-
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
7eed260
commit dcbe962
Showing
1 changed file
with
22 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 |
---|---|---|
|
@@ -19,25 +19,18 @@ jobs: | |
uses: actions/checkout@v4 | ||
with: | ||
fetch-depth: 0 | ||
token: ${{ secrets.SWISSPOSTDEVS_ACCESS_TOKEN }} | ||
|
||
- name: Configure GitHub User | ||
run: | | ||
git config user.name "Swiss Post Bot" | ||
git config user.email "[email protected]" | ||
- name: Update Tokens Branch | ||
run: | | ||
git checkout ${{ github.ref_name }} | ||
git merge origin/main -X ours --no-edit | ||
git push | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.SWISSPOSTDEVS_ACCESS_TOKEN }} | ||
|
||
# Check if a PR branch corresponding to the token branch exists | ||
# Check if a PR branch already exists | ||
- name: Get PR Branch | ||
id: pr-branch | ||
run: | | ||
PR_BRANCH="merge-tokens-${GITHUB_REF##*/}" | ||
PR_BRANCH="update-tokens" | ||
echo "name=${PR_BRANCH}" >> $GITHUB_OUTPUT | ||
if [[ -n $(git ls-remote origin "${PR_BRANCH}") ]]; then | ||
|
@@ -46,30 +39,37 @@ jobs: | |
echo "exists=false" >> $GITHUB_OUTPUT | ||
fi | ||
# If the branch does not exit, create it | ||
# If the PR 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 checkout -b ${{ steps.pr-branch.outputs.name }} origin/main | ||
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' | ||
# Check if there are token changes | ||
- name: Get Token Changes | ||
id: tokens | ||
run: | | ||
git checkout ${{ steps.pr-branch.outputs.name }} | ||
git merge ${{ github.ref_name }} -X theirs --no-edit | ||
git checkout ${{ github.ref_name }} -- packages/tokens/tokensstudio-generated | ||
git add . | ||
if [[ -n $(git commit --dry-run --short) ]]; then | ||
echo "haveChanged=true" >> $GITHUB_OUTPUT | ||
else | ||
echo "haveChanged=false" >> $GITHUB_OUTPUT | ||
fi | ||
# If there are token changes, commit them | ||
- name: Commit Token Changes | ||
if: steps.tokens.outputs.haveChanged == 'true' | ||
run: | | ||
git commit -m "chore(tokens): update generated files" | ||
git push | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.SWISSPOSTDEVS_ACCESS_TOKEN }} | ||
# Check if a PR already exist | ||
- name: Get PR | ||
id: pr | ||
run: | | ||
if [[ -n $(gh pr list --head "${{ steps.pr-branch.outputs.name }}") ]]; then | ||
if [[ -n $(gh pr list --head ${{ steps.pr-branch.outputs.name }}) ]]; then | ||
echo "exists=true" >> $GITHUB_OUTPUT | ||
else | ||
echo "exists=false" >> $GITHUB_OUTPUT | ||
|