diff --git a/.github/workflows/sync-upstream.yml b/.github/workflows/sync-upstream.yml new file mode 100644 index 00000000..b3624ade --- /dev/null +++ b/.github/workflows/sync-upstream.yml @@ -0,0 +1,66 @@ +name: Sync with Upstream + +on: + schedule: + # Weekly on Monday at 6 AM UTC + - cron: '0 6 * * 1' + workflow_dispatch: + +permissions: + contents: write + pull-requests: write + +jobs: + sync-upstream: + runs-on: ubuntu-latest + steps: + - name: Checkout repository + uses: actions/checkout@v4 + with: + fetch-depth: 0 + + - name: Add upstream remote + run: | + git remote add upstream https://github.com/alexandrevilain/temporal-operator.git || true + git fetch upstream + + - name: Check for upstream changes + id: check-changes + run: | + # Compare local main with upstream main + LOCAL_SHA=$(git rev-parse HEAD) + UPSTREAM_SHA=$(git rev-parse upstream/main) + + if [ "$LOCAL_SHA" = "$UPSTREAM_SHA" ]; then + echo "No changes from upstream" + echo "has_changes=false" >> $GITHUB_OUTPUT + else + echo "Upstream has changes" + echo "has_changes=true" >> $GITHUB_OUTPUT + fi + + - name: Merge upstream changes + if: steps.check-changes.outputs.has_changes == 'true' + run: | + git config user.name "github-actions[bot]" + git config user.email "github-actions[bot]@users.noreply.github.com" + git merge upstream/main --no-edit --allow-unrelated-histories || true + + - name: Create Pull Request + if: steps.check-changes.outputs.has_changes == 'true' + uses: peter-evans/create-pull-request@v6 + with: + token: ${{ secrets.GITHUB_TOKEN }} + commit-message: "chore: sync with upstream temporal-operator" + branch: chore/sync-upstream + delete-branch: true + title: "chore: sync with upstream temporal-operator" + body: | + This PR syncs changes from the upstream repository [alexandrevilain/temporal-operator](https://github.com/alexandrevilain/temporal-operator). + + **Automated sync triggered by GitHub Actions.** + + Please review the changes carefully before merging. + labels: | + upstream-sync + automated