From dff9875211cb078410f19b2d7714914a7ab4bd16 Mon Sep 17 00:00:00 2001 From: unifolio0 Date: Mon, 9 Dec 2024 17:09:45 +0900 Subject: [PATCH 1/7] feat: Auto_PR_Setting.yml --- .github/workflows/Auto_PR_Setting.yml | 52 +++++++++++++++++++++++++++ 1 file changed, 52 insertions(+) create mode 100644 .github/workflows/Auto_PR_Setting.yml diff --git a/.github/workflows/Auto_PR_Setting.yml b/.github/workflows/Auto_PR_Setting.yml new file mode 100644 index 0000000..15b8e20 --- /dev/null +++ b/.github/workflows/Auto_PR_Setting.yml @@ -0,0 +1,52 @@ +name: Auto PR Setting + +on: + pull_request: + types: [opened] + +jobs: + assign-issue: + runs-on: ubuntu-latest + + steps: + - name: Checkout Code + uses: actions/checkout@v4 + + - name: Get Issue Number + id: get_issue + env: + GH_TOKEN: ${{ github.token }} + run: | + PR_DATA=$(gh pr view ${{ github.event.pull_request.number }} --json headRefName) + echo "PR_DATA=${PR_DATA}" >> $GITHUB_ENV + BRANCH_NAME=$(echo "${PR_DATA}" | jq -r '.headRefName') + echo "BRANCH_NAME=${BRANCH_NAME}" >> $GITHUB_ENV + ISSUE_NUMBER=$(echo "${BRANCH_NAME}" | awk -F'#' '{print $2}' | grep -Eo '^[0-9]+') + echo "ISSUE_NUMBER=${ISSUE_NUMBER}" >> $GITHUB_ENV + + - name: Get Issue Details + id: get_issue_details + env: + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} + run: | + ISSUE_DATA=$(gh issue view "${ISSUE_NUMBER}" --json assignees,labels,projectItems --jq '{assignees: [.assignees[].login], labels: [.labels[].name], projects: [.projectItems[].title]}') + echo "ISSUE_DATA=${ISSUE_DATA}" >> $GITHUB_ENV + + - name: Setting PR + id: setting_pr + env: + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} + run: | + ASSIGNEES=$(echo "${ISSUE_DATA}" | jq -r '.assignees | join(",")') + LABELS=$(echo "${ISSUE_DATA}" | jq -r '.labels | join(",")') + PROJECTS=$(echo "${ISSUE_DATA}" | jq -r '.projects | join(",")') + TEAM_MEMBERS=("unifolio0" "coli-geonwoo" "leegwichan") + IFS=', ' read -r -a ASSIGNEE_ARRAY <<< "${ASSIGNEES}" + REVIEWERS=() + for MEMBER in "${TEAM_MEMBERS[@]}"; do + if [[ ! " ${ASSIGNEE_ARRAY[@]} " =~ " ${MEMBER} " ]]; then + REVIEWERS+=("${MEMBER}") + fi + done + REVIEWER_LIST=$(IFS=', '; echo "${REVIEWERS[*]}") + gh pr edit ${{ github.event.pull_request.number }} --add-assignee "${ASSIGNEES}" --add-label "${LABELS}" --add-reviewer "${REVIEWER_LIST}" From 31bac5dbbd9fd9db31b3d353557167fd40f19aa9 Mon Sep 17 00:00:00 2001 From: unifolio0 Date: Mon, 9 Dec 2024 17:26:03 +0900 Subject: [PATCH 2/7] feat: PR_Comment_Notification.yml --- .github/workflows/PR_Comment_Notification.yml | 65 +++++++++++++++++++ 1 file changed, 65 insertions(+) create mode 100644 .github/workflows/PR_Comment_Notification.yml diff --git a/.github/workflows/PR_Comment_Notification.yml b/.github/workflows/PR_Comment_Notification.yml new file mode 100644 index 0000000..952dd7a --- /dev/null +++ b/.github/workflows/PR_Comment_Notification.yml @@ -0,0 +1,65 @@ +name: Discord Notification on PR Comment + +on: + issue_comment: + types: [ created, edited ] + +jobs: + notify-discord: + if: ${{ github.event.issue.pull_request && contains(github.event.comment.body, '/noti') }} + runs-on: ubuntu-latest + + steps: + - name: Set Environment Variables + env: + TITLE: ${{ github.event.issue.title }} + run: | + echo "AVATAR_URL=${{ secrets.DISCORD_AVATAR_URL }}" >> $GITHUB_ENV + echo "COMMENT_BODY= πŸ€šλ°±μ—”λ“œ μΉœκ΅¬λ“€ λͺ¨μ—¬λΌ~ πŸ”Š" >> $GITHUB_ENV + echo "USERNAME=λ§λ‚˜λ‡½" >> $GITHUB_ENV + echo "WEB_HOOK=${{ secrets.DISCORD_WEB_HOOK }}" >> $GITHUB_ENV + + - name: Notify Discord + env: + COMMENT_BODY: ${{ env.COMMENT_BODY }} + COMMENT_AUTHOR: ${{ github.event.comment.user.login }} + PR_URL: ${{ github.event.issue.pull_request.html_url }} + AUTHOR_URL: ${{ github.event.comment.user.avatar_url }} + AVATAR_URL: ${{ env.AVATAR_URL }} + CONTENT: ${{ github.event.comment.body }} + USERNAME: ${{ env.USERNAME }} + WEB_HOOK: ${{ env.WEB_HOOK }} + run: | + if [ -n "$WEB_HOOK" ]; then + JSON_PAYLOAD=$(jq -n \ + --arg content "$CONTENT" \ + --arg description "$COMMENT_BODY" \ + --arg username "$USERNAME" \ + --arg avatar_url "$AVATAR_URL" \ + --arg title "Pull Request Command" \ + --arg url "$PR_URL" \ + --arg author_url "$AUTHOR_URL" \ + --arg author_name "$COMMENT_AUTHOR" \ + --arg color "5814783" \ + --arg timestamp "$(date -u +"%Y-%m-%dT%H:%M:%SZ")" \ + '{ + content: $content, + username: $username, + avatar_url: $avatar_url, + embeds: [{ + title: $title, + url: $url, + author: { + name: $author_name, + icon_url: $author_url + }, + description: $description, + color: ($color | tonumber), + timestamp: $timestamp + }] + }') + + curl -X POST -H "Content-Type: application/json" -d "$JSON_PAYLOAD" "$WEB_HOOK" + else + echo "No matching title found. Skipping notification." + fi From 13ca0aa6d871213a8695deb095dc1c764cc1420e Mon Sep 17 00:00:00 2001 From: SANGHUN OH <121424793+unifolio0@users.noreply.github.com> Date: Mon, 9 Dec 2024 17:28:05 +0900 Subject: [PATCH 3/7] =?UTF-8?q?docs:=20pr=20=ED=85=9C=ED=94=8C=EB=A6=BF=20?= =?UTF-8?q?=EC=9E=91=EC=84=B1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/pull_request_template.md | 4 ++++ 1 file changed, 4 insertions(+) create mode 100644 .github/pull_request_template.md diff --git a/.github/pull_request_template.md b/.github/pull_request_template.md new file mode 100644 index 0000000..d03be11 --- /dev/null +++ b/.github/pull_request_template.md @@ -0,0 +1,4 @@ +# 🚩 μ—°κ΄€ 이슈 +closed # + +# πŸ—£οΈ 리뷰 μš”κ΅¬μ‚¬ν•­ (선택) From 348ebdd55d610c54aad846b8a831012f78b39450 Mon Sep 17 00:00:00 2001 From: unifolio0 Date: Mon, 9 Dec 2024 17:32:20 +0900 Subject: [PATCH 4/7] =?UTF-8?q?fix:=20=ED=94=84=EB=A1=9C=EC=A0=9D=ED=8A=B8?= =?UTF-8?q?=20=EA=B6=8C=ED=95=9C=20=EC=98=A4=EB=A5=98=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/Auto_PR_Setting.yml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/.github/workflows/Auto_PR_Setting.yml b/.github/workflows/Auto_PR_Setting.yml index 15b8e20..5042b3d 100644 --- a/.github/workflows/Auto_PR_Setting.yml +++ b/.github/workflows/Auto_PR_Setting.yml @@ -29,7 +29,7 @@ jobs: env: GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} run: | - ISSUE_DATA=$(gh issue view "${ISSUE_NUMBER}" --json assignees,labels,projectItems --jq '{assignees: [.assignees[].login], labels: [.labels[].name], projects: [.projectItems[].title]}') + ISSUE_DATA=$(gh issue view "${ISSUE_NUMBER}" --json assignees,labels --jq '{assignees: [.assignees[].login], labels: [.labels[].name]') echo "ISSUE_DATA=${ISSUE_DATA}" >> $GITHUB_ENV - name: Setting PR @@ -39,7 +39,6 @@ jobs: run: | ASSIGNEES=$(echo "${ISSUE_DATA}" | jq -r '.assignees | join(",")') LABELS=$(echo "${ISSUE_DATA}" | jq -r '.labels | join(",")') - PROJECTS=$(echo "${ISSUE_DATA}" | jq -r '.projects | join(",")') TEAM_MEMBERS=("unifolio0" "coli-geonwoo" "leegwichan") IFS=', ' read -r -a ASSIGNEE_ARRAY <<< "${ASSIGNEES}" REVIEWERS=() From 049c349417ec02ac57dd3d11ca6880cedb5bd6a2 Mon Sep 17 00:00:00 2001 From: unifolio0 Date: Mon, 9 Dec 2024 17:35:11 +0900 Subject: [PATCH 5/7] =?UTF-8?q?fix:=20jq=20=EB=AC=B8=EB=B2=95=20=EC=98=A4?= =?UTF-8?q?=EB=A5=98=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/Auto_PR_Setting.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/Auto_PR_Setting.yml b/.github/workflows/Auto_PR_Setting.yml index 5042b3d..563cd51 100644 --- a/.github/workflows/Auto_PR_Setting.yml +++ b/.github/workflows/Auto_PR_Setting.yml @@ -29,7 +29,7 @@ jobs: env: GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} run: | - ISSUE_DATA=$(gh issue view "${ISSUE_NUMBER}" --json assignees,labels --jq '{assignees: [.assignees[].login], labels: [.labels[].name]') + ISSUE_DATA=$(gh issue view "${ISSUE_NUMBER}" --json assignees,labels --jq '{assignees: [.assignees[].login], labels: [.labels[].name]}') echo "ISSUE_DATA=${ISSUE_DATA}" >> $GITHUB_ENV - name: Setting PR From 8aefa1ed2c1f2bdc37bb27a394681ba7639ed883 Mon Sep 17 00:00:00 2001 From: unifolio0 Date: Mon, 9 Dec 2024 18:05:21 +0900 Subject: [PATCH 6/7] =?UTF-8?q?fix:=20GH=5FTOKEN=20=EA=B6=8C=ED=95=9C=20?= =?UTF-8?q?=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/Auto_PR_Setting.yml | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/.github/workflows/Auto_PR_Setting.yml b/.github/workflows/Auto_PR_Setting.yml index 563cd51..28fc59e 100644 --- a/.github/workflows/Auto_PR_Setting.yml +++ b/.github/workflows/Auto_PR_Setting.yml @@ -12,10 +12,11 @@ jobs: - name: Checkout Code uses: actions/checkout@v4 + - name: Set Auth Token + run: echo "GH_TOKEN=${{ secrets.PERSONAL_ACCESS_TOKEN }}" >> $GITHUB_ENV + - name: Get Issue Number id: get_issue - env: - GH_TOKEN: ${{ github.token }} run: | PR_DATA=$(gh pr view ${{ github.event.pull_request.number }} --json headRefName) echo "PR_DATA=${PR_DATA}" >> $GITHUB_ENV @@ -26,16 +27,12 @@ jobs: - name: Get Issue Details id: get_issue_details - env: - GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} run: | ISSUE_DATA=$(gh issue view "${ISSUE_NUMBER}" --json assignees,labels --jq '{assignees: [.assignees[].login], labels: [.labels[].name]}') echo "ISSUE_DATA=${ISSUE_DATA}" >> $GITHUB_ENV - name: Setting PR id: setting_pr - env: - GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} run: | ASSIGNEES=$(echo "${ISSUE_DATA}" | jq -r '.assignees | join(",")') LABELS=$(echo "${ISSUE_DATA}" | jq -r '.labels | join(",")') From 81ae524250956b9b77cdc7b8743e452eb7cb3b7b Mon Sep 17 00:00:00 2001 From: unifolio0 Date: Mon, 9 Dec 2024 18:08:56 +0900 Subject: [PATCH 7/7] =?UTF-8?q?fix:=20=ED=94=84=EB=A1=9C=EC=A0=9D=ED=8A=B8?= =?UTF-8?q?=EB=8F=84=20=ED=95=A0=EB=8B=B9=ED=95=98=EB=8F=84=EB=A1=9D=20?= =?UTF-8?q?=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/Auto_PR_Setting.yml | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/.github/workflows/Auto_PR_Setting.yml b/.github/workflows/Auto_PR_Setting.yml index 28fc59e..aa067e0 100644 --- a/.github/workflows/Auto_PR_Setting.yml +++ b/.github/workflows/Auto_PR_Setting.yml @@ -28,7 +28,7 @@ jobs: - name: Get Issue Details id: get_issue_details run: | - ISSUE_DATA=$(gh issue view "${ISSUE_NUMBER}" --json assignees,labels --jq '{assignees: [.assignees[].login], labels: [.labels[].name]}') + ISSUE_DATA=$(gh issue view "${ISSUE_NUMBER}" --json assignees,labels,projectItems --jq '{assignees: [.assignees[].login], labels: [.labels[].name], projects: [.projectItems[].title]}') echo "ISSUE_DATA=${ISSUE_DATA}" >> $GITHUB_ENV - name: Setting PR @@ -36,6 +36,7 @@ jobs: run: | ASSIGNEES=$(echo "${ISSUE_DATA}" | jq -r '.assignees | join(",")') LABELS=$(echo "${ISSUE_DATA}" | jq -r '.labels | join(",")') + PROJECTS=$(echo "${ISSUE_DATA}" | jq -r '.projects | join(",")') TEAM_MEMBERS=("unifolio0" "coli-geonwoo" "leegwichan") IFS=', ' read -r -a ASSIGNEE_ARRAY <<< "${ASSIGNEES}" REVIEWERS=() @@ -45,4 +46,4 @@ jobs: fi done REVIEWER_LIST=$(IFS=', '; echo "${REVIEWERS[*]}") - gh pr edit ${{ github.event.pull_request.number }} --add-assignee "${ASSIGNEES}" --add-label "${LABELS}" --add-reviewer "${REVIEWER_LIST}" + gh pr edit ${{ github.event.pull_request.number }} --add-assignee "${ASSIGNEES}" --add-label "${LABELS}" --add-reviewer "${REVIEWER_LIST}" --add-project "${PROJECTS}"