From 6e856b42c9075b1fe94c2878a85be010dd2b431e Mon Sep 17 00:00:00 2001 From: Matt Wang Date: Thu, 17 Jul 2025 16:04:37 +0800 Subject: [PATCH 1/3] feat: deploy PR preview to gh pages --- .github/workflows/ci.yml | 17 ++++++++++++++++- .github/workflows/deploy-gh-page.yml | 9 +++++---- 2 files changed, 21 insertions(+), 5 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index a6bd32c1cd..d82fbc707c 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -1,5 +1,11 @@ name: build +concurrency: preview-${{ github.ref }} + +permissions: + contents: write + pull-requests: write + on: pull_request: @@ -19,5 +25,14 @@ jobs: - name: Install uv uses: astral-sh/setup-uv@v6 - - name: Validate + - name: Build HTML Docs run: VERSION=${{ github.event.repository.default_branch }} JOBS=4 MODE=html make all + + - name: Deploy PR Doc Preview + uses: rossjrw/pr-preview-action@v1 + with: + source-dir: ../cpython/Doc/build/html + token: ${{ secrets.GITHUB_TOKEN }} + preview-branch: gh-pages + umbrella-dir: pr-preview + action: auto diff --git a/.github/workflows/deploy-gh-page.yml b/.github/workflows/deploy-gh-page.yml index 2c7442c1a8..05f00a9ad1 100644 --- a/.github/workflows/deploy-gh-page.yml +++ b/.github/workflows/deploy-gh-page.yml @@ -23,7 +23,8 @@ jobs: - name: Deploy to gh page uses: JamesIves/github-pages-deploy-action@v4.7.3 with: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - BRANCH: gh-pages - FOLDER: ../cpython/Doc/build/html - CLEAN: true + token: ${{ secrets.GITHUB_TOKEN }} + branch: gh-pages + folder: ../cpython/Doc/build/html + clean: true + clean-exclude: pr-preview/ From a1aaf1ff32515853f384172d43aa929a9e7c5373 Mon Sep 17 00:00:00 2001 From: Matt Wang Date: Thu, 17 Jul 2025 19:07:31 +0800 Subject: [PATCH 2/3] fix: replace archived action for gen app token --- .github/workflows/py313-sync-cpython.yml | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/.github/workflows/py313-sync-cpython.yml b/.github/workflows/py313-sync-cpython.yml index f3362c52c5..e826525144 100644 --- a/.github/workflows/py313-sync-cpython.yml +++ b/.github/workflows/py313-sync-cpython.yml @@ -36,17 +36,17 @@ jobs: - name: Sync with CPython run: make clone merge rm_cpython wrap - - uses: tibdex/github-app-token@v2 - id: generate-token + - uses: actions/create-github-app-token@v2 + id: app-token with: - app_id: ${{ secrets.APP_ID }} - private_key: ${{ secrets.APP_PRIVATE_KEY }} + app-id: ${{ secrets.APP_ID }} + private-key: ${{ secrets.APP_PRIVATE_KEY }} - name: Create Pull Request id: cpr uses: peter-evans/create-pull-request@v6 with: - token: ${{ steps.generate-token.outputs.token }} + token: ${{ steps.app-token.outputs.token }} commit-message: sync with cpython ${{ env.LATEST_COMMIT_ID }} committer: GitHub author: github-actions[bot] From 3f47875905953a0398a1bb9548b000f33e862e5b Mon Sep 17 00:00:00 2001 From: Matt Wang Date: Thu, 17 Jul 2025 19:11:07 +0800 Subject: [PATCH 3/3] fix: use app token to push to gh-pages branch --- .github/workflows/ci.yml | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index d82fbc707c..84b9b582c4 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -28,11 +28,17 @@ jobs: - name: Build HTML Docs run: VERSION=${{ github.event.repository.default_branch }} JOBS=4 MODE=html make all + - uses: actions/create-github-app-token@v2 + id: app-token + with: + app-id: ${{ secrets.APP_ID }} + private-key: ${{ secrets.APP_PRIVATE_KEY }} + - name: Deploy PR Doc Preview uses: rossjrw/pr-preview-action@v1 with: source-dir: ../cpython/Doc/build/html - token: ${{ secrets.GITHUB_TOKEN }} + token: ${{ steps.app-token.outputs.token }} preview-branch: gh-pages umbrella-dir: pr-preview action: auto