-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
46ab176
commit 99df8e8
Showing
1 changed file
with
26 additions
and
22 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -16,41 +16,45 @@ jobs: | |
|
||
steps: | ||
# Checkout the token branch which was pushed | ||
- name: Checkout | ||
- name: Checkout Token Branch | ||
uses: actions/checkout@v4 | ||
|
||
# Get the name of the PR branch corresponding to the token branch | ||
- name: Get Branch Name | ||
id: branch-names | ||
# Check if the PR branch corresponding to the token branch exists | ||
- name: Get PR Branch | ||
id: pr-branch | ||
run: | | ||
echo "pr-branch=merge-tokens-$(echo ${GITHUB_REF##*/})" >> $GITHUB_OUTPUT | ||
PR_BRANCH="merge-tokens-${GITHUB_REF##*/}" | ||
echo "name=${PR_BRANCH}" >> $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 [[ -n $(git ls-remote origin "${PR_BRANCH}") ]]; then | ||
echo "exists=true" >> $GITHUB_OUTPUT | ||
else | ||
echo "exists=false" >> $GITHUB_OUTPUT | ||
fi | ||
# if the branch exits, update the PR | ||
- name: Checkout PR Branch | ||
if: steps.pr-branch.outputs.exists == 'true' | ||
uses: actions/checkout@v4 | ||
with: | ||
ref: ${{ steps.pr-branch.outputs.name }} | ||
|
||
# if the branch already exits, update the PR | ||
- name: Update Branch | ||
if: steps.ls-remote.outputs.pr_branch != '' | ||
- name: Update PR Branch | ||
if: steps.pr-branch.outputs.exists == 'true' | ||
run: | | ||
git checkout $PR_BRANCH | ||
git config user.name "Swiss Post Bot" | ||
git config user.email "[email protected]" | ||
git merge ${{ github.ref_name }} -X theirs --no-edit | ||
git push | ||
git push origin ${{ steps.pr-branch.outputs.name }} | ||
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 == '' | ||
if: steps.pr-branch.outputs.exists == 'false' | ||
run: | | ||
git checkout -b $PR_BRANCH ${{ github.ref_name }} | ||
git push --set-upstream origin merge-tokens-v2-24-10 | ||
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: | ||
PR_BRANCH: ${{ steps.branch-names.outputs.pr-branch }} | ||
GITHUB_TOKEN: ${{ secrets.SWISSPOSTDEVS_ACCESS_TOKEN }} |