diff --git a/.github/workflows/build-preview.yml b/.github/workflows/cloudflare.yml similarity index 52% rename from .github/workflows/build-preview.yml rename to .github/workflows/cloudflare.yml index a4df268..c615f75 100644 --- a/.github/workflows/build-preview.yml +++ b/.github/workflows/cloudflare.yml @@ -1,13 +1,22 @@ -name: Build Preview Deployment +name: Deploy to Cloudflare Pages on: pull_request: - types: [opened, synchronize] + +permissions: + contents: read + pull-requests: write + deployments: write + +concurrency: + group: cloudflare-pages + cancel-in-progress: false jobs: - build-preview: + deploy: + # Skip fork PRs — secrets are unavailable there + if: github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name == github.repository runs-on: ubuntu-latest - name: Build Preview Site and Upload Build Artifact env: HUGO_VERSION: 0.143.1 steps: @@ -24,18 +33,17 @@ jobs: fetch-depth: 0 - name: Build with Hugo env: - # For maximum backward compatibility with Hugo modules HUGO_ENVIRONMENT: production HUGO_ENV: production run: | hugo \ --gc \ - --minify \ - --baseURL "${{ steps.pages.outputs.base_url }}/" - - # Uploads the build directory as a workflow artifact - - name: Upload build artifact - uses: actions/upload-artifact@v4 + --minify + - name: Deploy to Cloudflare Pages + uses: cloudflare/pages-action@v1 with: - name: preview-build - path: ./public + apiToken: ${{ secrets.CLOUDFLARE_API_TOKEN }} + accountId: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }} + projectName: peakscale + directory: public + gitHubToken: ${{ secrets.GITHUB_TOKEN }} diff --git a/.github/workflows/deploy-preview.yml b/.github/workflows/deploy-preview.yml deleted file mode 100644 index 2a506d2..0000000 --- a/.github/workflows/deploy-preview.yml +++ /dev/null @@ -1,38 +0,0 @@ -name: Upload Preview Deployment -on: - workflow_run: - workflows: ['Build Preview Deployment'] - types: - - completed - -permissions: - actions: read - deployments: write - contents: read - pull-requests: write - -jobs: - deploy-preview: - runs-on: ubuntu-latest - if: ${{ github.event.workflow_run.conclusion == 'success' }} - name: Deploy Preview to Cloudflare Pages - steps: - # Downloads the build directory from the previous workflow - - name: Download build artifact - uses: actions/download-artifact@v4 - id: preview-build-artifact - with: - name: preview-build - path: build - github-token: ${{ secrets.GITHUB_TOKEN }} - run-id: ${{ github.event.workflow_run.id }} - - - name: Deploy to Cloudflare Pages - uses: AdrianGonz97/refined-cf-pages-action@v1 - with: - apiToken: ${{ secrets.CLOUDFLARE_API_TOKEN }} - accountId: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }} - githubToken: ${{ secrets.GITHUB_TOKEN }} - projectName: peakscale - deploymentName: Preview - directory: ${{ steps.preview-build-artifact.outputs.download-path }}