Health Check #34873
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Health Check | |
| on: | |
| repository_dispatch: | |
| workflow_dispatch: | |
| schedule: | |
| # Every 5 minutes | |
| - cron: '*/5 * * * *' | |
| permissions: {} | |
| env: | |
| health_check_file: health_check.json | |
| health_check_blocks_file: health_check_blocks.json | |
| concurrency: | |
| group: ${{ github.workflow }}-${{ github.event_name }}-${{ github.ref }} | |
| cancel-in-progress: true | |
| jobs: | |
| context: | |
| runs-on: ubuntu-latest | |
| outputs: | |
| is_fork: ${{ steps.context.outputs.is_fork }} | |
| steps: | |
| - name: Context | |
| id: context | |
| uses: mozilla/addons/.github/actions/context@f748fdc2c8057ad7b574521a60c182939f2ee687 | |
| health_check: | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| environment: | |
| - dev | |
| - stage | |
| - prod | |
| uses: ./.github/workflows/_health_check.yml | |
| secrets: | |
| SLACK_TOKEN: ${{ secrets.SLACK_TOKEN }} | |
| with: | |
| environment: ${{ matrix.environment }} | |
| notify: ${{ github.event_name == 'schedule' }} | |
| slack_channel: ${{ vars.SLACK_ADDONS_PRODUCTION_CHANNEL }} | |
| post_health_check: | |
| if: always() | |
| needs: [context, health_check] | |
| runs-on: ubuntu-latest | |
| permissions: | |
| actions: write | |
| steps: | |
| - uses: actions/checkout@v5 | |
| with: | |
| persist-credentials: false | |
| - name: Retry Health Check | |
| if: needs.health_check.result == 'failure' | |
| shell: bash | |
| env: | |
| GH_TOKEN: ${{ github.token }} | |
| ref: ${{ github.ref }} | |
| run: | | |
| sleep 10 | |
| gh workflow run health_check.yml --ref "${ref}" | |
| - name: Notify Recovery | |
| uses: mozilla/addons/.github/actions/slack@f748fdc2c8057ad7b574521a60c182939f2ee687 | |
| with: | |
| slack_token: ${{ secrets.SLACK_TOKEN }} | |
| payload: | | |
| { | |
| "channel": "${{ vars.SLACK_ADDONS_PRODUCTION_CHANNEL }}", | |
| "text": ":white_check_mark: Health check has recovered", | |
| } | |
| dry_run: ${{ !(needs.health_check.result == 'success' && github.event_name == 'workflow_dispatch') }} | |
| - name: Notify Failure | |
| uses: mozilla/addons/.github/actions/slack-workflow-notification@f748fdc2c8057ad7b574521a60c182939f2ee687 | |
| with: | |
| slack_token: ${{ secrets.SLACK_TOKEN }} | |
| slack_channel: ${{ vars.SLACK_ADDONS_PRODUCTION_CHANNEL }} | |
| conclusion: "failure" | |
| text: ${{ github.ref }} | |
| text_link: ${{ github.event.repository.html_url }} | |
| context: | | |
| { | |
| "channel": "${{ vars.SLACK_ADDONS_PRODUCTION_CHANNEL }}", | |
| "text": ":x: Health check has failed" | |
| } | |
| links: | | |
| { | |
| "${{ github.run_id }}": "${{ format('{0}/{1}/actions/runs/{2}', github.server_url, github.repository, github.run_id) }}", | |
| "${{ github.repository }}": "${{ github.server_url }}/${{ github.repository }}" | |
| } | |
| dry_run: ${{ !(github.event_name == 'schedule' && needs.health_check.result == 'failure') }} | |