Skip to content

Commit

Permalink
chore: update tokens workflow (#3954)
Browse files Browse the repository at this point in the history
Updated the tokens PR workflow to:
- have only one merging branch to prevent overriding changes from the
current month with changes from the past month,
- stop merging the main branch into the token branch, merge it into the
merging branch instead
  • Loading branch information
alizedebray authored Nov 20, 2024
1 parent 81859a1 commit acb910e
Showing 1 changed file with 12 additions and 13 deletions.
25 changes: 12 additions & 13 deletions .github/workflows/create-token-pr.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -25,19 +25,11 @@ jobs:
git config user.name "Swiss Post Bot"
git config user.email "[email protected]"
- 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
Expand All @@ -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: |
Expand All @@ -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 }}
Expand Down

0 comments on commit acb910e

Please sign in to comment.