Update Challenge Progress #100
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: 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 }}" |