Auto Create Weekly Issue #1
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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: | | |
| # 현재 날짜 기준 주차 계산 (1월 1일 기준) | |
| WEEK_NUM=$(date +%U) | |
| # 주차를 2자리로 포맷 (01, 02, ...) | |
| WEEK_NUM_FORMATTED=$(printf "%02d" $((WEEK_NUM + 1))) | |
| # 이번 주 월요일과 일요일 계산 | |
| START_DATE=$(date -d "monday" +%Y.%m.%d) | |
| END_DATE=$(date -d "sunday" +%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}`); | |
| return 'skip'; | |
| } else { | |
| console.log(`✅ No duplicate found. Proceeding to create issue.`); | |
| return 'create'; | |
| } | |
| - name: Create weekly issue | |
| if: steps.check.outputs.result == 'create' | |
| 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!`); |