From e1c4c9f82d4a625b88cdbfbf666544c3c57fe889 Mon Sep 17 00:00:00 2001 From: Saeed Vaziry Date: Fri, 24 Apr 2026 12:18:04 +0200 Subject: [PATCH] Add sync-upstream workflow Manual workflow_dispatch that merges migueldeicaza/SwiftTerm@main into a dated branch and opens a PR against main, mirroring the pattern used in muxy-app/ghostty. --- .github/workflows/sync-upstream.yml | 69 +++++++++++++++++++++++++++++ 1 file changed, 69 insertions(+) create mode 100644 .github/workflows/sync-upstream.yml diff --git a/.github/workflows/sync-upstream.yml b/.github/workflows/sync-upstream.yml new file mode 100644 index 00000000..9e977e14 --- /dev/null +++ b/.github/workflows/sync-upstream.yml @@ -0,0 +1,69 @@ +name: Sync Upstream + +on: + workflow_dispatch: + +jobs: + sync: + runs-on: ubuntu-latest + permissions: + contents: write + pull-requests: write + steps: + - uses: actions/checkout@v4 + with: + fetch-depth: 0 + + - name: Configure git identity + run: | + git config user.name "github-actions[bot]" + git config user.email "github-actions[bot]@users.noreply.github.com" + + - name: Fetch upstream + run: | + git remote add upstream https://github.com/migueldeicaza/SwiftTerm.git + git fetch upstream main + + - name: Check if sync needed + id: check + run: | + BEHIND=$(git rev-list --count HEAD..upstream/main) + echo "behind=$BEHIND" >> "$GITHUB_OUTPUT" + if [ "$BEHIND" = "0" ]; then + echo "main is already up to date with upstream" + else + echo "main is $BEHIND commit(s) behind upstream" + fi + + - name: Create sync branch and merge + if: steps.check.outputs.behind != '0' + id: merge + run: | + DATE=$(date -u +%Y-%m-%d) + BRANCH="sync/upstream-$DATE" + git checkout -b "$BRANCH" + echo "branch=$BRANCH" >> "$GITHUB_OUTPUT" + + if git merge upstream/main --no-edit; then + echo "conflicts=false" >> "$GITHUB_OUTPUT" + else + echo "conflicts=true" >> "$GITHUB_OUTPUT" + git merge --abort + exit 1 + fi + + - name: Push sync branch + if: steps.check.outputs.behind != '0' && steps.merge.outputs.conflicts == 'false' + run: | + git push --set-upstream origin "${{ steps.merge.outputs.branch }}" + + - name: Open pull request + if: steps.check.outputs.behind != '0' && steps.merge.outputs.conflicts == 'false' + env: + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} + run: | + gh pr create \ + --base main \ + --head "${{ steps.merge.outputs.branch }}" \ + --title "Sync upstream ($(date -u +%Y-%m-%d))" \ + --body "Automated merge of \`migueldeicaza/SwiftTerm@main\` into \`main\`. Review the diff and merge if our customizations still compile and behave correctly."