[CHORE] Swagger 문서화 환경 세팅 #10
Workflow file for this run
This file contains 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: Auto PR Setting | |
on: | |
pull_request: | |
types: [opened] | |
jobs: | |
assign-issue: | |
runs-on: ubuntu-latest | |
steps: | |
- 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 | |
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 | |
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 | |
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}" --add-project "${PROJECTS}" |