From 4a534c5d82018cb2d14fb6978b7de3c359a08ad1 Mon Sep 17 00:00:00 2001 From: Kevin Heis Date: Fri, 13 Oct 2023 11:06:12 -0700 Subject: [PATCH] Standardized slack alert fails (#44074) --- .github/actions/slack-alert/action.yml | 29 ++++++++ .github/workflows/add-review-template.yml | 5 ++ .github/workflows/auto-close-dependencies.yml | 5 ++ .../workflows/azure-preview-env-deploy.yml | 5 ++ .../workflows/azure-preview-env-destroy.yml | 7 +- .github/workflows/azure-prod-build-deploy.yml | 10 +-- .../workflows/azure-staging-build-deploy.yml | 5 ++ .../check-broken-links-github-github.yml | 10 +-- .github/workflows/check-for-spammy-issues.yml | 5 ++ .github/workflows/close-bad-repo-sync-prs.yml | 10 +-- .github/workflows/close-on-invalid-label.yaml | 5 ++ .../workflows/codeowners-content-strategy.yml | 5 ++ .../workflows/codeowners-docs-engineering.yml | 6 ++ .github/workflows/codeql.yml | 5 ++ .../confirm-internal-staff-work-in-docs.yml | 5 ++ .../content-changes-table-comment.yml | 10 +++ .github/workflows/content-lint-markdown.yml | 5 ++ .../workflows/copy-api-issue-to-internal.yml | 5 ++ .github/workflows/docs-review-collect.yml | 5 ++ .github/workflows/dont-delete-assets.yml | 5 ++ .github/workflows/enterprise-dates.yml | 10 +-- .../first-responder-docs-content.yml | 9 +++ .github/workflows/headless-tests.yml | 5 ++ .../workflows/hubber-contribution-help.yml | 5 ++ .github/workflows/keep-caches-warm.yml | 5 ++ .github/workflows/link-check-daily.yml | 5 ++ .github/workflows/link-check-on-pr.yml | 5 ++ .github/workflows/lint-code.yml | 5 ++ .../lint-entire-content-data-markdown.yml | 5 ++ .github/workflows/local-dev.yml | 5 ++ .../workflows/main-preview-docker-cache.yml | 5 ++ .github/workflows/manually-purge-fastly.yml | 5 ++ .github/workflows/merged-notification.yml | 5 ++ ...ve-existing-issues-to-the-correct-repo.yml | 5 ++ .github/workflows/move-help-wanted-issues.yml | 5 ++ .../move-new-issues-to-correct-docs-repo.yml | 5 ++ .github/workflows/move-ready-to-merge-pr.yaml | 5 ++ .../move-reopened-issues-to-triage.yaml | 5 ++ .github/workflows/needs-sme-stale-check.yaml | 5 ++ .github/workflows/needs-sme-workflow.yml | 9 +++ .github/workflows/no-response.yaml | 5 ++ .github/workflows/notify-about-deployment.yml | 5 ++ .../notify-when-maintainers-cannot-edit.yaml | 5 ++ .github/workflows/open-enterprise-issue.yml | 5 ++ .github/workflows/optimize-images.yml | 5 ++ .github/workflows/orphaned-assets-check.yml | 10 +-- .github/workflows/os-ready-for-review.yml | 5 ++ .github/workflows/package-lock-lint.yml | 5 ++ .github/workflows/purge-fastly.yml | 5 ++ .../purge-old-deployment-environments.yml | 10 +-- .github/workflows/purge-old-workflow-runs.yml | 10 +-- .github/workflows/ready-for-doc-review.yml | 5 ++ .github/workflows/remove-from-fr-board.yaml | 5 ++ .github/workflows/repo-freeze-check.yml | 5 ++ .github/workflows/repo-sync-stalls.yml | 11 ++- .github/workflows/repo-sync.yml | 10 +-- .../secret-scanning-pattern-table-updates.yml | 5 ++ .github/workflows/site-policy-reminder.yml | 5 ++ .github/workflows/site-policy-sync.yml | 5 ++ .github/workflows/stale.yml | 5 ++ .github/workflows/sync-audit-logs.yml | 10 +-- .github/workflows/sync-codeql-cli.yml | 10 +-- .github/workflows/sync-graphql.yml | 11 ++- .github/workflows/sync-openapi.yml | 10 +-- .../workflows/sync-search-elasticsearch.yml | 14 ++-- .github/workflows/sync-search-pr.yml | 5 ++ .github/workflows/test-changed-content.yml | 5 ++ .github/workflows/test.yml | 7 +- .../transfer-api-issue-to-openapi.yml | 5 ++ .../workflows/translation-health-report.yml | 11 +-- .github/workflows/triage-issue-comments.yml | 5 ++ .github/workflows/triage-issues.yml | 5 ++ .github/workflows/triage-pull-requests.yml | 5 ++ .github/workflows/triage-stale-check.yml | 10 +++ .../triage-unallowed-contributions.yml | 5 ++ .github/workflows/validate-asset-images.yml | 5 ++ src/workflows/tests/actions-workflows.js | 72 +++++++++++++++++++ tests/unit/actions-workflows.js | 58 --------------- 78 files changed, 473 insertions(+), 166 deletions(-) create mode 100644 .github/actions/slack-alert/action.yml create mode 100644 src/workflows/tests/actions-workflows.js delete mode 100644 tests/unit/actions-workflows.js diff --git a/.github/actions/slack-alert/action.yml b/.github/actions/slack-alert/action.yml new file mode 100644 index 000000000000..f73f51a9fa4b --- /dev/null +++ b/.github/actions/slack-alert/action.yml @@ -0,0 +1,29 @@ +name: Send Slack notification if workflow fails +description: Send Slack notification if workflow fails + +inputs: + slack_channel_id: + description: Slack channel ID + required: true + slack_token: + description: Slack token + required: true + +runs: + using: composite + steps: + - name: Send Slack notification if workflow fails + uses: someimportantcompany/github-actions-slack-message@1d367080235edfa53df415bd8e0bbab480f29bad + if: >- + ${{ + failure() && + env.FREEZE != 'true' && + github.repository == 'github/docs-internal' && + github.event_name != 'pull_request' && + github.event_name != 'pull_request_target' + }} + with: + channel: ${{ inputs.slack_channel_id }} + bot-token: ${{ inputs.slack_token }} + color: failure + text: The last '${{ github.workflow }}' run failed. See ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }} diff --git a/.github/workflows/add-review-template.yml b/.github/workflows/add-review-template.yml index 6d9896f27efc..493c6c338f1e 100644 --- a/.github/workflows/add-review-template.yml +++ b/.github/workflows/add-review-template.yml @@ -37,3 +37,8 @@ jobs: GITHUB_TOKEN: ${{ secrets.DOCS_BOT_PAT_WORKFLOW_READORG }} PR: ${{ github.event.pull_request.html_url }} TEMPLATE: ${{ env.TEMPLATE }} + + - uses: ./.github/actions/slack-alert + with: + slack_channel_id: ${{ secrets.DOCS_ALERTS_SLACK_CHANNEL_ID }} + slack_token: ${{ secrets.SLACK_DOCS_BOT_TOKEN }} diff --git a/.github/workflows/auto-close-dependencies.yml b/.github/workflows/auto-close-dependencies.yml index 5a2059562d06..5e30d319be79 100644 --- a/.github/workflows/auto-close-dependencies.yml +++ b/.github/workflows/auto-close-dependencies.yml @@ -66,3 +66,8 @@ jobs: console.error(`Failed to lock the pull request. Error: ${error}`) throw error } + + - uses: ./.github/actions/slack-alert + with: + slack_channel_id: ${{ secrets.DOCS_ALERTS_SLACK_CHANNEL_ID }} + slack_token: ${{ secrets.SLACK_DOCS_BOT_TOKEN }} diff --git a/.github/workflows/azure-preview-env-deploy.yml b/.github/workflows/azure-preview-env-deploy.yml index 09d5ba9c6000..f2543262eec6 100644 --- a/.github/workflows/azure-preview-env-deploy.yml +++ b/.github/workflows/azure-preview-env-deploy.yml @@ -254,3 +254,8 @@ jobs: # The `--fail --retry N` combination means that a 4xx response # code will exit immediately but a 5xx will exhaust the retries. run: curl --fail --retry-connrefused --retry 5 -I ${{ env.APP_URL }} + + - uses: ./.github/actions/slack-alert + with: + slack_channel_id: ${{ secrets.DOCS_ALERTS_SLACK_CHANNEL_ID }} + slack_token: ${{ secrets.SLACK_DOCS_BOT_TOKEN }} diff --git a/.github/workflows/azure-preview-env-destroy.yml b/.github/workflows/azure-preview-env-destroy.yml index c0ac240f6c4d..8679da1d9d6e 100644 --- a/.github/workflows/azure-preview-env-destroy.yml +++ b/.github/workflows/azure-preview-env-destroy.yml @@ -25,7 +25,7 @@ concurrency: cancel-in-progress: true jobs: - destory-azure-preview-env: + destroy-azure-preview-env: name: Destroy runs-on: ubuntu-latest if: github.repository == 'github/docs-internal' || github.repository == 'github/docs' @@ -70,3 +70,8 @@ jobs: # The token provided by the workflow does not have the permissions to delete created environments token: ${{ secrets.DOCS_BOT_PAT_READPUBLICKEY }} environment: preview-env-${{ env.PR_NUMBER }} + + - uses: ./.github/actions/slack-alert + with: + slack_channel_id: ${{ secrets.DOCS_ALERTS_SLACK_CHANNEL_ID }} + slack_token: ${{ secrets.SLACK_DOCS_BOT_TOKEN }} diff --git a/.github/workflows/azure-prod-build-deploy.yml b/.github/workflows/azure-prod-build-deploy.yml index fbc41676fe38..bfb2e8a2dc9b 100644 --- a/.github/workflows/azure-prod-build-deploy.yml +++ b/.github/workflows/azure-prod-build-deploy.yml @@ -146,11 +146,7 @@ jobs: run: | az webapp deployment slot swap --slot canary --target-slot production -n ghdocs-prod -g docs-prod - - name: Send Slack notification if workflow failed - uses: someimportantcompany/github-actions-slack-message@1d367080235edfa53df415bd8e0bbab480f29bad - if: ${{ failure() }} + - uses: ./.github/actions/slack-alert with: - channel: ${{ secrets.DOCS_ALERTS_SLACK_CHANNEL_ID }} - bot-token: ${{ secrets.SLACK_DOCS_BOT_TOKEN }} - color: failure - text: Production deployment (Azure) failed at commit ${{ github.sha }}. See https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }} + slack_channel_id: ${{ secrets.DOCS_ALERTS_SLACK_CHANNEL_ID }} + slack_token: ${{ secrets.SLACK_DOCS_BOT_TOKEN }} diff --git a/.github/workflows/azure-staging-build-deploy.yml b/.github/workflows/azure-staging-build-deploy.yml index 101103d69330..5eda678815b9 100644 --- a/.github/workflows/azure-staging-build-deploy.yml +++ b/.github/workflows/azure-staging-build-deploy.yml @@ -157,3 +157,8 @@ jobs: - name: 'Swap deployment slot to production' run: | az webapp deployment slot swap --slot ${{ env.SLOT_NAME }} --target-slot production -n ${{ env.APP_SERVICE_NAME }} -g ${{ env.RESOURCE_GROUP_NAME }} + + - uses: ./.github/actions/slack-alert + with: + slack_channel_id: ${{ secrets.DOCS_ALERTS_SLACK_CHANNEL_ID }} + slack_token: ${{ secrets.SLACK_DOCS_BOT_TOKEN }} diff --git a/.github/workflows/check-broken-links-github-github.yml b/.github/workflows/check-broken-links-github-github.yml index 17868efc7707..28ead2925c2b 100644 --- a/.github/workflows/check-broken-links-github-github.yml +++ b/.github/workflows/check-broken-links-github-github.yml @@ -87,11 +87,7 @@ jobs: repository: ${{ env.REPORT_REPOSITORY }} labels: ${{ env.REPORT_LABEL }} - - name: Send Slack notification if workflow fails - uses: someimportantcompany/github-actions-slack-message@1d367080235edfa53df415bd8e0bbab480f29bad - if: ${{ failure() && env.FREEZE != 'true' }} + - uses: ./.github/actions/slack-alert with: - channel: ${{ secrets.DOCS_ALERTS_SLACK_CHANNEL_ID }} - bot-token: ${{ secrets.SLACK_DOCS_BOT_TOKEN }} - color: failure - text: The last "Check Broken Docs Links in github/github" run for ${{github.repository}} failed. See https://github.com/${{github.repository}}/actions/workflows/check-broken-links-github-github.yml + slack_channel_id: ${{ secrets.DOCS_ALERTS_SLACK_CHANNEL_ID }} + slack_token: ${{ secrets.SLACK_DOCS_BOT_TOKEN }} diff --git a/.github/workflows/check-for-spammy-issues.yml b/.github/workflows/check-for-spammy-issues.yml index cd6a7ae31541..7b95210caa73 100644 --- a/.github/workflows/check-for-spammy-issues.yml +++ b/.github/workflows/check-for-spammy-issues.yml @@ -80,3 +80,8 @@ jobs: } catch (error) { console.log(error); } + + - uses: ./.github/actions/slack-alert + with: + slack_channel_id: ${{ secrets.DOCS_ALERTS_SLACK_CHANNEL_ID }} + slack_token: ${{ secrets.SLACK_DOCS_BOT_TOKEN }} diff --git a/.github/workflows/close-bad-repo-sync-prs.yml b/.github/workflows/close-bad-repo-sync-prs.yml index aa519f5d9a9d..57dd4b349406 100644 --- a/.github/workflows/close-bad-repo-sync-prs.yml +++ b/.github/workflows/close-bad-repo-sync-prs.yml @@ -61,11 +61,7 @@ jobs: body: "Please leave this `repo-sync` branch to the robots!\n\nI'm going to close this pull request now, but feel free to open a new issue or ask any questions in [discussions](https://github.com/github/docs/discussions)!" }) - - name: Send Slack notification if workflow fails - uses: someimportantcompany/github-actions-slack-message@1d367080235edfa53df415bd8e0bbab480f29bad - if: failure() + - uses: ./.github/actions/slack-alert with: - channel: ${{ secrets.DOCS_ALERTS_SLACK_CHANNEL_ID }} - bot-token: ${{ secrets.SLACK_DOCS_BOT_TOKEN }} - color: failure - text: The last close-bad-repo-sync-prs run for ${{github.repository}} failed. See https://github.com/${{github.repository}}/actions?query=Close+bad+repo-sync+PRs + slack_channel_id: ${{ secrets.DOCS_ALERTS_SLACK_CHANNEL_ID }} + slack_token: ${{ secrets.SLACK_DOCS_BOT_TOKEN }} diff --git a/.github/workflows/close-on-invalid-label.yaml b/.github/workflows/close-on-invalid-label.yaml index 4812cf1651f9..869d01eec192 100644 --- a/.github/workflows/close-on-invalid-label.yaml +++ b/.github/workflows/close-on-invalid-label.yaml @@ -31,3 +31,8 @@ jobs: env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} run: gh pr close ${{ github.event.pull_request.html_url }} + + - uses: ./.github/actions/slack-alert + with: + slack_channel_id: ${{ secrets.DOCS_ALERTS_SLACK_CHANNEL_ID }} + slack_token: ${{ secrets.SLACK_DOCS_BOT_TOKEN }} diff --git a/.github/workflows/codeowners-content-strategy.yml b/.github/workflows/codeowners-content-strategy.yml index 8b777ebd1004..2199c9fee82a 100644 --- a/.github/workflows/codeowners-content-strategy.yml +++ b/.github/workflows/codeowners-content-strategy.yml @@ -20,3 +20,8 @@ jobs: GH_TOKEN: ${{ secrets.DOCS_BOT_PAT_WRITEORG_PROJECT }} PR: ${{ github.event.pull_request.html_url }} run: gh pr edit $PR --add-reviewer github/docs-content-strategy + + - uses: ./.github/actions/slack-alert + with: + slack_channel_id: ${{ secrets.DOCS_ALERTS_SLACK_CHANNEL_ID }} + slack_token: ${{ secrets.SLACK_DOCS_BOT_TOKEN }} diff --git a/.github/workflows/codeowners-docs-engineering.yml b/.github/workflows/codeowners-docs-engineering.yml index 74cde62a487b..176db05de01b 100644 --- a/.github/workflows/codeowners-docs-engineering.yml +++ b/.github/workflows/codeowners-docs-engineering.yml @@ -57,6 +57,7 @@ jobs: id=9664BE8F1CA3 body=$(gh pr view $PR --json body | jq -r .body) append=$(cat <<-EOM + ### For engineers @@ -75,3 +76,8 @@ jobs: body+=$append gh pr edit $PR --body "$body" fi + + - uses: ./.github/actions/slack-alert + with: + slack_channel_id: ${{ secrets.DOCS_ALERTS_SLACK_CHANNEL_ID }} + slack_token: ${{ secrets.SLACK_DOCS_BOT_TOKEN }} diff --git a/.github/workflows/codeql.yml b/.github/workflows/codeql.yml index bb74819fa727..2eb1eac0ee41 100644 --- a/.github/workflows/codeql.yml +++ b/.github/workflows/codeql.yml @@ -36,3 +36,8 @@ jobs: languages: javascript # comma separated list of values from {go, python, javascript, java, cpp, csharp, ruby} - uses: github/codeql-action/analyze@32dc499307d133bb5085bae78498c0ac2cf762d5 continue-on-error: true + + - uses: ./.github/actions/slack-alert + with: + slack_channel_id: ${{ secrets.DOCS_ALERTS_SLACK_CHANNEL_ID }} + slack_token: ${{ secrets.SLACK_DOCS_BOT_TOKEN }} diff --git a/.github/workflows/confirm-internal-staff-work-in-docs.yml b/.github/workflows/confirm-internal-staff-work-in-docs.yml index 1cf4c5e65c17..07aa051adf3c 100644 --- a/.github/workflows/confirm-internal-staff-work-in-docs.yml +++ b/.github/workflows/confirm-internal-staff-work-in-docs.yml @@ -79,3 +79,8 @@ jobs: channel: ${{ secrets.DOCS_OPEN_SOURCE_SLACK_CHANNEL_ID }} bot-token: ${{ secrets.SLACK_DOCS_BOT_TOKEN }} text: <@${{github.actor}}> opened https://github.com/github/docs/issues/${{ github.event.number || github.event.issue.number }} publicly on the github/docs repo instead of a private repo. They have been notified via a new issue in the private repo to confirm this was intentional. + + - uses: ./.github/actions/slack-alert + with: + slack_channel_id: ${{ secrets.DOCS_ALERTS_SLACK_CHANNEL_ID }} + slack_token: ${{ secrets.SLACK_DOCS_BOT_TOKEN }} diff --git a/.github/workflows/content-changes-table-comment.yml b/.github/workflows/content-changes-table-comment.yml index 6c6e53cdc8f9..8951a48ce7fd 100644 --- a/.github/workflows/content-changes-table-comment.yml +++ b/.github/workflows/content-changes-table-comment.yml @@ -41,6 +41,11 @@ jobs: filterContentDir: - 'content/**/*' + - uses: ./.github/actions/slack-alert + with: + slack_channel_id: ${{ secrets.DOCS_ALERTS_SLACK_CHANNEL_ID }} + slack_token: ${{ secrets.SLACK_DOCS_BOT_TOKEN }} + filterContentDir: needs: PR-Preview-Links if: ${{ needs.PR-Preview-Links.outputs.filterContentDir == 'true' }} @@ -107,3 +112,8 @@ jobs: ghes: GitHub Enterprise Server ghae: GitHub AE edit-mode: replace + + - uses: ./.github/actions/slack-alert + with: + slack_channel_id: ${{ secrets.DOCS_ALERTS_SLACK_CHANNEL_ID }} + slack_token: ${{ secrets.SLACK_DOCS_BOT_TOKEN }} diff --git a/.github/workflows/content-lint-markdown.yml b/.github/workflows/content-lint-markdown.yml index a9f3b7408f7d..0f3058babce5 100644 --- a/.github/workflows/content-lint-markdown.yml +++ b/.github/workflows/content-lint-markdown.yml @@ -39,3 +39,8 @@ jobs: - name: Run content linter if changed content/data files if: steps.changed-files.outputs.any_changed == 'true' run: npm run lint-content -- --errors-only --paths ${{ steps.changed-files.outputs.all_changed_files }} + + - uses: ./.github/actions/slack-alert + with: + slack_channel_id: ${{ secrets.DOCS_ALERTS_SLACK_CHANNEL_ID }} + slack_token: ${{ secrets.SLACK_DOCS_BOT_TOKEN }} diff --git a/.github/workflows/copy-api-issue-to-internal.yml b/.github/workflows/copy-api-issue-to-internal.yml index 03d0d7f74154..e979e50983a8 100644 --- a/.github/workflows/copy-api-issue-to-internal.yml +++ b/.github/workflows/copy-api-issue-to-internal.yml @@ -70,3 +70,8 @@ jobs: GITHUB_TOKEN: ${{secrets.DOCS_BOT_PAT_WORKFLOW_READORG}} NEW_ISSUE: ${{ env.NEW_ISSUE }} OLD_ISSUE: ${{ github.event.issue.html_url }} + + - uses: ./.github/actions/slack-alert + with: + slack_channel_id: ${{ secrets.DOCS_ALERTS_SLACK_CHANNEL_ID }} + slack_token: ${{ secrets.SLACK_DOCS_BOT_TOKEN }} diff --git a/.github/workflows/docs-review-collect.yml b/.github/workflows/docs-review-collect.yml index 8ccbbe577820..503018c00030 100644 --- a/.github/workflows/docs-review-collect.yml +++ b/.github/workflows/docs-review-collect.yml @@ -52,3 +52,8 @@ jobs: REPO: 'audit-log-allowlists' REVIEWER: 'docs-reviewers' FEATURE: 'Audit log event descriptions' + + - uses: ./.github/actions/slack-alert + with: + slack_channel_id: ${{ secrets.DOCS_ALERTS_SLACK_CHANNEL_ID }} + slack_token: ${{ secrets.SLACK_DOCS_BOT_TOKEN }} diff --git a/.github/workflows/dont-delete-assets.yml b/.github/workflows/dont-delete-assets.yml index af4127652f77..2c84c321134a 100644 --- a/.github/workflows/dont-delete-assets.yml +++ b/.github/workflows/dont-delete-assets.yml @@ -63,3 +63,8 @@ jobs: echo "More than 1 asset image was deleted as part of this PR." echo "See posted PR commented about how to get them back." exit 1 + + - uses: ./.github/actions/slack-alert + with: + slack_channel_id: ${{ secrets.DOCS_ALERTS_SLACK_CHANNEL_ID }} + slack_token: ${{ secrets.SLACK_DOCS_BOT_TOKEN }} diff --git a/.github/workflows/enterprise-dates.yml b/.github/workflows/enterprise-dates.yml index 897c06be47b0..002a9cd9eb0f 100644 --- a/.github/workflows/enterprise-dates.yml +++ b/.github/workflows/enterprise-dates.yml @@ -87,11 +87,7 @@ jobs: github-token: ${{ secrets.GITHUB_TOKEN }} number: ${{ steps.create-pull-request.outputs.pull-request-number }} - - name: Send Slack notification if workflow fails - uses: someimportantcompany/github-actions-slack-message@1d367080235edfa53df415bd8e0bbab480f29bad - if: ${{ failure() && env.FREEZE != 'true' }} + - uses: ./.github/actions/slack-alert with: - channel: ${{ secrets.DOCS_ALERTS_SLACK_CHANNEL_ID }} - bot-token: ${{ secrets.SLACK_DOCS_BOT_TOKEN }} - color: failure - text: The last enterprise-dates run for ${{github.repository}} failed. See https://github.com/${{github.repository}}/actions/workflows/enterprise-dates.yml + slack_channel_id: ${{ secrets.DOCS_ALERTS_SLACK_CHANNEL_ID }} + slack_token: ${{ secrets.SLACK_DOCS_BOT_TOKEN }} diff --git a/.github/workflows/first-responder-docs-content.yml b/.github/workflows/first-responder-docs-content.yml index 469f289fb51b..9541c391780b 100644 --- a/.github/workflows/first-responder-docs-content.yml +++ b/.github/workflows/first-responder-docs-content.yml @@ -62,6 +62,10 @@ jobs: project-url: 'https://github.com/orgs/github/projects/1367' column-name: 'Docs-internal external contributor PRs' + - uses: ./.github/actions/slack-alert + with: + slack_channel_id: ${{ secrets.DOCS_ALERTS_SLACK_CHANNEL_ID }} + slack_token: ${{ secrets.SLACK_DOCS_BOT_TOKEN }} first-responder-remove-pr: name: Remove PR from FR project board if: github.repository == 'github/docs-internal' && ((github.event.label.name == 'docs-content-fr' && github.event.action == 'unlabeled') || github.event.action == 'closed') && github.actor != 'dependabot[bot]' @@ -94,3 +98,8 @@ jobs: with: repo-token: '${{ secrets.DOCS_BOT_PAT_WORKFLOW_READORG }}' remove-labels: 'docs-content-fr' + + - uses: ./.github/actions/slack-alert + with: + slack_channel_id: ${{ secrets.DOCS_ALERTS_SLACK_CHANNEL_ID }} + slack_token: ${{ secrets.SLACK_DOCS_BOT_TOKEN }} diff --git a/.github/workflows/headless-tests.yml b/.github/workflows/headless-tests.yml index d57fb0b45a4c..bba3d0cfee11 100644 --- a/.github/workflows/headless-tests.yml +++ b/.github/workflows/headless-tests.yml @@ -58,3 +58,8 @@ jobs: # so that we can run them without blocking merges until we can be confident # results for a11y tests are meaningul and scenarios we're testing are correct. run: npm run playwright-test -- ${{ matrix.node }} --reporter list + + - uses: ./.github/actions/slack-alert + with: + slack_channel_id: ${{ secrets.DOCS_ALERTS_SLACK_CHANNEL_ID }} + slack_token: ${{ secrets.SLACK_DOCS_BOT_TOKEN }} diff --git a/.github/workflows/hubber-contribution-help.yml b/.github/workflows/hubber-contribution-help.yml index f24333c28eed..6b9a1a8befb8 100644 --- a/.github/workflows/hubber-contribution-help.yml +++ b/.github/workflows/hubber-contribution-help.yml @@ -48,3 +48,8 @@ jobs: env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} PR: ${{ github.event.pull_request.html_url }} + + - uses: ./.github/actions/slack-alert + with: + slack_channel_id: ${{ secrets.DOCS_ALERTS_SLACK_CHANNEL_ID }} + slack_token: ${{ secrets.SLACK_DOCS_BOT_TOKEN }} diff --git a/.github/workflows/keep-caches-warm.yml b/.github/workflows/keep-caches-warm.yml index 5ba8b5bb7972..69c29972fa5f 100644 --- a/.github/workflows/keep-caches-warm.yml +++ b/.github/workflows/keep-caches-warm.yml @@ -31,3 +31,8 @@ jobs: run: npm run build - uses: ./.github/actions/warmup-remotejson-cache + + - uses: ./.github/actions/slack-alert + with: + slack_channel_id: ${{ secrets.DOCS_ALERTS_SLACK_CHANNEL_ID }} + slack_token: ${{ secrets.SLACK_DOCS_BOT_TOKEN }} diff --git a/.github/workflows/link-check-daily.yml b/.github/workflows/link-check-daily.yml index 45dec2074422..403ade2b3b65 100644 --- a/.github/workflows/link-check-daily.yml +++ b/.github/workflows/link-check-daily.yml @@ -83,3 +83,8 @@ jobs: with: name: artifacts path: ./artifacts + + - uses: ./.github/actions/slack-alert + with: + slack_channel_id: ${{ secrets.DOCS_ALERTS_SLACK_CHANNEL_ID }} + slack_token: ${{ secrets.SLACK_DOCS_BOT_TOKEN }} diff --git a/.github/workflows/link-check-on-pr.yml b/.github/workflows/link-check-on-pr.yml index debc3b73c20a..84a3c68ecbb1 100644 --- a/.github/workflows/link-check-on-pr.yml +++ b/.github/workflows/link-check-on-pr.yml @@ -61,3 +61,8 @@ jobs: if: ${{ steps.changed_links.outputs.has_flaws_at_level == 'true' || steps.all_links.outputs.has_flaws_at_level == 'true' }} run: | exit 1 + + - uses: ./.github/actions/slack-alert + with: + slack_channel_id: ${{ secrets.DOCS_ALERTS_SLACK_CHANNEL_ID }} + slack_token: ${{ secrets.SLACK_DOCS_BOT_TOKEN }} diff --git a/.github/workflows/lint-code.yml b/.github/workflows/lint-code.yml index 45053238df68..e4b0e97f1832 100644 --- a/.github/workflows/lint-code.yml +++ b/.github/workflows/lint-code.yml @@ -47,3 +47,8 @@ jobs: - name: Run TypeScript run: npm run tsc + + - uses: ./.github/actions/slack-alert + with: + slack_channel_id: ${{ secrets.DOCS_ALERTS_SLACK_CHANNEL_ID }} + slack_token: ${{ secrets.SLACK_DOCS_BOT_TOKEN }} diff --git a/.github/workflows/lint-entire-content-data-markdown.yml b/.github/workflows/lint-entire-content-data-markdown.yml index cab4e1e4c89d..b58d48655892 100644 --- a/.github/workflows/lint-entire-content-data-markdown.yml +++ b/.github/workflows/lint-entire-content-data-markdown.yml @@ -42,3 +42,8 @@ jobs: REPORT_LABEL: broken content markdown report REPORT_REPOSITORY: github/docs-content run: node src/content-linter/scripts/post-lints.js --path /tmp/error-lints.json + + - uses: ./.github/actions/slack-alert + with: + slack_channel_id: ${{ secrets.DOCS_ALERTS_SLACK_CHANNEL_ID }} + slack_token: ${{ secrets.SLACK_DOCS_BOT_TOKEN }} diff --git a/.github/workflows/local-dev.yml b/.github/workflows/local-dev.yml index 56d621f32b16..467d1e015f7d 100644 --- a/.github/workflows/local-dev.yml +++ b/.github/workflows/local-dev.yml @@ -75,3 +75,8 @@ jobs: else echo "As expected, it failed :)" fi + + - uses: ./.github/actions/slack-alert + with: + slack_channel_id: ${{ secrets.DOCS_ALERTS_SLACK_CHANNEL_ID }} + slack_token: ${{ secrets.SLACK_DOCS_BOT_TOKEN }} diff --git a/.github/workflows/main-preview-docker-cache.yml b/.github/workflows/main-preview-docker-cache.yml index 459afbb3a4f1..3a45e4415922 100644 --- a/.github/workflows/main-preview-docker-cache.yml +++ b/.github/workflows/main-preview-docker-cache.yml @@ -76,3 +76,8 @@ jobs: tags: ${{ env.DOCKER_IMAGE_CACHE_REF }} cache-from: type=registry,ref=${{ env.DOCKER_IMAGE_CACHE_REF }} cache-to: type=registry,mode=max,ref=${{ env.DOCKER_IMAGE_CACHE_REF }} + + - uses: ./.github/actions/slack-alert + with: + slack_channel_id: ${{ secrets.DOCS_ALERTS_SLACK_CHANNEL_ID }} + slack_token: ${{ secrets.SLACK_DOCS_BOT_TOKEN }} diff --git a/.github/workflows/manually-purge-fastly.yml b/.github/workflows/manually-purge-fastly.yml index 686e1e155d7b..ec13e7f5e064 100644 --- a/.github/workflows/manually-purge-fastly.yml +++ b/.github/workflows/manually-purge-fastly.yml @@ -26,3 +26,8 @@ jobs: FASTLY_SERVICE_ID: ${{ secrets.FASTLY_SERVICE_ID }} FASTLY_SURROGATE_KEY: 'manual-purge' run: src/workflows/purge-fastly-edge-cache.js + + - uses: ./.github/actions/slack-alert + with: + slack_channel_id: ${{ secrets.DOCS_ALERTS_SLACK_CHANNEL_ID }} + slack_token: ${{ secrets.SLACK_DOCS_BOT_TOKEN }} diff --git a/.github/workflows/merged-notification.yml b/.github/workflows/merged-notification.yml index aca6d56dc901..92f5dcdeda37 100644 --- a/.github/workflows/merged-notification.yml +++ b/.github/workflows/merged-notification.yml @@ -26,3 +26,8 @@ jobs: issue_number: context.payload.pull_request.number, body: "Thanks very much for contributing! Your pull request has been merged 🎉 You should see your changes appear on the site in approximately 24 hours. If you're looking for your next contribution, check out our [help wanted issues](https://github.com/github/docs/issues?q=is%3Aopen+is%3Aissue+label%3A%22help+wanted%22) :zap:" }) + + - uses: ./.github/actions/slack-alert + with: + slack_channel_id: ${{ secrets.DOCS_ALERTS_SLACK_CHANNEL_ID }} + slack_token: ${{ secrets.SLACK_DOCS_BOT_TOKEN }} diff --git a/.github/workflows/move-existing-issues-to-the-correct-repo.yml b/.github/workflows/move-existing-issues-to-the-correct-repo.yml index 913db08a777a..560b37e66b1b 100644 --- a/.github/workflows/move-existing-issues-to-the-correct-repo.yml +++ b/.github/workflows/move-existing-issues-to-the-correct-repo.yml @@ -77,3 +77,8 @@ jobs: }) } } + + - uses: ./.github/actions/slack-alert + with: + slack_channel_id: ${{ secrets.DOCS_ALERTS_SLACK_CHANNEL_ID }} + slack_token: ${{ secrets.SLACK_DOCS_BOT_TOKEN }} diff --git a/.github/workflows/move-help-wanted-issues.yml b/.github/workflows/move-help-wanted-issues.yml index 12723ed6b036..376c36e38707 100644 --- a/.github/workflows/move-help-wanted-issues.yml +++ b/.github/workflows/move-help-wanted-issues.yml @@ -26,3 +26,8 @@ jobs: project: Docs open source board column: Help wanted repo-token: ${{ secrets.DOCS_BOT_PAT_WORKFLOW_READORG }} + + - uses: ./.github/actions/slack-alert + with: + slack_channel_id: ${{ secrets.DOCS_ALERTS_SLACK_CHANNEL_ID }} + slack_token: ${{ secrets.SLACK_DOCS_BOT_TOKEN }} diff --git a/.github/workflows/move-new-issues-to-correct-docs-repo.yml b/.github/workflows/move-new-issues-to-correct-docs-repo.yml index 08fcb335662d..a398365a07d2 100644 --- a/.github/workflows/move-new-issues-to-correct-docs-repo.yml +++ b/.github/workflows/move-new-issues-to-correct-docs-repo.yml @@ -88,3 +88,8 @@ jobs: issue_number: newIssueNumber, labels: context.payload.issue.labels.map(label => label.name), }) + + - uses: ./.github/actions/slack-alert + with: + slack_channel_id: ${{ secrets.DOCS_ALERTS_SLACK_CHANNEL_ID }} + slack_token: ${{ secrets.SLACK_DOCS_BOT_TOKEN }} diff --git a/.github/workflows/move-ready-to-merge-pr.yaml b/.github/workflows/move-ready-to-merge-pr.yaml index ec67617358b2..d4883db1b7e4 100644 --- a/.github/workflows/move-ready-to-merge-pr.yaml +++ b/.github/workflows/move-ready-to-merge-pr.yaml @@ -33,3 +33,8 @@ jobs: with: ignore-if-assigned: 'false' remove-labels: 'waiting for review' + + - uses: ./.github/actions/slack-alert + with: + slack_channel_id: ${{ secrets.DOCS_ALERTS_SLACK_CHANNEL_ID }} + slack_token: ${{ secrets.SLACK_DOCS_BOT_TOKEN }} diff --git a/.github/workflows/move-reopened-issues-to-triage.yaml b/.github/workflows/move-reopened-issues-to-triage.yaml index 05ccc5637349..020da40c1fc5 100644 --- a/.github/workflows/move-reopened-issues-to-triage.yaml +++ b/.github/workflows/move-reopened-issues-to-triage.yaml @@ -41,3 +41,8 @@ jobs: } catch(e) { console.log(e); } + + - uses: ./.github/actions/slack-alert + with: + slack_channel_id: ${{ secrets.DOCS_ALERTS_SLACK_CHANNEL_ID }} + slack_token: ${{ secrets.SLACK_DOCS_BOT_TOKEN }} diff --git a/.github/workflows/needs-sme-stale-check.yaml b/.github/workflows/needs-sme-stale-check.yaml index bff3cef07dae..31ce02720c3d 100644 --- a/.github/workflows/needs-sme-stale-check.yaml +++ b/.github/workflows/needs-sme-stale-check.yaml @@ -29,3 +29,8 @@ jobs: stale-pr-message: 'This is a gentle bump for the docs team that this PR is waiting for technical review.' stale-pr-label: SME stale days-before-pr-close: -1 # never close + + - uses: ./.github/actions/slack-alert + with: + slack_channel_id: ${{ secrets.DOCS_ALERTS_SLACK_CHANNEL_ID }} + slack_token: ${{ secrets.SLACK_DOCS_BOT_TOKEN }} diff --git a/.github/workflows/needs-sme-workflow.yml b/.github/workflows/needs-sme-workflow.yml index fd12d33af3ce..9641524a5d7f 100644 --- a/.github/workflows/needs-sme-workflow.yml +++ b/.github/workflows/needs-sme-workflow.yml @@ -25,6 +25,10 @@ jobs: body: | Thanks for opening an issue! We've triaged this issue for technical review by a subject matter expert :eyes: + - uses: ./.github/actions/slack-alert + with: + slack_channel_id: ${{ secrets.DOCS_ALERTS_SLACK_CHANNEL_ID }} + slack_token: ${{ secrets.SLACK_DOCS_BOT_TOKEN }} add-pr-comment: if: ${{ github.repository == 'github/docs' && (github.event.label.name == 'needs SME' && github.event_name == 'pull_request_target') }} runs-on: ubuntu-latest @@ -34,3 +38,8 @@ jobs: issue-number: ${{ github.event.pull_request.number }} body: | Thanks for opening a pull request! We've triaged this issue for technical review by a subject matter expert :eyes: + + - uses: ./.github/actions/slack-alert + with: + slack_channel_id: ${{ secrets.DOCS_ALERTS_SLACK_CHANNEL_ID }} + slack_token: ${{ secrets.SLACK_DOCS_BOT_TOKEN }} diff --git a/.github/workflows/no-response.yaml b/.github/workflows/no-response.yaml index 34e2c03ebd5b..06a172968360 100644 --- a/.github/workflows/no-response.yaml +++ b/.github/workflows/no-response.yaml @@ -46,3 +46,8 @@ jobs: to our request for more information from the original author. Please reach out if you have the information we requested, or open a [new issue](https://github.com/github/docs/issues/new/choose) to describing your changes. Then we can begin the review process. + + - uses: ./.github/actions/slack-alert + with: + slack_channel_id: ${{ secrets.DOCS_ALERTS_SLACK_CHANNEL_ID }} + slack_token: ${{ secrets.SLACK_DOCS_BOT_TOKEN }} diff --git a/.github/workflows/notify-about-deployment.yml b/.github/workflows/notify-about-deployment.yml index 377fcb706736..64258fb6dbac 100644 --- a/.github/workflows/notify-about-deployment.yml +++ b/.github/workflows/notify-about-deployment.yml @@ -65,3 +65,8 @@ jobs: If you don't see updates when expected, try adding a random query string to the URL like `?bla=1234` and see if that helps. If that shows the expected content, it would indicate that the CDN is "overly caching" the page still. It will eventually update, but it can take a while. edit-mode: replace + + - uses: ./.github/actions/slack-alert + with: + slack_channel_id: ${{ secrets.DOCS_ALERTS_SLACK_CHANNEL_ID }} + slack_token: ${{ secrets.SLACK_DOCS_BOT_TOKEN }} diff --git a/.github/workflows/notify-when-maintainers-cannot-edit.yaml b/.github/workflows/notify-when-maintainers-cannot-edit.yaml index f48160bd38d6..bb9760fe6154 100644 --- a/.github/workflows/notify-when-maintainers-cannot-edit.yaml +++ b/.github/workflows/notify-when-maintainers-cannot-edit.yaml @@ -62,3 +62,8 @@ jobs: } catch(e) { console.log(e); } + + - uses: ./.github/actions/slack-alert + with: + slack_channel_id: ${{ secrets.DOCS_ALERTS_SLACK_CHANNEL_ID }} + slack_token: ${{ secrets.SLACK_DOCS_BOT_TOKEN }} diff --git a/.github/workflows/open-enterprise-issue.yml b/.github/workflows/open-enterprise-issue.yml index 5309deb050d6..431aeae29015 100644 --- a/.github/workflows/open-enterprise-issue.yml +++ b/.github/workflows/open-enterprise-issue.yml @@ -50,3 +50,8 @@ jobs: src/versions/scripts/create-enterprise-issue.js deprecation env: GITHUB_TOKEN: ${{ secrets.DOCS_BOT_PAT_WRITEORG_PROJECT }} + + - uses: ./.github/actions/slack-alert + with: + slack_channel_id: ${{ secrets.DOCS_ALERTS_SLACK_CHANNEL_ID }} + slack_token: ${{ secrets.SLACK_DOCS_BOT_TOKEN }} diff --git a/.github/workflows/optimize-images.yml b/.github/workflows/optimize-images.yml index 9797d9da199b..359978e47827 100644 --- a/.github/workflows/optimize-images.yml +++ b/.github/workflows/optimize-images.yml @@ -70,3 +70,8 @@ jobs: git push env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + + - uses: ./.github/actions/slack-alert + with: + slack_channel_id: ${{ secrets.DOCS_ALERTS_SLACK_CHANNEL_ID }} + slack_token: ${{ secrets.SLACK_DOCS_BOT_TOKEN }} diff --git a/.github/workflows/orphaned-assets-check.yml b/.github/workflows/orphaned-assets-check.yml index d9b8fc36d8a0..2d68fc099e05 100644 --- a/.github/workflows/orphaned-assets-check.yml +++ b/.github/workflows/orphaned-assets-check.yml @@ -68,11 +68,7 @@ jobs: --repo github/docs-internal \ --label docs-content-fr - - name: Send Slack notification if workflow fails - uses: someimportantcompany/github-actions-slack-message@1d367080235edfa53df415bd8e0bbab480f29bad - if: ${{ failure() && env.FREEZE != 'true' }} + - uses: ./.github/actions/slack-alert with: - channel: ${{ secrets.DOCS_ALERTS_SLACK_CHANNEL_ID }} - bot-token: ${{ secrets.SLACK_DOCS_BOT_TOKEN }} - color: failure - text: The last "Orphaned assets check" run for ${{github.repository}} failed. See https://github.com/${{github.repository}}/actions/workflows/orphaned-assets-check.yml + slack_channel_id: ${{ secrets.DOCS_ALERTS_SLACK_CHANNEL_ID }} + slack_token: ${{ secrets.SLACK_DOCS_BOT_TOKEN }} diff --git a/.github/workflows/os-ready-for-review.yml b/.github/workflows/os-ready-for-review.yml index 29a9d7a59c9d..eb2144990f16 100644 --- a/.github/workflows/os-ready-for-review.yml +++ b/.github/workflows/os-ready-for-review.yml @@ -65,3 +65,8 @@ jobs: ITEM_NODE_ID: ${{ github.event.pull_request.node_id || github.event.issue.node_id }} AUTHOR_LOGIN: ${{ github.event.pull_request.user.login || github.event.issue.user.login }} REPO: ${{ github.repository }} + + - uses: ./.github/actions/slack-alert + with: + slack_channel_id: ${{ secrets.DOCS_ALERTS_SLACK_CHANNEL_ID }} + slack_token: ${{ secrets.SLACK_DOCS_BOT_TOKEN }} diff --git a/.github/workflows/package-lock-lint.yml b/.github/workflows/package-lock-lint.yml index 04971599d5d4..ff6430d7169b 100644 --- a/.github/workflows/package-lock-lint.yml +++ b/.github/workflows/package-lock-lint.yml @@ -51,3 +51,8 @@ jobs: # running `git status` should # say "nothing to commit, working tree clean". git diff --exit-code + + - uses: ./.github/actions/slack-alert + with: + slack_channel_id: ${{ secrets.DOCS_ALERTS_SLACK_CHANNEL_ID }} + slack_token: ${{ secrets.SLACK_DOCS_BOT_TOKEN }} diff --git a/.github/workflows/purge-fastly.yml b/.github/workflows/purge-fastly.yml index 72cd50ea29e4..edc936e0027f 100644 --- a/.github/workflows/purge-fastly.yml +++ b/.github/workflows/purge-fastly.yml @@ -47,3 +47,8 @@ jobs: env: LANGUAGES: ${{ inputs.languages }} run: src/languages/scripts/purge-fastly-edge-cache-per-language.js + + - uses: ./.github/actions/slack-alert + with: + slack_channel_id: ${{ secrets.DOCS_ALERTS_SLACK_CHANNEL_ID }} + slack_token: ${{ secrets.SLACK_DOCS_BOT_TOKEN }} diff --git a/.github/workflows/purge-old-deployment-environments.yml b/.github/workflows/purge-old-deployment-environments.yml index 9f55e3a47599..90c4e26ba94c 100644 --- a/.github/workflows/purge-old-deployment-environments.yml +++ b/.github/workflows/purge-old-deployment-environments.yml @@ -33,11 +33,7 @@ jobs: GITHUB_TOKEN: ${{ secrets.DOCS_BOT_PAT_WORKFLOW_READORG }} run: src/workflows/purge-old-deployment-environments.js - - name: Send Slack notification if workflow fails - uses: someimportantcompany/github-actions-slack-message@1d367080235edfa53df415bd8e0bbab480f29bad - if: ${{ failure() && env.FREEZE != 'true' }} + - uses: ./.github/actions/slack-alert with: - channel: ${{ secrets.DOCS_ALERTS_SLACK_CHANNEL_ID }} - bot-token: ${{ secrets.SLACK_DOCS_BOT_TOKEN }} - color: failure - text: The last "Purge old deployment environments" run for ${{github.repository}} failed. See https://github.com/${{github.repository}}/actions/workflows/purge-old-deployment-environments.yml + slack_channel_id: ${{ secrets.DOCS_ALERTS_SLACK_CHANNEL_ID }} + slack_token: ${{ secrets.SLACK_DOCS_BOT_TOKEN }} diff --git a/.github/workflows/purge-old-workflow-runs.yml b/.github/workflows/purge-old-workflow-runs.yml index a059296499b9..1341b3557e01 100644 --- a/.github/workflows/purge-old-workflow-runs.yml +++ b/.github/workflows/purge-old-workflow-runs.yml @@ -30,11 +30,7 @@ jobs: GITHUB_TOKEN: ${{ secrets.DOCS_BOT_PAT_WORKFLOW_READORG }} run: src/workflows/purge-old-workflow-runs.js - - name: Send Slack notification if workflow fails - uses: someimportantcompany/github-actions-slack-message@1d367080235edfa53df415bd8e0bbab480f29bad - if: ${{ failure() && env.FREEZE != 'true' }} + - uses: ./.github/actions/slack-alert with: - channel: ${{ secrets.DOCS_ALERTS_SLACK_CHANNEL_ID }} - bot-token: ${{ secrets.SLACK_DOCS_BOT_TOKEN }} - color: failure - text: The last "Purge old workflow runs" run for ${{github.repository}} failed. See https://github.com/${{github.repository}}/actions/workflows/purge-old-workflow-runs.yml + slack_channel_id: ${{ secrets.DOCS_ALERTS_SLACK_CHANNEL_ID }} + slack_token: ${{ secrets.SLACK_DOCS_BOT_TOKEN }} diff --git a/.github/workflows/ready-for-doc-review.yml b/.github/workflows/ready-for-doc-review.yml index 11fbe8471a8e..fe67fe7e85ac 100644 --- a/.github/workflows/ready-for-doc-review.yml +++ b/.github/workflows/ready-for-doc-review.yml @@ -52,3 +52,8 @@ jobs: action-token: ${{ secrets.DOCS_BOT_PAT_WORKFLOW_READORG }} project-url: 'https://github.com/orgs/github/projects/1367' column-name: 'Docs-internal external contributor PRs' + + - uses: ./.github/actions/slack-alert + with: + slack_channel_id: ${{ secrets.DOCS_ALERTS_SLACK_CHANNEL_ID }} + slack_token: ${{ secrets.SLACK_DOCS_BOT_TOKEN }} diff --git a/.github/workflows/remove-from-fr-board.yaml b/.github/workflows/remove-from-fr-board.yaml index 1fb5790a750c..9cf3a4b4a93a 100644 --- a/.github/workflows/remove-from-fr-board.yaml +++ b/.github/workflows/remove-from-fr-board.yaml @@ -28,3 +28,8 @@ jobs: env: GITHUB_TOKEN: ${{secrets.DOCS_BOT_PAT_WORKFLOW_READORG}} PR_URL: https://github.com/${{ github.event.client_payload.command.repository.full_name }}/pull/${{ github.event.client_payload.command.resource.number }} + + - uses: ./.github/actions/slack-alert + with: + slack_channel_id: ${{ secrets.DOCS_ALERTS_SLACK_CHANNEL_ID }} + slack_token: ${{ secrets.SLACK_DOCS_BOT_TOKEN }} diff --git a/.github/workflows/repo-freeze-check.yml b/.github/workflows/repo-freeze-check.yml index 4be314879c47..7e5cf0229397 100644 --- a/.github/workflows/repo-freeze-check.yml +++ b/.github/workflows/repo-freeze-check.yml @@ -34,3 +34,8 @@ jobs: run: | echo 'Merges into the "main" branch on this repo are currently paused!' exit 1 + + - uses: ./.github/actions/slack-alert + with: + slack_channel_id: ${{ secrets.DOCS_ALERTS_SLACK_CHANNEL_ID }} + slack_token: ${{ secrets.SLACK_DOCS_BOT_TOKEN }} diff --git a/.github/workflows/repo-sync-stalls.yml b/.github/workflows/repo-sync-stalls.yml index 918eb4e7afa4..1ccbf2ab4443 100644 --- a/.github/workflows/repo-sync-stalls.yml +++ b/.github/workflows/repo-sync-stalls.yml @@ -51,11 +51,8 @@ jobs: core.setFailed('Repo sync appears to be stalled') } }) - - name: Send Slack notification if workflow fails - uses: someimportantcompany/github-actions-slack-message@1d367080235edfa53df415bd8e0bbab480f29bad - if: ${{ failure() }} + + - uses: ./.github/actions/slack-alert with: - channel: ${{ secrets.DOCS_ALERTS_SLACK_CHANNEL_ID }} - bot-token: ${{ secrets.SLACK_DOCS_BOT_TOKEN }} - color: failure - text: Repo sync appears to be stalled for ${{github.repository}}. See https://github.com/${{github.repository}}/pulls?q=is%3Apr+is%3Aopen+label%3Aautomated-reposync-pr + slack_channel_id: ${{ secrets.DOCS_ALERTS_SLACK_CHANNEL_ID }} + slack_token: ${{ secrets.SLACK_DOCS_BOT_TOKEN }} diff --git a/.github/workflows/repo-sync.yml b/.github/workflows/repo-sync.yml index d874a4a8123d..37c6cb1074ff 100644 --- a/.github/workflows/repo-sync.yml +++ b/.github/workflows/repo-sync.yml @@ -136,11 +136,7 @@ jobs: // Error loud here, so no try/catch console.log('Merged the pull request successfully') - - name: Send Slack notification if workflow fails - if: failure() - uses: someimportantcompany/github-actions-slack-message@1d367080235edfa53df415bd8e0bbab480f29bad + - uses: ./.github/actions/slack-alert with: - channel: ${{ secrets.DOCS_ALERTS_SLACK_CHANNEL_ID }} - bot-token: ${{ secrets.SLACK_DOCS_BOT_TOKEN }} - color: failure - text: The last repo-sync run for ${{github.repository}} failed. See https://github.com/${{github.repository}}/actions/workflows/repo-sync.yml + slack_channel_id: ${{ secrets.DOCS_ALERTS_SLACK_CHANNEL_ID }} + slack_token: ${{ secrets.SLACK_DOCS_BOT_TOKEN }} diff --git a/.github/workflows/secret-scanning-pattern-table-updates.yml b/.github/workflows/secret-scanning-pattern-table-updates.yml index dff01ae65d14..a98caab6e075 100644 --- a/.github/workflows/secret-scanning-pattern-table-updates.yml +++ b/.github/workflows/secret-scanning-pattern-table-updates.yml @@ -41,3 +41,8 @@ jobs: env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} PR: ${{ github.event.pull_request.html_url }} + + - uses: ./.github/actions/slack-alert + with: + slack_channel_id: ${{ secrets.DOCS_ALERTS_SLACK_CHANNEL_ID }} + slack_token: ${{ secrets.SLACK_DOCS_BOT_TOKEN }} diff --git a/.github/workflows/site-policy-reminder.yml b/.github/workflows/site-policy-reminder.yml index 41d99b5cdb7a..3ef974fc10c2 100644 --- a/.github/workflows/site-policy-reminder.yml +++ b/.github/workflows/site-policy-reminder.yml @@ -28,3 +28,8 @@ jobs: Before merging, please remember to change the title of this PR to a description of its changes that is suitable for public viewing on github/site-policy. <@github/site-policy-admins>, when these changes are ready to be synced to the site policy repo for the 24-hour or 30-day [review window](https://github.com/github/site-policy#whats-the-process), run the [site policy sync action](https://github.com/github/docs-internal/actions/workflows/site-policy-sync.yml) from this PR's branch. When these changes are ready to be merged in `docs-internal`, let the Docs team know on Slack in #docs-content and a writer will merge this PR. + + - uses: ./.github/actions/slack-alert + with: + slack_channel_id: ${{ secrets.DOCS_ALERTS_SLACK_CHANNEL_ID }} + slack_token: ${{ secrets.SLACK_DOCS_BOT_TOKEN }} diff --git a/.github/workflows/site-policy-sync.yml b/.github/workflows/site-policy-sync.yml index 4e14b0f38f8f..a94e72a47746 100644 --- a/.github/workflows/site-policy-sync.yml +++ b/.github/workflows/site-policy-sync.yml @@ -67,3 +67,8 @@ jobs: else echo "No updates to push to the public repo" fi + + - uses: ./.github/actions/slack-alert + with: + slack_channel_id: ${{ secrets.DOCS_ALERTS_SLACK_CHANNEL_ID }} + slack_token: ${{ secrets.SLACK_DOCS_BOT_TOKEN }} diff --git a/.github/workflows/stale.yml b/.github/workflows/stale.yml index 32b94d27bf5b..3c6f38b6877b 100644 --- a/.github/workflows/stale.yml +++ b/.github/workflows/stale.yml @@ -30,3 +30,8 @@ jobs: exempt-issue-labels: 'never-stale,help wanted,waiting for review' operations-per-run: 1000 close-issue-reason: not_planned + + - uses: ./.github/actions/slack-alert + with: + slack_channel_id: ${{ secrets.DOCS_ALERTS_SLACK_CHANNEL_ID }} + slack_token: ${{ secrets.SLACK_DOCS_BOT_TOKEN }} diff --git a/.github/workflows/sync-audit-logs.yml b/.github/workflows/sync-audit-logs.yml index a413e4369a94..cf4ef2902579 100644 --- a/.github/workflows/sync-audit-logs.yml +++ b/.github/workflows/sync-audit-logs.yml @@ -109,11 +109,7 @@ jobs: gh auth login --with-token <<< "${{ secrets.DOCS_BOT_PAT_WORKFLOW_READORG }}" gh pr merge --auto --delete-branch - - name: Send Slack notification if workflow fails - uses: someimportantcompany/github-actions-slack-message@1d367080235edfa53df415bd8e0bbab480f29bad - if: ${{ failure() && env.FREEZE != 'true' }} + - uses: ./.github/actions/slack-alert with: - channel: ${{ secrets.DOCS_ALERTS_SLACK_CHANNEL_ID }} - bot-token: ${{ secrets.SLACK_DOCS_BOT_TOKEN }} - color: failure - text: The last sync-audit-logs run for ${{github.repository}} failed. See https://github.com/${{github.repository}}/actions/workflows/sync-audit-logs.yml + slack_channel_id: ${{ secrets.DOCS_ALERTS_SLACK_CHANNEL_ID }} + slack_token: ${{ secrets.SLACK_DOCS_BOT_TOKEN }} diff --git a/.github/workflows/sync-codeql-cli.yml b/.github/workflows/sync-codeql-cli.yml index bf16e73031b3..ca4a66d54670 100644 --- a/.github/workflows/sync-codeql-cli.yml +++ b/.github/workflows/sync-codeql-cli.yml @@ -122,11 +122,7 @@ jobs: --repo github/docs-internal \ --label codeql-cli-pipeline - - name: Send Slack notification if workflow fails - uses: someimportantcompany/github-actions-slack-message@1d367080235edfa53df415bd8e0bbab480f29bad - if: ${{ failure() && env.FREEZE != 'true' }} + - uses: ./.github/actions/slack-alert with: - channel: ${{ secrets.DOCS_ALERTS_SLACK_CHANNEL_ID }} - bot-token: ${{ secrets.SLACK_DOCS_BOT_TOKEN }} - color: failure - text: The last Sync CodeQL CLI run for ${{github.repository}} failed. See https://github.com/${{github.repository}}/actions/workflows/sync-codeql-cli.yml + slack_channel_id: ${{ secrets.DOCS_ALERTS_SLACK_CHANNEL_ID }} + slack_token: ${{ secrets.SLACK_DOCS_BOT_TOKEN }} diff --git a/.github/workflows/sync-graphql.yml b/.github/workflows/sync-graphql.yml index f93c589dd0e5..9e4a426cfc18 100644 --- a/.github/workflows/sync-graphql.yml +++ b/.github/workflows/sync-graphql.yml @@ -80,11 +80,8 @@ jobs: with: github-token: ${{ secrets.GITHUB_TOKEN }} number: ${{ steps.create-pull-request.outputs.pull-request-number }} - - name: Send Slack notification if workflow fails - uses: someimportantcompany/github-actions-slack-message@1d367080235edfa53df415bd8e0bbab480f29bad - if: ${{ failure() && env.FREEZE != 'true' }} + + - uses: ./.github/actions/slack-alert with: - channel: ${{ secrets.DOCS_ALERTS_SLACK_CHANNEL_ID }} - bot-token: ${{ secrets.SLACK_DOCS_BOT_TOKEN }} - color: failure - text: The last sync-graphql run for ${{github.repository}} failed. See https://github.com/${{github.repository}}/actions/workflows/sync-graphql.yml + slack_channel_id: ${{ secrets.DOCS_ALERTS_SLACK_CHANNEL_ID }} + slack_token: ${{ secrets.SLACK_DOCS_BOT_TOKEN }} diff --git a/.github/workflows/sync-openapi.yml b/.github/workflows/sync-openapi.yml index f046f430d8ec..6f3454b2d40f 100644 --- a/.github/workflows/sync-openapi.yml +++ b/.github/workflows/sync-openapi.yml @@ -117,11 +117,7 @@ jobs: --repo github/docs-internal \ --label github-openapi-bot - - name: Send Slack notification if workflow fails - uses: someimportantcompany/github-actions-slack-message@1d367080235edfa53df415bd8e0bbab480f29bad - if: ${{ failure() && env.FREEZE != 'true' }} + - uses: ./.github/actions/slack-alert with: - channel: ${{ secrets.DOCS_ALERTS_SLACK_CHANNEL_ID }} - bot-token: ${{ secrets.SLACK_DOCS_BOT_TOKEN }} - color: failure - text: The last Sync OpenAPI schema run for ${{github.repository}} failed. See https://github.com/${{github.repository}}/actions/workflows/sync-openapi.yml + slack_channel_id: ${{ secrets.DOCS_ALERTS_SLACK_CHANNEL_ID }} + slack_token: ${{ secrets.SLACK_DOCS_BOT_TOKEN }} diff --git a/.github/workflows/sync-search-elasticsearch.yml b/.github/workflows/sync-search-elasticsearch.yml index 9856c6648626..e77d42496579 100644 --- a/.github/workflows/sync-search-elasticsearch.yml +++ b/.github/workflows/sync-search-elasticsearch.yml @@ -84,6 +84,10 @@ jobs: - name: Debug output run: echo "${{ steps.set-matrix.outputs.result }}" + - uses: ./.github/actions/slack-alert + with: + slack_channel_id: ${{ secrets.DOCS_ALERTS_SLACK_CHANNEL_ID }} + slack_token: ${{ secrets.SLACK_DOCS_BOT_TOKEN }} updateElasticsearchIndexes: needs: figureOutMatrix name: Update indexes @@ -205,11 +209,7 @@ jobs: FASTLY_SURROGATE_KEY: api-search:${{ matrix.language }} run: src/workflows/purge-fastly-edge-cache.js - - name: Send Slack notification if workflow fails - uses: someimportantcompany/github-actions-slack-message@1d367080235edfa53df415bd8e0bbab480f29bad - if: failure() + - uses: ./.github/actions/slack-alert with: - channel: ${{ secrets.DOCS_ALERTS_SLACK_CHANNEL_ID }} - bot-token: ${{ secrets.SLACK_DOCS_BOT_TOKEN }} - color: failure - text: The last 'Sync search Elasticsearch' run failed. See https://github.com/${{github.repository}}/actions/workflows/sync-search-elasticsearch.yml?query=workflow%3A%22sync+search%22 + slack_channel_id: ${{ secrets.DOCS_ALERTS_SLACK_CHANNEL_ID }} + slack_token: ${{ secrets.SLACK_DOCS_BOT_TOKEN }} diff --git a/.github/workflows/sync-search-pr.yml b/.github/workflows/sync-search-pr.yml index 625757939bd9..ff1182a903c4 100644 --- a/.github/workflows/sync-search-pr.yml +++ b/.github/workflows/sync-search-pr.yml @@ -111,3 +111,8 @@ jobs: run: | curl --fail --retry-connrefused --retry 5 ${{ env.ELASTICSEARCH_URL }}/_cat/indices?v curl --fail --retry-connrefused --retry 5 ${{ env.ELASTICSEARCH_URL }}/_cat/indices?v + + - uses: ./.github/actions/slack-alert + with: + slack_channel_id: ${{ secrets.DOCS_ALERTS_SLACK_CHANNEL_ID }} + slack_token: ${{ secrets.SLACK_DOCS_BOT_TOKEN }} diff --git a/.github/workflows/test-changed-content.yml b/.github/workflows/test-changed-content.yml index f163ed551b0d..c0e48f6120db 100644 --- a/.github/workflows/test-changed-content.yml +++ b/.github/workflows/test-changed-content.yml @@ -53,3 +53,8 @@ jobs: CHANGED_FILES: ${{ steps.changed-files.outputs.modified_files }} DELETED_FILES: ${{ steps.changed-files.outputs.deleted_files }} run: npm test -- src/content-render/tests/render-changed-and-deleted-files.js + + - uses: ./.github/actions/slack-alert + with: + slack_channel_id: ${{ secrets.DOCS_ALERTS_SLACK_CHANNEL_ID }} + slack_token: ${{ secrets.SLACK_DOCS_BOT_TOKEN }} diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index d01f7c7a5707..3ef661e1b941 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -77,7 +77,7 @@ jobs: # - tools - versions - webhooks - # - workflows + - workflows # The languages suite only runs on docs-internal isPrivateRepo: @@ -194,3 +194,8 @@ jobs: else npm test -- src/${{ matrix.name }}/tests/ fi + + - uses: ./.github/actions/slack-alert + with: + slack_channel_id: ${{ secrets.DOCS_ALERTS_SLACK_CHANNEL_ID }} + slack_token: ${{ secrets.SLACK_DOCS_BOT_TOKEN }} diff --git a/.github/workflows/transfer-api-issue-to-openapi.yml b/.github/workflows/transfer-api-issue-to-openapi.yml index 1200707ec9f7..791b3e465f46 100644 --- a/.github/workflows/transfer-api-issue-to-openapi.yml +++ b/.github/workflows/transfer-api-issue-to-openapi.yml @@ -56,3 +56,8 @@ jobs: env: GITHUB_TOKEN: ${{secrets.DOCS_BOT_PAT_WORKFLOW_READORG}} OLD_ISSUE: ${{ github.event.issue.html_url }} + + - uses: ./.github/actions/slack-alert + with: + slack_channel_id: ${{ secrets.DOCS_ALERTS_SLACK_CHANNEL_ID }} + slack_token: ${{ secrets.SLACK_DOCS_BOT_TOKEN }} diff --git a/.github/workflows/translation-health-report.yml b/.github/workflows/translation-health-report.yml index 03f1ea25b13f..b7d6b7484e8f 100644 --- a/.github/workflows/translation-health-report.yml +++ b/.github/workflows/translation-health-report.yml @@ -130,12 +130,7 @@ jobs: run: | az logout - # Emit a notification for the first responder to triage if the workflow failed. - - name: Send Slack notification if workflow failed - uses: someimportantcompany/github-actions-slack-message@1d367080235edfa53df415bd8e0bbab480f29bad - if: failure() + - uses: ./.github/actions/slack-alert with: - channel: ${{ secrets.DOCS_ALERTS_SLACK_CHANNEL_ID }} - bot-token: ${{ secrets.SLACK_DOCS_BOT_TOKEN }} - color: failure - text: 'The health report for ${{ matrix.language }} failed.' + slack_channel_id: ${{ secrets.DOCS_ALERTS_SLACK_CHANNEL_ID }} + slack_token: ${{ secrets.SLACK_DOCS_BOT_TOKEN }} diff --git a/.github/workflows/triage-issue-comments.yml b/.github/workflows/triage-issue-comments.yml index ea7f5b64b635..bb1252f1ace7 100644 --- a/.github/workflows/triage-issue-comments.yml +++ b/.github/workflows/triage-issue-comments.yml @@ -46,3 +46,8 @@ jobs: with: add-labels: 'triage' ignore-if-labeled: true + + - uses: ./.github/actions/slack-alert + with: + slack_channel_id: ${{ secrets.DOCS_ALERTS_SLACK_CHANNEL_ID }} + slack_token: ${{ secrets.SLACK_DOCS_BOT_TOKEN }} diff --git a/.github/workflows/triage-issues.yml b/.github/workflows/triage-issues.yml index 8beda5f1dfe2..795e8c569be4 100644 --- a/.github/workflows/triage-issues.yml +++ b/.github/workflows/triage-issues.yml @@ -23,3 +23,8 @@ jobs: uses: andymckay/labeler@e6c4322d0397f3240f0e7e30a33b5c5df2d39e90 with: add-labels: 'triage' + + - uses: ./.github/actions/slack-alert + with: + slack_channel_id: ${{ secrets.DOCS_ALERTS_SLACK_CHANNEL_ID }} + slack_token: ${{ secrets.SLACK_DOCS_BOT_TOKEN }} diff --git a/.github/workflows/triage-pull-requests.yml b/.github/workflows/triage-pull-requests.yml index 34a02a551609..35ba257686f7 100644 --- a/.github/workflows/triage-pull-requests.yml +++ b/.github/workflows/triage-pull-requests.yml @@ -24,3 +24,8 @@ jobs: uses: andymckay/labeler@e6c4322d0397f3240f0e7e30a33b5c5df2d39e90 with: add-labels: 'triage' + + - uses: ./.github/actions/slack-alert + with: + slack_channel_id: ${{ secrets.DOCS_ALERTS_SLACK_CHANNEL_ID }} + slack_token: ${{ secrets.SLACK_DOCS_BOT_TOKEN }} diff --git a/.github/workflows/triage-stale-check.yml b/.github/workflows/triage-stale-check.yml index 9444b6ea34d0..372aef616f27 100644 --- a/.github/workflows/triage-stale-check.yml +++ b/.github/workflows/triage-stale-check.yml @@ -30,6 +30,11 @@ jobs: days-before-pr-close: 3 stale-pr-label: 'stale' exempt-pr-labels: 'waiting for review,never-stale,ready to merge' + + - uses: ./.github/actions/slack-alert + with: + slack_channel_id: ${{ secrets.DOCS_ALERTS_SLACK_CHANNEL_ID }} + slack_token: ${{ secrets.SLACK_DOCS_BOT_TOKEN }} stale_staff: if: github.repository == 'github/docs' runs-on: ubuntu-latest @@ -49,3 +54,8 @@ jobs: # we want stale-pr-label: 'waiting for review' exempt-pr-labels: 'never-stale' + + - uses: ./.github/actions/slack-alert + with: + slack_channel_id: ${{ secrets.DOCS_ALERTS_SLACK_CHANNEL_ID }} + slack_token: ${{ secrets.SLACK_DOCS_BOT_TOKEN }} diff --git a/.github/workflows/triage-unallowed-contributions.yml b/.github/workflows/triage-unallowed-contributions.yml index 40763279245b..edc4ea38eb35 100644 --- a/.github/workflows/triage-unallowed-contributions.yml +++ b/.github/workflows/triage-unallowed-contributions.yml @@ -100,3 +100,8 @@ jobs: } core.setFailed(workflowFailMessage) + + - uses: ./.github/actions/slack-alert + with: + slack_channel_id: ${{ secrets.DOCS_ALERTS_SLACK_CHANNEL_ID }} + slack_token: ${{ secrets.SLACK_DOCS_BOT_TOKEN }} diff --git a/.github/workflows/validate-asset-images.yml b/.github/workflows/validate-asset-images.yml index 53cb2b91266a..b1fe689e795f 100644 --- a/.github/workflows/validate-asset-images.yml +++ b/.github/workflows/validate-asset-images.yml @@ -24,3 +24,8 @@ jobs: - name: Validate all asset images run: src/assets/scripts/validate-asset-images.js + + - uses: ./.github/actions/slack-alert + with: + slack_channel_id: ${{ secrets.DOCS_ALERTS_SLACK_CHANNEL_ID }} + slack_token: ${{ secrets.SLACK_DOCS_BOT_TOKEN }} diff --git a/src/workflows/tests/actions-workflows.js b/src/workflows/tests/actions-workflows.js new file mode 100644 index 000000000000..54920d6b82e2 --- /dev/null +++ b/src/workflows/tests/actions-workflows.js @@ -0,0 +1,72 @@ +import { fileURLToPath } from 'url' +import path from 'path' +import fs from 'fs' +import yaml from 'js-yaml' +import { flatten } from 'flat' +import { chain, get } from 'lodash-es' + +const actionHashRegexp = /^[A-Za-z0-9-/]+@[0-9a-f]{40}$/ + +const __dirname = path.dirname(fileURLToPath(import.meta.url)) +const workflowsDir = path.join(__dirname, '../../../.github/workflows') +const workflows = fs + .readdirSync(workflowsDir) + .filter((filename) => filename.endsWith('.yml') || filename.endsWith('.yaml')) + .map((filename) => { + const fullpath = path.join(workflowsDir, filename) + const data = yaml.load(fs.readFileSync(fullpath, 'utf8'), { fullpath }) + return { filename, fullpath, data } + }) + +function actionsUsedInWorkflow(workflow) { + return Object.keys(flatten(workflow)) + .filter((key) => key.endsWith('.uses')) + .map((key) => get(workflow, key)) +} + +const allUsedActions = chain(workflows) + .map(actionsUsedInWorkflow) + .flatten() + .uniq() + .filter((use) => !use.startsWith('.')) + .sort() + .value() + +const scheduledWorkflows = workflows.filter(({ data }) => data.on.schedule) + +const dailyWorkflows = scheduledWorkflows.filter(({ data }) => + data.on.schedule.find(({ cron }) => /^20 [^*]/.test(cron)), +) + +describe('GitHub Actions workflows', () => { + test.each(allUsedActions)('requires specific hash: %p', (actionName) => { + expect(actionName).toMatch(actionHashRegexp) + }) + + test.each(scheduledWorkflows)( + 'schedule workflow runs at 20 minutes past $filename', + ({ data }) => { + for (const { cron } of data.on.schedule) { + expect(cron).toMatch(/^20/) + } + }, + ) + + test.each(dailyWorkflows)( + 'daily scheduled workflows run at 16:20 UTC / 8:20 PST $filename', + ({ data }) => { + for (const { cron } of data.on.schedule) { + const hour = cron.match(/^20 ([^*\s]+)/)[1] + expect(hour).toEqual('16') + } + }, + ) + + test.each(workflows)('workflows slack alert on fail $filename', ({ filename, data }) => { + for (const [name, job] of Object.entries(data.jobs)) { + if (!job.steps.find((step) => step.uses === './.github/actions/slack-alert')) { + throw new Error(`Job ${filename} # ${name} missing slack alert on fail`) + } + } + }) +}) diff --git a/tests/unit/actions-workflows.js b/tests/unit/actions-workflows.js deleted file mode 100644 index 2e4ccb03c0b2..000000000000 --- a/tests/unit/actions-workflows.js +++ /dev/null @@ -1,58 +0,0 @@ -import { fileURLToPath } from 'url' -import path from 'path' -import fs from 'fs' -import yaml from 'js-yaml' -import { flatten } from 'flat' -import { chain, get } from 'lodash-es' -const __dirname = path.dirname(fileURLToPath(import.meta.url)) -const workflowsDir = path.join(__dirname, '../../.github/workflows') -const workflows = fs - .readdirSync(workflowsDir) - .filter((filename) => filename.endsWith('.yml') || filename.endsWith('.yaml')) - .map((filename) => { - const fullpath = path.join(workflowsDir, filename) - const data = yaml.load(fs.readFileSync(fullpath, 'utf8'), { fullpath }) - return { filename, fullpath, data } - }) - -function actionsUsedInWorkflow(workflow) { - return Object.keys(flatten(workflow)) - .filter((key) => key.endsWith('.uses')) - .map((key) => get(workflow, key)) -} - -const scheduledWorkflows = workflows - .map((workflow) => workflow.data.on.schedule) - .filter(Boolean) - .flat() - .map((schedule) => schedule.cron) - -const allUsedActions = chain(workflows) - .map(actionsUsedInWorkflow) - .flatten() - .uniq() - .filter((use) => !use.startsWith('.')) - .sort() - .value() - -describe('GitHub Actions workflows', () => { - test('all used actions are listed', () => { - expect(allUsedActions.length).toBeGreaterThan(0) - }) - - test.each(allUsedActions)('requires specific hash: %p', (actionName) => { - const actionRegexp = /^[A-Za-z0-9-/]+@[0-9a-f]{40}$/ - expect(actionName).toMatch(actionRegexp) - }) - - test('all scheduled workflows run at 20 minutes past', () => { - const twenties = scheduledWorkflows.filter((schedule) => /^20/.test(schedule)) - expect(twenties.length).toEqual(scheduledWorkflows.length) - }) - - test('all daily and weekly workflows run at 16:20 UTC / 8:20 PST', () => { - const dailies = scheduledWorkflows.filter((schedule) => /^20 \d{2}/.test(schedule)) - const sixteens = dailies.filter((schedule) => /^20 16/.test(schedule)) - expect(sixteens.length).toEqual(dailies.length) - }) -})