diff --git a/.github/workflows/AutoAssign.yml b/.github/workflows/AutoAssign.yml new file mode 100644 index 000000000..dd580a85b --- /dev/null +++ b/.github/workflows/AutoAssign.yml @@ -0,0 +1,40 @@ +name: Auto assign PR author + +on: + pull_request: + types: + - opened + - reopened + +jobs: + assign-pr-author: + runs-on: ubuntu-latest + + steps: + - name: Checkout repository + uses: actions/checkout@v3 + + - name: Get PR author + id: get-pr-author + run: echo "author=${{ github.event.pull_request.user.login }}" >> $GITHUB_OUTPUT + + - name: Assign PR author + run: gh pr edit ${{ github.event.number }} --add-assignee ${{ steps.get-pr-author.outputs.author }} + env: + GH_TOKEN: ${{ github.token }} + + - name: Comment success result to PR + uses: mshick/add-pr-comment@v2 + if: ${{ success() }} + with: + message: | + ## ✅ Assign 자동 지정을 성공했어요! + @${{ steps.get-pr-author.outputs.author }} + allow-repeats: true + + - name: Comment failure result to PR + uses: mshick/add-pr-comment@v2 + if: ${{ failure() }} + with: + message: "## ❌ PR의 Assign 자동 지정을 실패했어요." + allow-repeats: true diff --git a/.github/workflows/IssueToPRLabelSync.yml b/.github/workflows/IssueToPRLabelSync.yml new file mode 100644 index 000000000..d93b50461 --- /dev/null +++ b/.github/workflows/IssueToPRLabelSync.yml @@ -0,0 +1,55 @@ +name: Issue to PR label sync + +on: + pull_request: + types: + - opened + - reopened + +jobs: + add-label: + runs-on: ubuntu-latest + + steps: + - name: Checkout repository + uses: actions/checkout@v3 + + - name: Extract issue number from PR title + id: extract-issue-number + run: | + sh .github/workflows/IssueToPRLabelSync/ExtractIssueNumber.sh >> $GITHUB_OUTPUT + env: + PR_TITLE: ${{ github.event.pull_request.title }} + + - name: Check if issue number is found + id: check-issue-number + run: echo "valid_format=$(if [[ -n "${{ steps.extract-issue-number.outputs.issue_number }}" ]]; then echo "true"; else echo "false"; fi)" >> $GITHUB_OUTPUT + + - name: Add label if valid issue format + if: steps.check-issue-number.outputs.valid_format == 'true' + run: | + ISSUE_NUMBER="${{ steps.extract-issue-number.outputs.issue_number }}" + echo "Found Issue Number: $ISSUE_NUMBER" + gh issue view $ISSUE_NUMBER --json labels --template "{{range .labels}}'{{.name}}',{{end}}" \ + | sed 's/.$//g' \ + | xargs -I LABELS gh pr edit ${{ github.event.number }} --add-label "LABELS" + env: + GH_TOKEN: ${{ github.token }} + + - name: Skip if invalid issue format + if: steps.check-issue-number.outputs.valid_format == 'false' + run: echo "Invalid issue format. Skipping label addition." + + - name: Comment success result to PR + uses: mshick/add-pr-comment@v2 + if: steps.check-issue-number.outputs.valid_format == 'true' + with: + message: "## ✅ 이슈와 PR의 Labels 동기화를 성공했어요!" + allow-repeats: true + + - name: Comment skip result to PR + uses: mshick/add-pr-comment@v2 + if: steps.check-issue-number.outputs.valid_format == 'false' + with: + message: "## 🛠️ 이슈와 PR의 Labels 동기화를 스킵했어요." + allow-repeats: true diff --git a/.github/workflows/IssueToPRLabelSync/ExtractIssueNumber.sh b/.github/workflows/IssueToPRLabelSync/ExtractIssueNumber.sh new file mode 100644 index 000000000..d411c2886 --- /dev/null +++ b/.github/workflows/IssueToPRLabelSync/ExtractIssueNumber.sh @@ -0,0 +1,3 @@ +#!/bin/bash + +echo "issue_number=$(echo $PR_TITLE | grep -oP '\(#[0-9]+\)' | grep -oP '[0-9]+')" \ No newline at end of file