diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index ec85674e..7e6c409b 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -13,5 +13,3 @@ jobs: fail_on_error: true level: warning debug: true - env: - GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}} diff --git a/README.md b/README.md index 8a89cdff..e581d45d 100644 --- a/README.md +++ b/README.md @@ -22,10 +22,6 @@ jobs: steps: - uses: actions/checkout@v3 - uses: errata-ai/vale-action@reviewdog - env: - # Required, set by GitHub actions automatically: - # https://docs.github.com/en/actions/security-guides/automatic-token-authentication#about-the-github_token-secret - GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}} ``` ## Repository Structure @@ -131,4 +127,13 @@ with: vale_flags: "--glob=*.txt" ``` +### `token` (default: [`secrets.GITHUB_TOKEN`](https://docs.github.com/en/actions/security-guides/automatic-token-authentication)) + +The GitHub token to use. + +```yaml +with: + token: ${{secrets.VALE_GITHUB_TOKEN}} +``` + [1]: https://help.github.com/en/github/automating-your-workflow-with-github-actions/configuring-a-workflow diff --git a/action.yml b/action.yml index c0e19c16..aafc1fe4 100644 --- a/action.yml +++ b/action.yml @@ -55,6 +55,11 @@ inputs: required: false default: "" + token: + description: "The GitHub token to use." + required: false + default: ${{ github.token }} + runs: using: docker image: Dockerfile diff --git a/lib/main.js b/lib/main.js index 63b713fb..6edff8c4 100644 --- a/lib/main.js +++ b/lib/main.js @@ -38,7 +38,7 @@ const input = __importStar(require("./input")); * * See https://bit.ly/2WlFUD7 for more information. */ -const { GITHUB_TOKEN, GITHUB_WORKSPACE } = process.env; +const { GITHUB_WORKSPACE } = process.env; function run(actionInput) { return __awaiter(this, void 0, void 0, function* () { const workdir = core.getInput('workdir') || '.'; @@ -53,7 +53,7 @@ function run(actionInput) { const vale_code = output.exitCode; const should_fail = core.getInput('fail_on_error'); // Pipe to reviewdog ... - process.env['REVIEWDOG_GITHUB_API_TOKEN'] = GITHUB_TOKEN; + process.env['REVIEWDOG_GITHUB_API_TOKEN'] = core.getInput('token'); return yield exec.exec('/bin/reviewdog', [ '-f=rdjsonl', `-name=vale`, @@ -85,7 +85,7 @@ exports.run = run; function main() { return __awaiter(this, void 0, void 0, function* () { try { - const userToken = GITHUB_TOKEN; + const userToken = core.getInput('token'); const workspace = GITHUB_WORKSPACE; const actionInput = yield input.get(userToken, workspace); yield run(actionInput); diff --git a/src/main.ts b/src/main.ts index f5aa965c..5ecea802 100644 --- a/src/main.ts +++ b/src/main.ts @@ -10,7 +10,7 @@ import * as input from './input'; * * See https://bit.ly/2WlFUD7 for more information. */ -const {GITHUB_TOKEN, GITHUB_WORKSPACE} = process.env; +const {GITHUB_WORKSPACE} = process.env; export async function run(actionInput: input.Input): Promise { const workdir = core.getInput('workdir') || '.'; @@ -37,7 +37,7 @@ export async function run(actionInput: input.Input): Promise { const should_fail = core.getInput('fail_on_error'); // Pipe to reviewdog ... - process.env['REVIEWDOG_GITHUB_API_TOKEN'] = GITHUB_TOKEN; + process.env['REVIEWDOG_GITHUB_API_TOKEN'] = core.getInput('token'); return await exec.exec( '/bin/reviewdog', [ @@ -71,7 +71,7 @@ export async function run(actionInput: input.Input): Promise { async function main(): Promise { try { - const userToken = GITHUB_TOKEN as string; + const userToken = core.getInput('token'); const workspace = GITHUB_WORKSPACE as string; const actionInput = await input.get(userToken, workspace);