Wrapup π¦ #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: Wrapup π¦ | |
| on: | |
| schedule: | |
| # λ§€μ£Ό μΌμμΌ μ€μ 10μ (KST κΈ°μ€, UTCλ‘λ μΌμμΌ 1μ) | |
| - cron: "0 1 * * 0" | |
| workflow_dispatch: | |
| inputs: | |
| date: | |
| description: "λ§λ¬΄λ¦¬ν μ£Όμ°¨μ μν λ μ§ (λΉμλλ©΄ μ΄μ , KST κΈ°μ€)" | |
| required: false | |
| type: string | |
| default: "" | |
| exclude_prs: | |
| description: 'PR numbers to exclude (comma-separated, e.g., "1972,1973")' | |
| required: false | |
| type: string | |
| default: "" | |
| skip_release: | |
| description: "λ¦΄λ¦¬μ¦ μμ± κ±΄λλ°κΈ°" | |
| required: false | |
| type: boolean | |
| default: false | |
| jobs: | |
| wrapup: | |
| name: Wrap Up the Week π¦ | |
| runs-on: ubuntu-latest | |
| permissions: | |
| contents: write # λ¦΄λ¦¬μ¦ μμ± | |
| steps: | |
| - name: Resolve target week | |
| id: week | |
| env: | |
| DATE_INPUT: ${{ inputs.date }} | |
| run: | | |
| date="${DATE_INPUT:-$(TZ=Asia/Seoul date -d yesterday +%F)}" | |
| echo "ποΈ λμ λ μ§: $date" | |
| response=$(curl -sS -X POST "https://github.dalestudy.com/resolve-iteration" \ | |
| -H "Content-Type: application/json" \ | |
| -d "$(jq -nc --arg date "$date" '{date: $date}')") | |
| echo "$response" | jq '.' | |
| if [ "$(echo "$response" | jq -r '.success // false')" != "true" ]; then | |
| echo "::error::μ£Όμ°¨ μ‘°νμ μ€ν¨νμ΅λλ€" | |
| exit 1 | |
| fi | |
| found=$(echo "$response" | jq -r '.found') | |
| echo "found=$found" >> $GITHUB_OUTPUT | |
| if [ "$found" != "true" ]; then | |
| { | |
| echo "## π¦ λ§λ¬΄λ¦¬ν μ£Όμ°¨κ° μμ΅λλ€" | |
| echo "" | |
| echo "\`$date\`μ΄(κ°) μ΄λ μ£Όμ°¨μλ μνμ§ μμ΅λλ€. κΈ°μ μ¬μ΄ ν΄μκΈ°μ λλ€." | |
| } >> $GITHUB_STEP_SUMMARY | |
| exit 0 | |
| fi | |
| cohort=$(echo "$response" | jq -r '.cohort') | |
| week=$(echo "$response" | jq -r '.week') | |
| { | |
| echo "week_label=$(echo "$response" | jq -r '.week_label')" | |
| echo "tag=v${cohort}.${week}.0" | |
| echo "period=$(echo "$response" | jq -r '"\(.start_date) ~ \(.end_date)"')" | |
| } >> $GITHUB_OUTPUT | |
| - name: Build exclude list | |
| id: excludes | |
| if: steps.week.outputs.found == 'true' | |
| env: | |
| EXCLUDE_PRS: ${{ inputs.exclude_prs }} | |
| run: | | |
| if [ -z "$EXCLUDE_PRS" ]; then | |
| echo "json=[]" >> $GITHUB_OUTPUT | |
| exit 0 | |
| fi | |
| if ! echo "$EXCLUDE_PRS" | grep -qE '^[0-9]+(,[0-9]+)*$'; then | |
| echo "::error::exclude_prs νμμ΄ μλͺ»λμμ΅λλ€: $EXCLUDE_PRS" | |
| exit 1 | |
| fi | |
| echo "json=[$EXCLUDE_PRS]" >> $GITHUB_OUTPUT | |
| - name: Approve PRs | |
| id: approve | |
| if: steps.week.outputs.found == 'true' | |
| env: | |
| WEEK_LABEL: ${{ steps.week.outputs.week_label }} | |
| EXCLUDES: ${{ steps.excludes.outputs.json }} | |
| REPO_NAME: ${{ github.event.repository.name }} | |
| run: | | |
| echo "π ${WEEK_LABEL} PR μΉμΈ μ€..." | |
| response=$(curl -sS -X POST "https://github.dalestudy.com/approve-prs" \ | |
| -H "Content-Type: application/json" \ | |
| -d "$(jq -nc --arg repo "$REPO_NAME" --arg week "$WEEK_LABEL" \ | |
| --argjson excludes "$EXCLUDES" \ | |
| '{repo_name: $repo, week: $week, excludes: $excludes}')") | |
| echo "$response" | jq '.' | |
| echo "response=$(echo "$response" | jq -c '.')" >> $GITHUB_OUTPUT | |
| if [ "$(echo "$response" | jq -r '.success // false')" != "true" ]; then | |
| echo "::error::μΉμΈ μμ²μ μ€ν¨νμ΅λλ€" | |
| exit 1 | |
| fi | |
| - name: Merge PRs | |
| id: merge | |
| if: steps.week.outputs.found == 'true' | |
| env: | |
| WEEK_LABEL: ${{ steps.week.outputs.week_label }} | |
| EXCLUDES: ${{ steps.excludes.outputs.json }} | |
| REPO_NAME: ${{ github.event.repository.name }} | |
| run: | | |
| echo "π ${WEEK_LABEL} PR λ³ν© μ€..." | |
| response=$(curl -sS -X POST "https://github.dalestudy.com/merge-prs" \ | |
| -H "Content-Type: application/json" \ | |
| -d "$(jq -nc --arg repo "$REPO_NAME" --arg week "$WEEK_LABEL" \ | |
| --argjson excludes "$EXCLUDES" \ | |
| '{repo_name: $repo, week: $week, merge_method: "squash", excludes: $excludes}')") | |
| echo "$response" | jq '.' | |
| echo "response=$(echo "$response" | jq -c '.')" >> $GITHUB_OUTPUT | |
| if [ "$(echo "$response" | jq -r '.success // false')" != "true" ]; then | |
| echo "::error::λ³ν© μμ²μ μ€ν¨νμ΅λλ€" | |
| exit 1 | |
| fi | |
| - name: Create release | |
| id: release | |
| if: steps.week.outputs.found == 'true' && inputs.skip_release != true | |
| env: | |
| GH_TOKEN: ${{ github.token }} | |
| REPO: ${{ github.repository }} | |
| TAG: ${{ steps.week.outputs.tag }} | |
| run: | | |
| if gh release view "$TAG" --repo "$REPO" > /dev/null 2>&1; then | |
| echo "βοΈ ${TAG} 릴리μ¦κ° μ΄λ―Έ μμ΄ κ±΄λλλλ€" | |
| exit 0 | |
| fi | |
| echo "π·οΈ ${TAG} λ¦΄λ¦¬μ¦ μμ± μ€..." | |
| gh release create "$TAG" --repo "$REPO" \ | |
| --target main --title "$TAG" --generate-notes | |
| - name: Summary | |
| if: steps.week.outputs.found == 'true' | |
| env: | |
| WEEK_LABEL: ${{ steps.week.outputs.week_label }} | |
| PERIOD: ${{ steps.week.outputs.period }} | |
| TAG: ${{ steps.week.outputs.tag }} | |
| APPROVE_RESPONSE: ${{ steps.approve.outputs.response }} | |
| MERGE_RESPONSE: ${{ steps.merge.outputs.response }} | |
| REPO: ${{ github.repository }} | |
| run: | | |
| # μλ μ²λ¦¬ λμμ΄ μλ PRμ λ―Έν΄κ²°λ‘ μΈμ§ μλλ€ | |
| normal_skip='.reason == "draft PR"' | |
| unresolved_filter=".results[]? | select(.merged != true) | select($normal_skip | not)" | |
| approved=$(echo "$APPROVE_RESPONSE" | jq -r '.approved') | |
| merged=$(echo "$MERGE_RESPONSE" | jq -r '.merged') | |
| matched=$(echo "$MERGE_RESPONSE" | jq -r '.week_matched') | |
| solving=$(echo "$MERGE_RESPONSE" | jq -r '.solving_excluded') | |
| { | |
| echo "## π¦ ${WEEK_LABEL} λ§λ¬΄λ¦¬" | |
| echo "" | |
| echo "- ποΈ κΈ°κ°: ${PERIOD}" | |
| echo "- π λμ PR: **${matched}**κ° (Solving μ μΈ ${solving}κ°)" | |
| echo "- π μΉμΈ: **${approved}**κ°" | |
| echo "- π λ³ν©: **${merged}**κ°" | |
| echo "- π·οΈ 릴리μ¦: [${TAG}](https://github.com/${REPO}/releases/tag/${TAG})" | |
| } >> $GITHUB_STEP_SUMMARY | |
| unresolved=$(echo "$MERGE_RESPONSE" | jq "[$unresolved_filter] | length") | |
| if [ "$unresolved" -gt 0 ]; then | |
| { | |
| echo "" | |
| echo "### β οΈ λ³ν©λμ§ μμ PR" | |
| echo "" | |
| echo "$MERGE_RESPONSE" | jq -r "$unresolved_filter | \"- #\(.pr) \(.title) β \(.reason // .error // \"unknown\")\"" | |
| } >> $GITHUB_STEP_SUMMARY | |
| echo "::error::λ³ν©λμ§ μμ PR ${unresolved}건 β μ§μ νμΈμ΄ νμν©λλ€" | |
| exit 1 | |
| fi |