Skip to content
Open
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
61 changes: 61 additions & 0 deletions .github/workflows/deploy_test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
name: deploy pr title update
on:
pull_request:
branches:
- 'deploy/*/base'
permissions: write-all
jobs:
deploy-pr-title-update:
runs-on: ubuntu-latest
steps:
- name: Check PR Title
id: pr_title
run: |
PR_TITLE=$(curl -sH "Authorization: Bearer ${{ secrets.GITHUB_TOKEN }}" "https://api.github.com/repos/${{ github.repository }}/pulls/${{ github.event.pull_request.number }}" | jq -r .title)
# PR 제목이 "AMZUIOS"로 시작하면 작업 종료
if [[ "$PR_TITLE" == "deploy <"* ]]; then
echo "PR 제목이 'deploy <'로 시작하므로 작업을 종료합니다."
exit 0
else
echo "PR 제목이 'deploy <'로 시작하지 않으므로 다음 스텝으로 진행합니다."
echo "::set-output name=pr_title::$PR_TITLE"
fi
- name: Get Merged Branch Name
id: branch_name
run: |
MERGED_BRANCH_NAME="${{ github.event.pull_request.base.ref }}"
echo "Merged Branch Name: $MERGED_BRANCH_NAME"
# 브랜치 이름에서 "배포 이름" 부분 추출
MERGED_EXTRACTED_NAME=$(echo "$MERGED_BRANCH_NAME"| awk -F'/' '{print $2}')
# PR의 브랜치 이름 가져오기
RECEIVE_BRANCH_NAME="${{ github.event.pull_request.head.ref }}"
echo "PR의 브랜치 이름: $RECEIVE_BRANCH_NAME"
# 브랜치 이름에서 "AMZUIOS-1234" 부분 추출
RECEIVE_EXTRACTED_NAME=$(echo "$RECEIVE_BRANCH_NAME" | grep -oP 'AMZUIOS-\d+')
if [[ -n "$MERGED_EXTRACTED_NAME" && -n "$RECEIVE_EXTRACTED_NAME" ]]; then
echo "추출된 배포명: $MERGED_EXTRACTED_NAME"
echo "추출된 이슈명: $RECEIVE_EXTRACTED_NAME"
echo "::set-output name=branch_name::deploy/$RECEIVE_EXTRACTED_NAME <- $MERGED_EXTRACTED_NAME"
else
echo "추출할 이름이 없습니다."
exit 0
fi

- name: Update PR Title
if: ${{ steps.branch_name.outputs.branch_name != '' && steps.pr_title.outputs.pr_title != '' }}
run: |
PR_NUMBER="${{ github.event.pull_request.number }}" # 업데이트할 PR 번호
NEW_TITLE="deploy/${{ steps.branch_name.outputs.branch_name }} <- ${{ steps.branch_name.outputs.branch_name }} ${{ steps.pr_title.outputs.pr_title }}"
# GitHub API를 사용하여 PR 제목 업데이트
curl -X PATCH \
-H "Accept: application/vnd.github.v3+json" \
-H "Authorization: Bearer ${{ secrets.GITHUB_TOKEN }}" \
-d "{\"title\":\"$NEW_TITLE\"}" \
"https://api.github.com/repos/${{ github.repository }}/pulls/$PR_NUMBER"
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,8 @@
[compose navigation](https://velog.io/@pwolong/Android-Compose-Navigation)
</div>

test



test