Update create-token-pr.yaml #7
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
### | |
# | |
# Creates a PR from the token branch whenever is has commits ahead of main. | |
# | |
### | |
name: Create Token PR | |
on: | |
push: | |
branches: | |
- tokens/v* | |
jobs: | |
create_pr: | |
runs-on: ubuntu-latest | |
steps: | |
# Checkout the token branch which was pushed | |
- name: Checkout | |
uses: actions/checkout@v4 | |
# Get the name of the PR branch corresponding to the token branch | |
- name: Get Branch Name | |
id: branch-names | |
run: | | |
echo "pr-branch=merge-tokens-$(echo ${GITHUB_REF##*/})" >> $GITHUB_OUTPUT | |
# Check if the PR branch already exists | |
- name: Check PR Branch | |
id: ls-remote | |
run: | | |
echo "pr_branch=$(git ls-remote origin $PR_BRANCH)" >> $GITHUB_OUTPUT | |
env: | |
PR_BRANCH: ${{ steps.branch-names.outputs.pr-branch }} | |
# if the branch already exits, update the PR | |
- name: Update Branch | |
if: steps.ls-remote.outputs.pr_branch != '' | |
run: | | |
git checkout $PR_BRANCH | |
git merge ${{ github.ref_name }} -X theirs --no-edit | |
git push | |
env: | |
PR_BRANCH: ${{ steps.branch-names.outputs.pr-branch }} | |
GITHUB_TOKEN: ${{ secrets.SWISSPOSTDEVS_ACCESS_TOKEN }} | |
# if the branch does not exit, create the PR | |
- name: Create PR | |
if: steps.ls-remote.outputs.pr_branch == '' | |
run: | | |
git checkout -b $PR_BRANCH ${{ github.ref_name }} | |
git push --set-upstream origin merge-tokens-v2-24-10 | |
gh pr create --title "chore(tokens): :art: update tokens" --body "Merge this PR to update the tokens in the main branch." --base main | |
env: | |
PR_BRANCH: ${{ steps.branch-names.outputs.pr-branch }} | |
GITHUB_TOKEN: ${{ secrets.SWISSPOSTDEVS_ACCESS_TOKEN }} |