Skip to content

Revert "Create push.json" #6

Revert "Create push.json"

Revert "Create push.json" #6

###
#
# 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 token branch which was pushed and the corresponding PR 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: git-branch
run: |
GIT_BRANCH="$(git branch -l $PR_BRANCH)"
echo "pr_branch=${GIT_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.git-branch.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.git-branch.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 }}