diff --git a/.github/actions/rendered-content-link-checker.js b/.github/actions/rendered-content-link-checker.js index 7b762399da..d2b49b5524 100755 --- a/.github/actions/rendered-content-link-checker.js +++ b/.github/actions/rendered-content-link-checker.js @@ -51,9 +51,6 @@ const deprecatedVersionPrefixesRegex = new RegExp( // When this file is invoked directly from action as opposed to being imported if (import.meta.url.endsWith(process.argv[1])) { - // Validate that required action inputs are present - getEnvInputs(['GITHUB_TOKEN']) - // Optional env vars const { ACTION_RUN_URL, @@ -94,7 +91,7 @@ if (import.meta.url.endsWith(process.argv[1])) { language: 'en', actionUrl: ACTION_RUN_URL, checkExternalLinks: CHECK_EXTERNAL_LINKS === 'true', - shouldComment: SHOULD_COMMENT === 'true', + shouldComment: Boolean(JSON.parse(SHOULD_COMMENT)), commentLimitToExternalLinks: COMMENT_LIMIT_TO_EXTERNAL_LINKS === 'true', failOnFlaw: FAIL_ON_FLAW === 'true', createReport: CREATE_REPORT === 'true', @@ -104,6 +101,12 @@ if (import.meta.url.endsWith(process.argv[1])) { actionContext: getActionContext(), } + if (opts.shouldComment || opts.createReport) { + // `GITHUB_TOKEN` is optional. If you need the token to post a comment + // or open an issue report, you might get cryptic error messages from Octokit. + getEnvInputs(['GITHUB_TOKEN']) + } + main(coreLib, octokit, uploadArtifactLib, opts, {}) } diff --git a/.github/workflows/link-check-on-pr.yml b/.github/workflows/link-check-on-pr.yml index 1af11a5ce2..076140e4e5 100644 --- a/.github/workflows/link-check-on-pr.yml +++ b/.github/workflows/link-check-on-pr.yml @@ -10,7 +10,7 @@ on: push: branches: - main - pull_request_target: + pull_request: permissions: contents: read @@ -72,7 +72,7 @@ jobs: LEVEL: 'critical' ACTION_RUN_URL: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }} GITHUB_TOKEN: ${{ secrets.DOCS_BOT_FR }} - SHOULD_COMMENT: true + SHOULD_COMMENT: ${{ secrets.DOCS_BOT_FR != '' }} CHECK_EXTERNAL_LINKS: false CREATE_REPORT: false run: node .github/actions/rendered-content-link-checker.js