Skip to content

Commit 1c12dbf

Browse files
committed
chore: 슬랙 배포 알림 추가
1 parent de6746d commit 1c12dbf

1 file changed

Lines changed: 40 additions & 0 deletions

File tree

.github/workflows/nextjs.yml

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,3 +73,43 @@ jobs:
7373
- name: Deploy to GitHub Pages
7474
id: deployment
7575
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

Comments
 (0)