diff --git a/.github/workflows/archive_branch.yml b/.github/workflows/archive_branch.yml deleted file mode 100644 index 4bb9e106..00000000 --- a/.github/workflows/archive_branch.yml +++ /dev/null @@ -1,64 +0,0 @@ -name: Archive Branch on PR Merge - -on: - pull_request: - types: [closed] - -jobs: - archive_branch: - if: github.event.pull_request.merged == true - runs-on: ubuntu-latest - steps: - - name: Set up variables - env: - ORIGINAL_BRANCH: ${{ github.event.pull_request.head.ref }} - run: | - # Replace 'x/' with 'z/merged/' in the branch name - if [[ "$ORIGINAL_BRANCH" == x/* ]]; then - echo "ARCHIVED_BRANCH=${ORIGINAL_BRANCH/x\//z\/merged/}" >> $GITHUB_ENV - else - echo "ARCHIVED_BRANCH=z/archived/${ORIGINAL_BRANCH}" >> $GITHUB_ENV - fi - - - name: Get latest commit SHA of the original branch - id: get_sha - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - run: | - ORIGINAL_BRANCH=$ORIGINAL_BRANCH - SHA=$(curl -s -H "Authorization: token $GITHUB_TOKEN" \ - -H "Accept: application/vnd.github+json" \ - https://api.github.com/repos/${{ github.repository }}/git/ref/heads/$ORIGINAL_BRANCH \ - | jq -r '.object.sha') - echo "SHA=$SHA" >> $GITHUB_ENV - - - name: Create new branch with archived prefix - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - ARCHIVED_BRANCH: ${{ env.ARCHIVED_BRANCH }} - SHA: ${{ env.SHA }} - run: | - curl -X POST -H "Authorization: token $GITHUB_TOKEN" \ - -H "Accept: application/vnd.github+json" \ - https://api.github.com/repos/${{ github.repository }}/git/refs \ - -d "{\"ref\": \"refs/heads/${ARCHIVED_BRANCH}\", \"sha\": \"${SHA}\"}" - - - name: Delete the original branch - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - ORIGINAL_BRANCH: ${{ env.ORIGINAL_BRANCH }} - run: | - curl -X DELETE -H "Authorization: token $GITHUB_TOKEN" \ - -H "Accept: application/vnd.github+json" \ - https://api.github.com/repos/${{ github.repository }}/git/refs/heads/${ORIGINAL_BRANCH} - - - name: Comment on PR - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - PR_NUMBER: ${{ github.event.pull_request.number }} - ARCHIVED_BRANCH: ${{ env.ARCHIVED_BRANCH }} - run: | - curl -X POST -H "Authorization: token $GITHUB_TOKEN" \ - -H "Accept: application/vnd.github+json" \ - https://api.github.com/repos/${{ github.repository }}/issues/${PR_NUMBER}/comments \ - -d "{\"body\": \"Branch archived as ${ARCHIVED_BRANCH}\"}"