3. ๊ฐ๋จํ ์ํฌํ๋ก์ฐ ๋ง๋ค๊ธฐ
ํค์๋ ๊ธฐ๋ฐ ์ด์ ์๋ฆผ ์๋ํ ๋ง๋ค๊ธฐ
- ์ด์๊ฐ ์์ฑ๋ ๋ ์คํ
- issue event
- types: [opened]
- ํน์ ํค์๋๊ฐ ํฌํจ๋๋ฉด ์ฌ๋์ผ๋ก ๊ณต์ ํ๊ธฐ
- if critical -> ์ฌ๋์ critical-issue ์ฑ๋๋ก ๊ณต์
- if cormal -> ์ฌ๋์ normal-issue ์ฑ๋๋ก ๊ณต์
- ํค์๋๋ ๋ณ๋์ฌํญ์ด ์๊ธธ ์ ์์
๋ณต์ก์ฑ์ ์ค์ด๋ ๋ฐฉ๋ฒ
- ํค์๋ ๊ด๋ฆฌํ๊ธฐ
- (X) ๊นํ์ก์ ์ํฌํ๋ก์ฐ์์ ๊ด๋ฆฌ
- (O) ์ธ๋ถ์์ ํค์๋ ๊ด๋ฆฌ ex) keyword.txt
- slack step ์ฌ์ฉ ๊ตฌ์กฐ
- ํค์๋๋งํผ ์ฌ์ฉํ๋ฉด ๊ด๋ฆฌ๊ฐ ์ด๋ ค์
- slack step 1๊ฐ๋ก ์ฌ์ฉํ๊ธฐ
- ๋์ผํ ์ฌ๋ ์นํ
์ด๋ฆ ์ฌ์ฉํ๊ธฐ
- ๋์ผํ ์ํฌ๋ฆฟ ์ด๋ฆ ์ฌ์ฉํ๊ธฐ
- ${{ secret.SLACK_WEBHOOK }}
- ๊ตฌ์ฑ
- job 2๊ฐ ์ฌ์ฉํ๊ธฐ
- job-1 : get keyword (keyword-list.txt ์ฌ์ฉ. ์ด๋ฅ ์ ๋ชฉ์ด ํค์๋ ๋ฆฌ์คํธ์ ์๋ค๋ฉด ๊ทธ ๊ฐ์ ์์ํ์ผ๋ก ๊ตฌ์ฑ)
- job-2 : slack (get keyword์ ์์ํ์ ๋ฐ์์ environment๋ก ์ฌ์ฉ)
- job 2๊ฐ ์ฌ์ฉํ๊ธฐ
- ์ด์์ ๋ํ Environment๋ง๋ค๊ธฐ
- ๊ฐ Envieonmment ์์ secret ๋ง๋ค๊ธฐ
- ์ด์ ์ฑ๋์ ํค์๋ - ์ฌ๋ ํด๋น ์ฑ๋ url ๋ก secret๋ง๋ค๊ธฐ
name: issue-notify
on:
issues:
types: [opened]
jobs:
get-keyword:
runs-on: ubuntu-latest
outputs:
level: ${{ steps.get-keyword.outputs.level }}
steps:
- name: checkout
uses: actions/checkout@v4
- name: get keyword
id: get-keyword
run: |
echo level=Undefined >> $GITHUB_OUTPUT
keywords=$(cat keyword-list.txt)
for keyword in $keywords; do
if [[ "${{ github.event.issue.title }}" =~ "$keyword" ]]; then
echo level=$keyword >> $GITHUB_OUTPUT
fi
done
- name: get output
run: |
echo ${{ steps.get-keyword.outputs.level }}
slack:
needs: [get-keyword]
if: needs.get-keyword.outputs.level != 'Undefined'
runs-on: ubuntu-latest
# environment: ${{ needs.get-keyword.outputs.level }}
strategy:
matrix: # ๋งคํธ๋ฆญ์ค๋ฅผ ์ฌ์ฉํ๋ฉด ์๊ฐ์ ์ผ๋ก ์ด๋ค ํ๊ฒฝ์ ์ฌ์ฉํ๋์ง ํ์
ํ ์ ์์
environment: ["${{ needs.get-keyword.outputs.level }}"]
environment: ${{ matrix.environment }}
steps:
- name: slack
uses: slackapi/slack-github-action@v1.24.0
with:
payload: |
{
"attachments": [
{
"pretext": "issue alert message",
"color": "28a745",
"fields": [
{
"title": "Level : ${{ needs.get-keyword.outputs.level }}",
"short": true,
"value": "issue url : ${{ github.event.issue.html_url }}"
}
]
}
]
}
env:
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }}
SLACK_WEBHOOK_TYPE: INCOMING_WEBHOOK
'๐ฅ๏ธ ๋ฐฑ์๋ > CICD' ์นดํ ๊ณ ๋ฆฌ์ ๋ค๋ฅธ ๊ธ
[CICD] ๊ธฐ์ด ์๋๋ฆฌ์ค ๊นํ ์ก์ (0) | 2024.03.23 |
---|---|
[CICD] ๊นํ ๋ ํฌ ์์ฑ ์๋ํ (0) | 2024.03.23 |
[CICD] Github Actions์ ๋ค์ํ ๊ธฐ๋ฅ (0) | 2024.03.22 |
[CICD] Github Actions์ event (0) | 2024.03.21 |
[CICD] ๊นํ๋ธ ์ก์ ์ปดํฌ๋ํธ (0) | 2024.03.21 |