-
Notifications
You must be signed in to change notification settings - Fork 5
114 lines (101 loc) ยท 3.91 KB
/
update_challenge_progress.yml
File metadata and controls
114 lines (101 loc) ยท 3.91 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
name: Update Challenge Progress
on:
pull_request:
types:
- closed
jobs:
update_progress:
if: github.event.pull_request.merged == true
runs-on: ubuntu-latest
steps:
- name: Checkout Repository
uses: actions/checkout@v3
with:
ref: main
fetch-depth: 0
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: '3.x'
- name: Configure Github User & Sync with main branch
run: |
git config --global user.name "${{ secrets.GIT_USER_NAME }}"
git config --global user.email "${{ secrets.GIT_USER_EMAIL }}"
git pull origin main --rebase
- name: Run extract_pr_data.py
working-directory: _MonthlyChallenges
run: python extract_pr_data.py
- name: Run update_scoreboard.py
working-directory: _MonthlyChallenges
run: python update_scoreboard.py
- name: Run update_dashboard.py
working-directory: _MonthlyChallenges
run: python update_dashboard.py
git push https://x-access-token:${{ secrets.PERSONAL_ACCESS_TOKEN }}@github.com/AlgorithmStudy-Allumbus/codingtest_algorithm_study.git ${{ github.head_ref }}
- name: Commit updated files
run: |
cd _MonthlyChallenges
git add scoreboard.json DASHBOARD.md HISTORY.md
git commit -m "Update challenge progress dashboard" || echo "No changes to commit"
git push origin main
- name: Post PR Comment with progress
if: github.event_name == 'pull_request'
uses: actions/github-script@v6
with:
script: |
const fs = require('fs');
// DASHBOARD.md ํ์ผ์์ ๋ด์ฉ ์ฝ์ด์ค๊ธฐ (working-directory์ ๋ฐ๋ผ ๊ฒฝ๋ก ์กฐ์ )
const dashboard = fs.readFileSync('_MonthlyChallenges/DASHBOARD.md', 'utf8');
// PR ์ด๋ฒคํธ์์ PR ๋ฒํธ ๊ฐ์ ธ์ค๊ธฐ
const prNumber = context.payload.pull_request.number;
// GitHub REST API๋ฅผ ํตํด ์ฝ๋ฉํธ ์์ฑ
github.rest.issues.createComment({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: prNumber,
body: dashboard
});
notify_discord:
needs: update_progress
runs-on: ubuntu-latest
steps:
- name: Checkout Repository
uses: actions/checkout@v3
with:
fetch-depth: 0
ref: main
- name: Send Dashboard to Discord
working-directory: _MonthlyChallenges
run: |
# DASHBOARD.md ํ์ผ์ ์์ ํ๊ฒ JSON ๋ฌธ์์ด๋ก ์ด์ค์ผ์ดํ
DASHBOARD_CONTENT=$(jq -R -s '.' DASHBOARD.md)
echo "Dashboard content: $DASHBOARD_CONTENT"
# Discord ์๋ฒ ๋ ๋ฉ์์ง JSON ์์ฑ
EMBED_JSON=$(cat <<EOF
{
"content": "",
"embeds": [
{
"author": {
"name": "Allumbus๐ฅ",
"url": "https://github.com/AlgorithmStudy-Allumbus",
"icon_url": "https://imgur.com/kKJg6v3.jpg"
},
"title": "**๐ ์ฑ๋ฆฐ์ง ์งํ ์ํฉ**",
"url": "https://github.com/AlgorithmStudy-Allumbus/codingtest_algorithm_study/blob/main/_MonthlyChallenges/DASHBOARD.md",
"description": ${DASHBOARD_CONTENT},
"color": 15258703,
"footer": {
"text": "Updated on $(date '+%Y-%m-%d %H:%M:%S')"
}
}
]
}
EOF
)
echo "Embed JSON: $EMBED_JSON"
# Discord ์นํ
ํธ์ถ (๋๋ฒ๊ทธ๋ฅผ ์ํด -v ์ต์
์ฌ์ฉ)
curl -v -H "Content-Type: application/json" \
-X POST \
-d "$EMBED_JSON" \
"${{ secrets.DISCORD_WEBHOOK_URL }}"