Sync: main -> v2 #23
This file contains hidden or 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
| # Automatically creates a PR to merge main (v1) into v2 to keep v2 up to date. | |
| # The oncall is responsible for reviewing and merging the sync PR. | |
| name: "Sync: main -> v2" | |
| on: | |
| schedule: | |
| - cron: '0 6 * * *' # Daily at 6am UTC | |
| workflow_dispatch: | |
| permissions: | |
| contents: write | |
| pull-requests: write | |
| jobs: | |
| sync: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v6 | |
| with: | |
| ref: v2 | |
| fetch-depth: 0 | |
| token: ${{ secrets.RELEASE_PAT }} | |
| - name: Check for new commits on main | |
| id: check | |
| run: | | |
| git fetch origin main | |
| BEHIND=$(git rev-list --count HEAD..origin/main) | |
| echo "behind=$BEHIND" >> $GITHUB_OUTPUT | |
| if [ "$BEHIND" -eq 0 ]; then | |
| echo "v2 is up to date with main, nothing to sync" | |
| else | |
| echo "v2 is $BEHIND commit(s) behind main" | |
| fi | |
| - name: Check for existing sync PR | |
| if: steps.check.outputs.behind != '0' | |
| id: existing | |
| env: | |
| GH_TOKEN: ${{ github.token }} | |
| run: | | |
| PR=$(gh pr list --base v2 --head main --state open --json number --jq '.[0].number // empty') | |
| if [ -n "$PR" ]; then | |
| echo "Sync PR #$PR already exists, skipping" | |
| echo "exists=true" >> $GITHUB_OUTPUT | |
| else | |
| echo "exists=false" >> $GITHUB_OUTPUT | |
| fi | |
| - name: Create sync PR | |
| if: steps.check.outputs.behind != '0' && steps.existing.outputs.exists == 'false' | |
| env: | |
| GH_TOKEN: ${{ secrets.RELEASE_PAT }} | |
| run: | | |
| gh pr create \ | |
| --base v2 \ | |
| --head main \ | |
| --title "chore: sync main -> v2" \ | |
| --body "Automated sync of v1 changes from main into v2. The oncall is responsible for reviewing and merging this PR. Resolve conflicts in favor of the v2 implementation." |