diff --git a/.github/workflows/build-and-preview-site.yml b/.github/workflows/build-and-preview-site.yml index ca6e1bd..891a685 100644 --- a/.github/workflows/build-and-preview-site.yml +++ b/.github/workflows/build-and-preview-site.yml @@ -1,6 +1,6 @@ name: Build and Preview Site on: - pull_request: + pull_request_target: branches: [master] types: [opened, synchronize, reopened, closed] @@ -18,6 +18,8 @@ jobs: steps: - name: Checkout 🛎️ uses: actions/checkout@v6 + with: + ref: ${{ github.event.pull_request.head.sha }} - name: Install and Build 🔧 env: @@ -46,7 +48,7 @@ jobs: preview: needs: build runs-on: ubuntu-latest - if: github.event_name == 'pull_request' + if: github.event_name == 'pull_request_target' permissions: contents: write pull-requests: write @@ -55,14 +57,14 @@ jobs: uses: actions/checkout@v6 - name: Download pre-built site - if: github.event_name == 'pull_request' + if: github.event_name == 'pull_request_target' uses: actions/download-artifact@v4 with: name: public-dir path: . - name: Extract site - if: github.event_name == 'pull_request' + if: github.event_name == 'pull_request_target' run: | unzip -q public-dir.zip # Ensure the extracted folder has the static files in a 'public' dir for the action @@ -73,14 +75,14 @@ jobs: fi - name: Deploy Preview - if: github.event_name == 'pull_request' && github.event.action != 'closed' + if: github.event_name == 'pull_request_target' && github.event.action != 'closed' uses: rossjrw/pr-preview-action@v1.6.3 with: source-dir: public token: ${{ secrets.GITHUB_TOKEN }} - name: Remove Preview on Close - if: github.event_name == 'pull_request' && github.event.action == 'closed' + if: github.event_name == 'pull_request_target' && github.event.action == 'closed' uses: rossjrw/pr-preview-action@v1.6.3 with: source-dir: public