|
| 1 | +name: Update Challenge Progress |
| 2 | + |
| 3 | +on: |
| 4 | + pull_request: |
| 5 | + types: [opened, edited, reopened] |
| 6 | + |
| 7 | +jobs: |
| 8 | + update_progress: |
| 9 | + runs-on: ubuntu-latest |
| 10 | + steps: |
| 11 | + - name: Checkout Repository |
| 12 | + uses: actions/checkout@v3 |
| 13 | + with: |
| 14 | + ref: ${{ github.head_ref }} |
| 15 | + fetch-depth: 0 |
| 16 | + |
| 17 | + - name: Set up Python |
| 18 | + uses: actions/setup-python@v4 |
| 19 | + with: |
| 20 | + python-version: '3.x' |
| 21 | + |
| 22 | + - name: Run extract_pr_data.py |
| 23 | + working-directory: _MonthlyChallenges |
| 24 | + run: python extract_pr_data.py |
| 25 | + |
| 26 | + - name: Run update_scoreboard.py |
| 27 | + working-directory: _MonthlyChallenges |
| 28 | + run: python update_scoreboard.py |
| 29 | + |
| 30 | + - name: Run update_dashboard.py |
| 31 | + working-directory: _MonthlyChallenges |
| 32 | + run: python update_dashboard.py |
| 33 | + |
| 34 | + - name: Commit updated files |
| 35 | + working-directory: _MonthlyChallenges |
| 36 | + run: | |
| 37 | + git config --global user.name "${{ secrets.GIT_USER_NAME }}" |
| 38 | + git config --global user.email "${{ secrets.GIT_USER_EMAIL }}" |
| 39 | + git add scoreboard.json DASHBOARD.md HISTORY.md |
| 40 | + git commit -m "Update challenge progress dashboard" || echo "No changes to commit" |
| 41 | + git push origin ${{ github.head_ref }} |
| 42 | +
|
| 43 | + - name: Post PR Comment with progress |
| 44 | + if: github.event_name == 'pull_request' |
| 45 | + uses: actions/github-script@v6 |
| 46 | + with: |
| 47 | + script: | |
| 48 | + const fs = require('fs'); |
| 49 | + // DASHBOARD.md 파일에서 내용 읽어오기 (working-directory에 따라 경로 조정) |
| 50 | + const dashboard = fs.readFileSync('_MonthlyChallenges/DASHBOARD.md', 'utf8'); |
| 51 | + // PR 이벤트에서 PR 번호 가져오기 |
| 52 | + const prNumber = context.payload.pull_request.number; |
| 53 | + // GitHub REST API를 통해 코멘트 생성 |
| 54 | + github.rest.issues.createComment({ |
| 55 | + owner: context.repo.owner, |
| 56 | + repo: context.repo.repo, |
| 57 | + issue_number: prNumber, |
| 58 | + body: dashboard |
| 59 | + }); |
0 commit comments