diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index ebc07a9e..27873596 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -15,14 +15,23 @@ concurrency: cancel-in-progress: true jobs: + sync: + name: Sync Main to GH-Pages + uses: ./.github/workflows/sync-gh-pages.yml + permissions: + contents: write + deploy: name: Deploy Site To GitHub Pages + needs: sync runs-on: ubuntu-latest environment: name: github-pages url: ${{ steps.deployment.outputs.page_url }} steps: - uses: actions/checkout@v4 + with: + ref: ${{ needs.sync.outputs.synced_sha }} - uses: actions/setup-node@v4 with: node-version: 20 @@ -38,7 +47,7 @@ jobs: run: | npm test - name: Upload Pages artifact - uses: actions/upload-pages-artifact@v3 + uses: actions/upload-pages-artifact@v4 with: path: ./website/build - name: Deploy to GitHub Pages diff --git a/.github/workflows/sync-gh-pages.yml b/.github/workflows/sync-gh-pages.yml new file mode 100644 index 00000000..d6128279 --- /dev/null +++ b/.github/workflows/sync-gh-pages.yml @@ -0,0 +1,22 @@ +name: Sync Main to GH-Pages + +# Syncs the main branch to gh-pages so that the release workflow +# can be triggered from gh-pages (required by environment protection rules). +on: + workflow_dispatch: + workflow_call: + +permissions: + contents: write + +jobs: + sync: + name: Sync Main to GH-Pages Branch + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + with: + ref: main + fetch-depth: 0 + - name: Push main to gh-pages + run: git push origin main:gh-pages --force-with-lease