Skip to content

Commit

Permalink
Release workflow - open a PR with changes instead of direct push
Browse files Browse the repository at this point in the history
  • Loading branch information
sutaakar committed Jul 28, 2023
1 parent a822747 commit c7f776b
Showing 1 changed file with 24 additions and 0 deletions.
24 changes: 24 additions & 0 deletions .github/workflows/tag-and-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -48,9 +48,11 @@ jobs:
# Permission required to create a release
permissions:
contents: write
pull-requests: write

env:
IMAGE_ORG_BASE: quay.io/${{ github.event.inputs.quay-organization }}
PR_BRANCH_NAME: adjustments-release-${{ github.event.inputs.version }}

steps:
- uses: actions/checkout@v3
Expand Down Expand Up @@ -132,6 +134,28 @@ jobs:
with:
commit_message: Update dependency versions for release ${{ github.event.inputs.version }}
file_pattern: 'README.md controllers/defaults.go *.yaml Makefile go.mod go.sum'
create_branch: true
branch: ${{ env.PR_BRANCH_NAME }}

- name: Create a PR with code changes
run: |
GIT_BRANCH=${GITHUB_REF#refs/heads/}
gh pr create --base "$GIT_BRANCH" --fill --head "${{ env.PR_BRANCH_NAME }}"
PR_NUMBER=$(gh pr view ${{ env.PR_BRANCH_NAME }} --json number --jq .number)
gh pr comment $PR_NUMBER --body "/lgtm"
gh pr comment $PR_NUMBER --body "/approve"
env:
GITHUB_TOKEN: ${{ secrets.CODEFLARE_MACHINE_ACCOUNT_TOKEN }}

- name: Wait until PR with code changes is merged
run: |
timeout 3600 bash -c 'until [[ $(gh pr view '${{ env.PR_BRANCH_NAME }}' --json state --jq .state) == "MERGED" ]]; do sleep 5 && echo "$(gh pr view '${{ env.PR_BRANCH_NAME }}' --json state --jq .state)"; done'
env:
GITHUB_TOKEN: ${{ github.TOKEN }}

- name: Delete remote branch
run: |
git push origin --delete ${{ env.PR_BRANCH_NAME }}
- name: Creates a release in GitHub
run: |
Expand Down

0 comments on commit c7f776b

Please sign in to comment.