|
| 1 | +name: Sync with Upstream (unstable → production) |
| 2 | + |
| 3 | +on: |
| 4 | + schedule: |
| 5 | + - cron: "0 4 * * 0" # Every Sunday at 04:00 UTC |
| 6 | + workflow_dispatch: # Allow manual trigger from the Actions tab |
| 7 | + |
| 8 | +permissions: |
| 9 | + contents: write |
| 10 | + pull-requests: write |
| 11 | + actions: read |
| 12 | + |
| 13 | +concurrency: |
| 14 | + group: sync-upstream |
| 15 | + cancel-in-progress: true |
| 16 | + |
| 17 | +env: |
| 18 | + UPSTREAM_REPO: schrodinger/pymol-open-source |
| 19 | + UPSTREAM_BRANCH: main # change to 'main' if upstream uses main |
| 20 | + UNSTABLE_BRANCH: unstable # branch where upstream changes are merged |
| 21 | + PRODUCTION_BRANCH: production # stable branch for PyPI releases |
| 22 | + PR_BRANCH_PREFIX: sync/upstream- |
| 23 | + |
| 24 | +jobs: |
| 25 | + sync: |
| 26 | + name: Merge upstream → tests → PR |
| 27 | + runs-on: ubuntu-latest |
| 28 | + |
| 29 | + steps: |
| 30 | + - name: Checkout fork (full history) |
| 31 | + uses: actions/checkout@v4 |
| 32 | + with: |
| 33 | + fetch-depth: 0 |
| 34 | + |
| 35 | + - name: Configure Git author |
| 36 | + run: | |
| 37 | + git config --global user.name "github-actions[bot]" |
| 38 | + git config --global user.email "41898282+github-actions[bot]@users.noreply.github.com" |
| 39 | +
|
| 40 | + - name: Add and fetch upstream remote |
| 41 | + run: | |
| 42 | + git remote add upstream https://github.com/${{ env.UPSTREAM_REPO }} || true |
| 43 | + git fetch upstream ${{ env.UPSTREAM_BRANCH }} |
| 44 | + git fetch origin ${{ env.UNSTABLE_BRANCH }} |
| 45 | +
|
| 46 | + - name: Checkout unstable branch |
| 47 | + run: git checkout ${{ env.UNSTABLE_BRANCH }} |
| 48 | + |
| 49 | + - name: Merge upstream/${{ env.UPSTREAM_BRANCH }} into unstable |
| 50 | + run: | |
| 51 | + set -e |
| 52 | + git merge --no-ff --no-edit upstream/${{ env.UPSTREAM_BRANCH }} || { |
| 53 | + echo "❌ Merge conflict. Please resolve manually." >&2 |
| 54 | + git merge --abort || true |
| 55 | + exit 1 |
| 56 | + } |
| 57 | + git push origin ${{ env.UNSTABLE_BRANCH }} |
| 58 | +
|
| 59 | + - name: Run tests on unstable |
| 60 | + run: | |
| 61 | + python -m pip install --upgrade pip |
| 62 | + if [ -f requirements.txt ]; then pip install -r requirements.txt; fi |
| 63 | + pytest -q || exit 1 |
| 64 | +
|
| 65 | + - name: Detect if unstable has diverged from production |
| 66 | + id: changes |
| 67 | + run: | |
| 68 | + if git diff --quiet origin/${{ env.PRODUCTION_BRANCH }} origin/${{ env.UNSTABLE_BRANCH }}; then |
| 69 | + echo "HAS_CHANGES=false" >> $GITHUB_ENV |
| 70 | + echo "No new changes to propose for production." |
| 71 | + else |
| 72 | + echo "HAS_CHANGES=true" >> $GITHUB_ENV |
| 73 | +
|
| 74 | + - name: Create Pull Request from unstable → production |
| 75 | + if: env.HAS_CHANGES == 'true' |
| 76 | + uses: peter-evans/create-pull-request@v6 |
| 77 | + with: |
| 78 | + title: "Promote unstable → production" |
| 79 | + body: | |
| 80 | + This PR promotes the current `unstable` branch (with merged upstream changes) |
| 81 | + into `production`, preparing for the next PyPI release. |
| 82 | + |
| 83 | + Tests passed ✅ |
| 84 | + commit-message: "chore: merge unstable into production" |
| 85 | + branch: ${{ env.UNSTABLE_BRANCH }} # use unstable as the PR branch |
| 86 | + base: ${{ env.PRODUCTION_BRANCH }} |
| 87 | + delete-branch: false |
| 88 | + labels: | |
| 89 | + automated |
| 90 | + release-candidate |
0 commit comments