-
Notifications
You must be signed in to change notification settings - Fork 0
126 lines (111 loc) · 4.41 KB
/
update_challenge_progress.yml
File metadata and controls
126 lines (111 loc) · 4.41 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
115
116
117
118
119
120
121
122
123
124
125
126
name: Update Challenge Progress
on:
pull_request:
types:
- closed
workflow_dispatch:
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"
- name: Create Pull Request
uses: peter-evans/create-pull-request@v5
with:
commit-message: "Update challenge progress dashboard"
title: "자동 PR: 챌린지 진행 상황 갱신"
body: |
This pull request was automatically generated by the workflow.
branch: auto/update-dashboard
base: main
token: ${{ secrets.PERSONAL_ACCESS_TOKEN }}
- 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 }}"