Skip to content

Commit

Permalink
chore: update create-token-pr.yaml (#3896)
Browse files Browse the repository at this point in the history
  • Loading branch information
alizedebray authored Nov 7, 2024
1 parent d452ce2 commit 98b504b
Showing 1 changed file with 26 additions and 7 deletions.
33 changes: 26 additions & 7 deletions .github/workflows/create-token-pr.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ name: Create Token PR
on:
push:
branches:
- tokens/v*
- tokens/*

jobs:
create_pr:
Expand Down Expand Up @@ -46,8 +46,17 @@ jobs:
echo "exists=false" >> $GITHUB_OUTPUT
fi
# If the branch exits, update the PR
- name: Update PR
# If the branch does not exit, create it
- name: Create PR Branch
if: steps.pr-branch.outputs.exists == 'false'
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 }}

# If the branch exits, update it
- name: Update PR Branch
if: steps.pr-branch.outputs.exists == 'true'
run: |
git checkout ${{ steps.pr-branch.outputs.name }}
Expand All @@ -56,12 +65,22 @@ jobs:
env:
GITHUB_TOKEN: ${{ secrets.SWISSPOSTDEVS_ACCESS_TOKEN }}

# If the branch does not exit, create the PR
# Check if a PR already exist
- name: Get PR
id: pr
run: |
if [[ -n $(gh pr list --head "${{ steps.pr-branch.outputs.name }}") ]]; then
echo "exists=true" >> $GITHUB_OUTPUT
else
echo "exists=false" >> $GITHUB_OUTPUT
fi
env:
GITHUB_TOKEN: ${{ secrets.SWISSPOSTDEVS_ACCESS_TOKEN }}

# If the PR does not exit, create it
- name: Create PR
if: steps.pr-branch.outputs.exists == 'false'
if: steps.pr.outputs.exists == 'false'
run: |
git checkout -b ${{ steps.pr-branch.outputs.name }} ${{ github.ref_name }}
git push --set-upstream origin ${{ steps.pr-branch.outputs.name }}
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 }}

0 comments on commit 98b504b

Please sign in to comment.