Skip to content

Update create-token-pr.yaml #91

Update create-token-pr.yaml

Update create-token-pr.yaml #91

###
#
# Creates a PR from the token branch whenever is has commits ahead of main.
#
###
name: Create Token PR
on:
push:
branches:
- tokens/*
jobs:
create_pr:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Configure GitHub User
run: |
git config user.name "Swiss Post Bot"
git config user.email "[email protected]"
# Check if a PR branch exists
- name: Get PR Branch
id: pr-branch
run: |
PR_BRANCH="merge-tokens-${GITHUB_REF##*/}"
echo "name=${PR_BRANCH}" >> $GITHUB_OUTPUT
if [[ -n $(git ls-remote origin "${PR_BRANCH}") ]]; then
echo "exists=true" >> $GITHUB_OUTPUT
else
echo "exists=false" >> $GITHUB_OUTPUT
fi
# If the branch exits, delete it
- name: Delete PR Branch
if: steps.pr-branch.outputs.exists == 'true'
run: |
git push origin --delete ${{ steps.pr-branch.outputs.name }}
env:
GITHUB_TOKEN: ${{ secrets.SWISSPOSTDEVS_ACCESS_TOKEN }}
# Create a new PR branch
- name: Create New PR Branch
run: |
git checkout -b ${{ steps.pr-branch.outputs.name }} ${{ github.ref_name }}
git push --set-upstream origin ${{ steps.pr-branch.outputs.name }}
env:
GITHUB_TOKEN: ${{ secrets.SWISSPOSTDEVS_ACCESS_TOKEN }}
# Create a New PR from the PR branch
- name: Create New PR
run: |
gh pr create --title "chore(tokens): :art: update tokens" --body "Merge this PR to update the tokens in the main branch." --base main
env:
GITHUB_TOKEN: ${{ secrets.SWISSPOSTDEVS_ACCESS_TOKEN }}