diff --git a/.github/workflows/create-token-pr.yaml b/.github/workflows/create-token-pr.yaml index 0735130155..9f6c226966 100644 --- a/.github/workflows/create-token-pr.yaml +++ b/.github/workflows/create-token-pr.yaml @@ -25,19 +25,11 @@ jobs: git config user.name "Swiss Post Bot" git config user.email "103635272+swisspost-bot@users.noreply.github.com" - - name: Update Tokens Branch - run: | - git checkout ${{ github.ref_name }} - git merge origin/main -X ours --no-edit - git push - env: - GITHUB_TOKEN: ${{ secrets.SWISSPOSTDEVS_ACCESS_TOKEN }} - - # Check if a PR branch corresponding to the token branch exists + # Check if a PR branch already exists - name: Get PR Branch id: pr-branch run: | - PR_BRANCH="merge-tokens-${GITHUB_REF##*/}" + PR_BRANCH="update-tokens" echo "name=${PR_BRANCH}" >> $GITHUB_OUTPUT if [[ -n $(git ls-remote origin "${PR_BRANCH}") ]]; then @@ -46,7 +38,7 @@ jobs: echo "exists=false" >> $GITHUB_OUTPUT fi - # If the branch does not exit, create it + # If the PR branch does not exit, create it - name: Create PR Branch if: steps.pr-branch.outputs.exists == 'false' run: | @@ -55,12 +47,19 @@ jobs: env: GITHUB_TOKEN: ${{ secrets.SWISSPOSTDEVS_ACCESS_TOKEN }} - # If the branch exits, update it - - name: Update PR Branch + # If the PR branch exits, update it with the tokens branch + - name: Update PR Branch with Tokens Branch if: steps.pr-branch.outputs.exists == 'true' run: | git checkout ${{ steps.pr-branch.outputs.name }} git merge ${{ github.ref_name }} -X theirs --no-edit + env: + GITHUB_TOKEN: ${{ secrets.SWISSPOSTDEVS_ACCESS_TOKEN }} + + # Always update the PR branch with the main branch + - name: Update PR Branch with main + run: | + git merge origin/main -X ours --no-edit git push env: GITHUB_TOKEN: ${{ secrets.SWISSPOSTDEVS_ACCESS_TOKEN }}