diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index 52b4806..81703dc 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -6,6 +6,10 @@ on: branches: - main +concurrency: + group: gh-pages + cancel-in-progress: false + permissions: contents: write @@ -17,12 +21,19 @@ jobs: - uses: actions/setup-python@v6 with: python-version: '3.10' - - uses: abatilo/actions-poetry@v4 + - uses: abatilo/actions-poetry@0dd19c9498c3dc8728967849d0d2eae428a8a3d8 # v4 with: poetry-version: 2.1.4 - name: Install dependencies run: | poetry install --without dev + - name: Build + run: poetry run make html - name: Deploy - run: poetry run make deploy + uses: JamesIves/github-pages-deploy-action@d92aa235d04922e8f08b40ce78cc5442fcfbfa2f # v4 + with: + folder: build/html + branch: gh-pages + force: false + clean-exclude: pr-preview/ diff --git a/.github/workflows/preview-fork.yml b/.github/workflows/preview-fork.yml new file mode 100644 index 0000000..9ca199f --- /dev/null +++ b/.github/workflows/preview-fork.yml @@ -0,0 +1,64 @@ +name: Deploy Fork PR Preview + +# Org admins can manually deploy/remove a preview for a PR from a fork. +# rossjrw/pr-preview-action@v1 does not support forks automatically, +# so this workflow is the workaround until v2 is released. +# +# ⚠️ Only trigger this after reviewing the fork's code, since it checks +# out and runs code from the PR branch. + +on: + workflow_dispatch: + inputs: + pr_number: + description: 'PR number (from a fork)' + required: true + type: number + action: + description: 'Action to perform' + type: choice + options: + - deploy + - remove + default: deploy + +concurrency: + group: gh-pages + cancel-in-progress: false + +permissions: + contents: write + pull-requests: write + +jobs: + deploy-fork-preview: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + with: + ref: refs/pull/${{ inputs.pr_number }}/head + + - uses: actions/setup-python@v6 + if: inputs.action == 'deploy' + with: + python-version: '3.10' + + - uses: abatilo/actions-poetry@0dd19c9498c3dc8728967849d0d2eae428a8a3d8 # v4 + if: inputs.action == 'deploy' + with: + poetry-version: 2.1.4 + + - name: Install dependencies + if: inputs.action == 'deploy' + run: poetry install --without dev + + - name: Build + if: inputs.action == 'deploy' + run: poetry run make html + + - name: Deploy preview + uses: rossjrw/pr-preview-action@ffa7509e91a3ec8dfc2e5536c4d5c1acdf7a6de9 # v1 + with: + source-dir: ./build/html/ + pr-number: ${{ inputs.pr_number }} + action: ${{ inputs.action }} diff --git a/.github/workflows/preview.yml b/.github/workflows/preview.yml index 9fa8dde..6f2a89b 100644 --- a/.github/workflows/preview.yml +++ b/.github/workflows/preview.yml @@ -8,9 +8,9 @@ on: - synchronize - closed -concurrency: - group: preview-${{ github.ref }} - cancel-in-progress: true +concurrency: + group: gh-pages + cancel-in-progress: false permissions: contents: write @@ -24,15 +24,18 @@ jobs: - uses: actions/setup-python@v6 with: python-version: '3.10' - - uses: abatilo/actions-poetry@v4 + - uses: abatilo/actions-poetry@0dd19c9498c3dc8728967849d0d2eae428a8a3d8 # v4 with: poetry-version: 2.1.4 - name: Install dependencies + if: github.event.action != 'closed' run: poetry install --without dev - name: Build + if: github.event.action != 'closed' run: poetry run make html - name: Deploy preview - uses: rossjrw/pr-preview-action@v1 + uses: rossjrw/pr-preview-action@ffa7509e91a3ec8dfc2e5536c4d5c1acdf7a6de9 # v1 + if: github.event.pull_request.head.repo.full_name == github.repository with: source-dir: ./build/html/