ci: Add slack notification to the release pipeline #274
Workflow file for this run
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: Tests | |
| on: | |
| push: | |
| branches: | |
| - main | |
| pull_request: | |
| jobs: | |
| unit-tests: | |
| name: Unit tests | |
| runs-on: ubuntu-latest | |
| strategy: | |
| matrix: | |
| node-version: [24.x] | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0 | |
| with: | |
| fetch-depth: 0 | |
| - name: Use Node.js ${{ matrix.node-version }} | |
| uses: actions/setup-node@48b55a011bda9f5d6aeb4c2d9c7362e8dae4041e # v6.4.0 | |
| - name: Install Dependencies | |
| run: npm ci | |
| - name: Lint | |
| run: npm run lint | |
| - name: Unit tests | |
| run: npm run test | |
| notify-slack: | |
| name: Notify on failure | |
| needs: | |
| - unit-tests | |
| if: failure() | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Notify Slack | |
| uses: FlowFuse/github-actions-workflows/actions/slack_notification@slack_notification/v1 | |
| with: | |
| bot-token: ${{ secrets.SLACK_GHBOT_TOKEN }} | |
| mode: ${{ github.event_name == 'pull_request' && 'author' || 'channel' }} | |
| mention-actor: ${{ github.event_name != 'pull_request' }} | |
| blocks: | | |
| [ | |
| { "type": "header", "text": { "type": "plain_text", "text": ":x: ${{ github.event_name == 'pull_request' && format('Tests failed against #{0} pull request', github.event.pull_request.number) || format('Tests failed against {0} branch', github.ref_name) }}", "emoji": true } }, | |
| { "type": "divider" }, | |
| { "type": "rich_text", "elements": [ { "type": "rich_text_section", "elements": [ | |
| { "type": "emoji", "name": "${{ github.event_name == 'pull_request' && 'warning' || 'no_entry' }}" }, | |
| { "type": "text", "text": "${{ github.event_name == 'pull_request' && ' Please resolve the problem before merging your changes into the main branch.' || ' Deployment to FFC environments will not happen until this issue is resolved.' }}", "style": { "bold": true } } | |
| ] } ] }, | |
| { "type": "divider" }, | |
| { "type": "section", "fields": [ | |
| { "type": "mrkdwn", "text": "*Author:* ${{ github.event_name == 'pull_request' && github.actor || '{{MENTION}}' }}" }, | |
| { "type": "mrkdwn", "text": "<${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}|View failed workflow>" }, | |
| { "type": "mrkdwn", "text": "${{ format('*Last commit:* <{0}/{1}/commit/{2}|{2}>', github.server_url, github.repository, github.event_name == 'pull_request' && github.event.pull_request.head.sha || github.sha) }}" }, | |
| { "type": "mrkdwn", "text": "${{ github.event_name == 'pull_request' && format('*Pull request:* <{0}/{1}/pull/{2}|{2}>', github.server_url, github.repository, github.event.pull_request.number) || format('*Branch:* {0}', github.ref_name) }}" } | |
| ] } | |
| ] |