-
Notifications
You must be signed in to change notification settings - Fork 1
130 lines (103 loc) · 4.11 KB
/
auto-weekly-issue.yml
File metadata and controls
130 lines (103 loc) · 4.11 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
127
128
129
130
name: Auto Create Weekly Issue
on:
schedule:
# 매주 월요일 오전 9시 (UTC 0시, 한국시간 9시)
- cron: '0 0 * * 1'
workflow_dispatch: # 수동 실행도 가능
jobs:
create-issue:
runs-on: ubuntu-latest
permissions:
issues: write
steps:
- name: Calculate week number and dates
id: calc
run: |
WEEK_NUM=$(date +%U)
WEEK_NUM_FORMATTED=$(printf "%02d" $((10#$WEEK_NUM + 1)))
START_DATE=$(date -d "monday" +%Y.%m.%d)
END_DATE=$(date -d "monday + 6 days" +%Y.%m.%d)
echo "week_number=$WEEK_NUM_FORMATTED" >> $GITHUB_OUTPUT
echo "start_date=$START_DATE" >> $GITHUB_OUTPUT
echo "end_date=$END_DATE" >> $GITHUB_OUTPUT
- name: Check for duplicate issue
id: check
uses: actions/github-script@v7
with:
script: |
const weekNumber = '${{ steps.calc.outputs.week_number }}';
const startDate = '${{ steps.calc.outputs.start_date }}';
const endDate = '${{ steps.calc.outputs.end_date }}';
const expectedTitle = `[Week${weekNumber}] ${startDate} ~ ${endDate} 주차 문제`;
// 열려있는 이슈 중에서 같은 제목이 있는지 확인
const { data: issues } = await github.rest.issues.listForRepo({
owner: context.repo.owner,
repo: context.repo.repo,
state: 'all',
labels: 'weekly-challenge'
});
const duplicate = issues.find(issue => issue.title === expectedTitle);
if (duplicate) {
console.log(`⚠️ Issue already exists: ${duplicate.html_url}`);
core.setOutput('should_create', 'false');
} else {
console.log(`✅ No duplicate found. Proceeding to create issue.`);
core.setOutput('should_create', 'true');
}
- name: Create weekly issue
if: steps.check.outputs.should_create == 'true'
uses: actions/github-script@v7
with:
script: |
const weekNumber = '${{ steps.calc.outputs.week_number }}';
const startDate = '${{ steps.calc.outputs.start_date }}';
const endDate = '${{ steps.calc.outputs.end_date }}';
const issueBody = `## Week ${weekNumber} (${startDate} ~ ${endDate})
이번 주 공통 문제입니다! 💪
### 📝 문제 목록
#### 문제 1
- **플랫폼**: 백준 / 프로그래머스 / 리트코드
- **문제 번호**:
- **문제 이름**:
- **난이도**:
- **링크**:
#### 문제 2
- **플랫폼**:
- **문제 번호**:
- **문제 이름**:
- **난이도**:
- **링크**:
#### 문제 3
- **플랫폼**:
- **문제 번호**:
- **문제 이름**:
- **난이도**:
- **링크**:
---
### ✅ 진행 상황
- [ ] @sukangpunch
- [ ] @Hexeong
- [ ] @whqtker
- [ ] @JAEHEE25
- [ ] @Gyuhyeok99
---
### 💡 참고사항
문제 풀이는 \`weekly/week${weekNumber}/\` 디렉토리에 업로드해주세요!
\`\`\`bash
weekly/week${weekNumber}/
├── BOJ_1234_문제명/
│ ├── sukangpunch.py
│ └── Hexeong.java
└── PGS_5678_문제명/
└── whqtker.cpp
\`\`\`
> ⚠️ **문제 정보를 채워주세요!** 이슈 생성 후 문제 정보를 편집해서 추가해주세요.
`;
await github.rest.issues.create({
owner: context.repo.owner,
repo: context.repo.repo,
title: `[Week${weekNumber}] ${startDate} ~ ${endDate} 주차 문제`,
body: issueBody,
labels: ['weekly-challenge']
});
console.log(`✅ Week ${weekNumber} issue created!`);