Skip to content

Commit

Permalink
chore: improve the token PR workflow (#3766)
Browse files Browse the repository at this point in the history
  • Loading branch information
alizedebray authored Oct 16, 2024
1 parent 579d250 commit 36f1626
Showing 1 changed file with 9 additions and 6 deletions.
15 changes: 9 additions & 6 deletions .github/workflows/create-token-pr.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ jobs:
uses: actions/checkout@v4

# Get the name of the token branch which was pushed and the corresponding PR branch
- name: Get Branch
- name: Get Branch Name
id: branch-names
run: |
echo "pr-branch=merge-tokens-$(echo ${GITHUB_REF##*/})" >> $GITHUB_OUTPUT
Expand All @@ -29,14 +29,17 @@ jobs:
- name: Check PR Branch
id: git-branch
run: |
GIT_BRANCH="$(git branch -l $PR_BRANCH)"
echo "pr_branch=${GIT_BRANCH}" >> $GITHUB_OUTPUT
if git branch --list "$PR_BRANCH"; then
echo "pr_branch=true" >> $GITHUB_OUTPUT
else
echo "pr_branch=false" >> $GITHUB_OUTPUT
fi
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 != ''
if: steps.git-branch.outputs.pr_branch == 'true'
run: |
git checkout $PR_BRANCH
git merge ${{ github.ref_name }} -X theirs --no-edit
Expand All @@ -47,10 +50,10 @@ jobs:

# if the branch does not exit, create the PR
- name: Create PR
if: steps.git-branch.outputs.pr_branch == ''
if: steps.git-branch.outputs.pr_branch == 'false'
run: |
git checkout -b $PR_BRANCH ${{ github.ref_name }}
gh pr create --title "chore(tokens): :art: update tokens"
gh pr create --title "chore(tokens): :art: update tokens" --body "Merge this PR to update the tokens in the main branch." --base main --head $PR_BRANCH
env:
PR_BRANCH: ${{ steps.branch-names.outputs.pr-branch }}
GITHUB_TOKEN: ${{ secrets.SWISSPOSTDEVS_ACCESS_TOKEN }}

0 comments on commit 36f1626

Please sign in to comment.