Skip to content

Update Challenge Progress #102

Update Challenge Progress

Update Challenge Progress #102

name: Update Challenge Progress
on:
pull_request:
types:
- closed
push:
branches:
- main
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 }}"