|
73 | 73 | - name: Deploy to GitHub Pages |
74 | 74 | id: deployment |
75 | 75 | uses: actions/deploy-pages@v4 |
| 76 | + |
| 77 | + notify: |
| 78 | + needs: [build-and-deploy] |
| 79 | + if: always() |
| 80 | + runs-on: ubuntu-latest |
| 81 | + steps: |
| 82 | + - name: Checkout |
| 83 | + uses: actions/checkout@v4 |
| 84 | + |
| 85 | + - name: Resolve actor name |
| 86 | + id: resolve_actor |
| 87 | + uses: actions/github-script@v7 |
| 88 | + with: |
| 89 | + script: | |
| 90 | + const fs = require('fs'); |
| 91 | + const developers = JSON.parse(fs.readFileSync(`${{ github.workspace }}/.github/workflows/reviewer.json`)); |
| 92 | + const matched = developers.reviewers.find(p => p.githubName === '${{ github.actor }}'); |
| 93 | + core.setOutput('actorName', JSON.stringify(matched?.name ?? '${{ github.actor }}')); |
| 94 | +
|
| 95 | + - name: Send Slack Notification |
| 96 | + run: | |
| 97 | + STATUS="${{ needs.build-and-deploy.result }}" |
| 98 | + ENVIRONMENT=$([[ "${{ github.ref_name }}" == "main" ]] && echo "Production" || echo "Stage") |
| 99 | + COMMIT_MSG=$(echo "${{ github.event.head_commit.message }}" | head -1) |
| 100 | + RUN_URL="${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}" |
| 101 | + ACTOR=${{ steps.resolve_actor.outputs.actorName }} |
| 102 | +
|
| 103 | + BODY=$(jq -n \ |
| 104 | + --arg status "$STATUS" \ |
| 105 | + --arg environment "$ENVIRONMENT" \ |
| 106 | + --arg repository "${{ github.repository }}" \ |
| 107 | + --arg branch "${{ github.ref_name }}" \ |
| 108 | + --arg actor "$ACTOR" \ |
| 109 | + --arg commitMessage "$COMMIT_MSG" \ |
| 110 | + --arg runUrl "$RUN_URL" \ |
| 111 | + '{status: $status, environment: $environment, repository: $repository, branch: $branch, actor: $actor, commitMessage: $commitMessage, runUrl: $runUrl}') |
| 112 | +
|
| 113 | + curl -X POST https://api-slack.internal.bcsdlab.com/api/deploy/frontend \ |
| 114 | + -H 'Content-Type: application/json' \ |
| 115 | + -d "$BODY" |
0 commit comments