ํ์ ์ ํ๋ฉด์ ๋ฌธ์ํ๋ฅผ ์ํด GitHub Discussions๋ฅผ ์ฌ์ฉํ๊ธฐ๋ก ํ๋ค.
๊ธฐ์กด์๋ notion์ ์ฃผ๋ก ์ฌ์ฉํ์ง๋ง,
GitHub์ ์ด๋ฏธ organization์ด ์กด์ฌํ๋ ์ํฉ์์ ํ๋ซํผ์ ํ๋๋ ๋๋ฆฌ๊ธฐ ๋ณด๋ค๋ ํต์ผํ๋ ๊ฒ์ด ์ข๋ค๋ ํ๋จ์ด์๋ค.
Slack์ ์๋ GitHub ์ฑ์์ ๊ฐ๋จํ ๋ช ๋ น์ด ํ ์ค์ด๋ฉด `issues`, `pulls`, `commit`๋ฑ์ ์๋ฆผ์ ๋ฐ์ ์ ์์ง๋ง,
Discussions์ ์ ๊ธ์ด ์ฌ๋ผ์์ ๋ ์๋ฆผ์ ๋ฐ์ ์ ์๋ ๋ช ๋ น์ด๋ ์๋ค. ๐ญ
์์๋ณด๋ GitHub Actions์ Web Hook์ ์ฌ์ฉํ์ฌ Slack๊ณผ ์ฐ๋ํ ์ ์๋ค๊ณ ํ์ฌ ์ง์ ํด๋ณด๋ ค๊ณ ํ๋ค!
1. GitHub Actions ์ํฌํ๋ก์ฐ ์ค์
1) GitHub ๋ ํฌ์งํ ๋ฆฌ์์ `.github/workflows` ๋๋ ํ ๋ฆฌ ํ์์ `discussioins-notification.yml`๊ณผ ๊ฐ์ ์ด๋ฆ์ YAML ํ์ผ์ ์์ฑํ๋ค.
2) ์๋์ ๊ฐ์ด GitHub Actions ์ํฌํ๋ก์ฐ๋ฅผ ์ค์ ํ๋ค.
name: GitHub Discussions Notification
on:
discussion:
types: [created]
discussion_comment:
types: [created]
jobs:
notify_slack:
runs-on: ubuntu-latest
steps:
- name: Check out code
uses: actions/checkout@v2
- name: Send notification to Slack
env:
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }}
run: |
MESSAGE="A new discussion has been created: ${{ github.event.discussion.html_url }}"
curl -X POST -H 'Content-type: application/json' --data "{'text':'$MESSAGE'}" $SLACK_WEBHOOK_URL
์์์๋ ์๋ก์ด ํ ๋ก ์ด ์์ฑ๋์์ ๋์ ๋๊ธ์ด ๋ฌ๋ ธ์ ๋ ์๋ฆผ์ด ์ค๋๋ก ํ๋ค.
๋ค์ํ event trigger์ types๋ฅผ ํ์ธํ๋ ค๋ฉด ์๋ ๊ณต์ ๋ฌธ์๋ฅผ ์ฐธ๊ณ ํ์.
https://docs.github.com/en/actions/using-workflows/events-that-trigger-workflows#discussion
Events that trigger workflows - GitHub Docs
You can configure your workflows to run when specific activity on GitHub happens, at a scheduled time, or when an event outside of GitHub occurs.
docs.github.com
2. Slack Incomming Webhooks ์ค์
1) Slack ์ฑ ๋๋ ํ ๋ฆฌ์์ `incoming`์ผ๋ก ๊ฒ์ํ์ฌ ์๋ "Incoming WebHooks`๋ฅผ ์ค์นํ๋ค.
2) Incomming Webhook์ ์์ฑํ ํ, Webhook URL์ ๋ณต์ฌํด๋๋ค.
(์ด URL์ GitHub Actions์์ Slack์ ์๋ฆผ์ ๋ณด๋ด๋๋ฐ ์ฌ์ฉ๋๋ค.)
3. GitHub Secrets ์ค์
1) GitHub ์ ์ฅ์์ Settings > Secrets and variables > Actions ์น์ ์ผ๋ก ์ด๋ํ์ฌ `New Repository Secret`์ ํด๋ฆญํ๋ค.
2) Name์ `SLACK_WEBHOOK_URL`๋ก ์ค์ ํ๊ณ , Secret์๋ ์ด์ ์ ๋ณต์ฌํด๋ Slck Incoming Webhook URL์ ๋ถ์ฌ๋ฃ๋๋ค.
(์ด Secret์ GitHub Actions ์ํฌํ๋ก์ฐ์์ ์ฌ์ฉ๋๋ค.)
์๋ฃ
์ด์ ์๋ก์ด GitHub Discussions ๊ธ์ด ๋ฑ๋ก๋๊ฑฐ๋ ๋๊ธ์ด ๋ฌ๋ ธ์ ๋ Slack์ผ๋ก ์๋ฆผ์ ๋ฐ์๋ณผ ์ ์๋ค! ๐
์ฐธ๊ณ ์๋ฃ
[Git] Github Action Workflow ์์ฑ๋ฒ