Skip to content

Sync upstream changes and create PR #7

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

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
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
54 changes: 54 additions & 0 deletions .github/workflows/sync.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
name: sync-fork
on:
schedule:
- cron: "0 0 * * *" # Run every day at midnight
workflow_dispatch:
jobs:
sync:
runs-on: ubuntu-latest
permissions:
contents: write
pull-requests: write
actions: write
env:
GH_TOKEN: ${{ secrets.PAT_TOKEN }} # Needed when there are workflow changes upstream
GH_REPO: ${{ github.repository }}
steps:
- uses: actions/checkout@v4
with:
ref: main
fetch-depth: "0"
token: ${{ secrets.PAT_TOKEN }}
- name: Check if branch exists
id: check-branch
run: |
BRANCH_NAME="chore/update-sqlite3-upstream"

if git ls-remote --heads origin ${BRANCH_NAME} | grep ${BRANCH_NAME}; then
echo "Git branch '$BRANCH_NAME' exists in the remote repository, Cancelling workflow..."
gh run cancel ${{ github.run_id }}
gh run watch ${{ github.run_id }}
fi
- name: Set config
run: |
git config --global user.name github-actions
git config --global user.email github-actions@github.com
- name: Fetch upstream
run: |
git remote add upstream https://github.com/simolus3/sqlite3.dart.git
git fetch upstream
lines=$( git diff main..upstream/main -- . ':(exclude).github/**' | wc -l )
echo "Number of detected line changes: $lines"
if [ $lines -eq 0 ]; then
echo "No changes detected, Cancelling workflow..."
gh run cancel ${{ github.run_id }}
gh run watch ${{ github.run_id }}
fi
- name: Merge upstream changes
run: |
git checkout -b chore/update-sqlite3-upstream main
git push --set-upstream origin chore/update-sqlite3-upstream
git merge upstream/main
git merge --no-edit upstream/main
git push origin chore/update-sqlite3-upstream
gh pr create --title "chore: update sqlite3 upstream" --body "This PR updates the main branch to the latest changes from the upstream repository." --base main --head chore/update-sqlite3-upstream
Loading