Merge pull request #59 from Jsumin07/feat/baekjoon #65
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: Notify Slack on Push to main | |
| on: | |
| push: | |
| branches: [main] | |
| jobs: | |
| notify: | |
| runs-on: ubuntu-latest | |
| env: | |
| TZ: Asia/Seoul | |
| steps: | |
| - name: Get KST time | |
| run: echo "KST_NOW=$(date '+%Y-%m-%d %H:%M KST')" >> "$GITHUB_ENV" | |
| - name: Build payload (single commit summary) | |
| id: payload | |
| uses: actions/github-script@v7 | |
| env: | |
| KST_NOW: ${{ env.KST_NOW }} | |
| with: | |
| script: | | |
| const commit = (context.payload.commits || [])[0]; | |
| const msg = commit ? commit.message.split('\n')[0] : '— (no commit) —'; | |
| const text = | |
| `main 브랜치 업데이트\n` + | |
| `푸시한 유저: ${context.actor}\n` + | |
| `시간(KST): ${process.env.KST_NOW}\n` + | |
| `커밋 요약:\n` + | |
| `• ${msg}`; | |
| core.setOutput('json', JSON.stringify({ text })); | |
| - name: Post to Slack | |
| uses: slackapi/[email protected] | |
| with: | |
| payload: ${{ steps.payload.outputs.json }} | |
| env: | |
| SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }} | |
| SLACK_WEBHOOK_TYPE: INCOMING_WEBHOOK |