Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix sync workflow (finally) #40

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 9 additions & 5 deletions .github/workflows/sync.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ jobs:
with:
ref: main
fetch-depth: 0
persist-credentials: false

- name: Sync with upstream
id: sync
Expand Down Expand Up @@ -55,17 +56,20 @@ jobs:

if ! git diff --quiet main; then
echo "diff_main=1" >> $GITHUB_OUTPUT

echo ::group::Pushing sync branch
git push -f origin sync
echo ::endgroup::
else
echo "diff_main=0" >> $GITHUB_OUTPUT
echo "main is in sync with upstream"
fi
env:
GITHUB_TOKEN: ${{ steps.create_token.outputs.token }}

- name: Push to sync branch
if: ${{ steps.sync.outputs.diff_main == 1 }}
uses: ad-m/github-push-action@master
with:
github_token: ${{ steps.create_token.outputs.token }}
branch: sync

- name: Check if sync pull request exists
id: sync_pr_existence
run: |
Expand All @@ -74,7 +78,7 @@ jobs:
GITHUB_TOKEN: ${{ steps.create_token.outputs.token }}

- name: Create pull request if needed
if: ${{steps.sync_pr_existence.outputs.count == 0 && steps.sync.outputs.diff_main == 1}}
if: ${{ steps.sync_pr_existence.outputs.count == 0 && steps.sync.outputs.diff_main == 1 }}
run: |
gh pr create --head "sync" --base "main" --title "Sync with upstream" --body ""
env:
Expand Down