diff --git a/.github/workflows/deploy_test.yml b/.github/workflows/deploy_test.yml new file mode 100644 index 0000000..1302629 --- /dev/null +++ b/.github/workflows/deploy_test.yml @@ -0,0 +1,66 @@ +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: merged_branch_name + run: | + MERGED_BRANCH_NAME="${{ github.event.pull_request.base.ref }}" + echo "Merged Branch Name: $MERGED_BRANCH_NAME" + # 브랜치 이름에서 "배포 이름" 부분 추출 + EXTRACTED_NAME=$(echo "$MERGED_BRANCH_NAME"| awk -F'/' '{print $2}') + if [[ -n "$EXTRACTED_NAME" ]]; then + echo "추출된 이름: $EXTRACTED_NAME" + echo "::set-output name=merged_branch_name::$EXTRACTED_NAME" + else + echo "추출할 이름이 없습니다." + exit 0 + fi + - name: Get Receive branch name + id: receive_branch_name + run: | + # PR의 브랜치 이름 가져오기 + RECEIVE_BRANCH_NAME="${{ github.event.pull_request.head.ref }}" + echo "PR의 브랜치 이름: $RECEIVE_BRANCH_NAME" + # 브랜치 이름에서 "AMZUIOS-1234" 부분 추출 + EXTRACTED_NAME=$(echo "$RECEIVE_BRANCH_NAME" | grep -oP 'AMZUIOS-\d+') + if [[ -n "$EXTRACTED_NAME" ]]; then + echo "추출된 이름: $EXTRACTED_NAME" + echo "::set-output name=receive_branch_name::$EXTRACTED_NAME" + else + echo "추출할 이름이 없습니다." + exit 0 + fi + - name: Update PR Title + if: ${{ steps.receive_branch_name.outputs.receive_branch_name != '' && steps.pr_title.outputs.pr_title != '' && steps.merged_branch_name.outputs.merged_branch_name != '' }} + run: | + PR_NUMBER="${{ github.event.pull_request.number }}" # 업데이트할 PR 번호 + NEW_TITLE="deploy/${{ steps.issue_name.outputs.receive_branch_name }} <- ${{ steps.issue_name.outputs.merged_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" diff --git a/README.md b/README.md index 02321f4..116d870 100644 --- a/README.md +++ b/README.md @@ -57,7 +57,10 @@ [compose navigation](https://velog.io/@pwolong/Android-Compose-Navigation) +Deploy Test +test +test