Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. Weโ€™ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

๐Ÿ”€ :: (#433) PR Assign, Labels ์ง€์ • ์ž๋™ํ™” workflow ์ถ”๊ฐ€ #449

Merged
merged 2 commits into from
Mar 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 40 additions & 0 deletions .github/workflows/AutoAssign.yml
Original file line number Diff line number Diff line change
@@ -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
55 changes: 55 additions & 0 deletions .github/workflows/IssueToPRLabelSync.yml
Original file line number Diff line number Diff line change
@@ -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
3 changes: 3 additions & 0 deletions .github/workflows/IssueToPRLabelSync/ExtractIssueNumber.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#!/bin/bash

echo "issue_number=$(echo $PR_TITLE | grep -oP '\(#[0-9]+\)' | grep -oP '[0-9]+')"
Loading