From 6c64ea458884424b6573108fcdbff9d72844e40f Mon Sep 17 00:00:00 2001 From: neveler <55753029+neveler@users.noreply.github.com> Date: Thu, 20 Aug 2026 11:45:29 +0800 Subject: [PATCH 1/3] =?UTF-8?q?=E5=B0=86=20PR=20=E9=A2=84=E8=A7=88?= =?UTF-8?q?=E6=9E=84=E5=BB=BA=E7=94=B1=E6=89=8B=E5=8A=A8=E6=94=B9=E4=B8=BA?= =?UTF-8?q?=E8=87=AA=E5=8A=A8=E8=A7=A6=E5=8F=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/pr-preview-build.yml | 48 +++ .github/workflows/pr-preview.yml | 481 +++++-------------------- 2 files changed, 139 insertions(+), 390 deletions(-) create mode 100644 .github/workflows/pr-preview-build.yml diff --git a/.github/workflows/pr-preview-build.yml b/.github/workflows/pr-preview-build.yml new file mode 100644 index 00000000..0b92a690 --- /dev/null +++ b/.github/workflows/pr-preview-build.yml @@ -0,0 +1,48 @@ +name: PR Preview Build + +on: + pull_request: + types: + - opened + - reopened + - synchronize + +concurrency: + group: pr-preview-build-${{ github.event.pull_request.number }} + cancel-in-progress: true + +env: + JEKYLL_ENV: production + PULL_REQUEST_NUMBER: ${{ github.event.pull_request.number }} + PREVIEW_DOMAIN: "pr${{ github.event.pull_request.number }}.preview-hmcl-docs.pages.dev" + +jobs: + pr-preview-build: + if: ${{ github.event_name == 'pull_request' }} + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v7 + - name: Setup Ruby + uses: ruby/setup-ruby@v1 + with: + ruby-version: "3.4" + - name: Build Artifact + run: | + echo "${{ env.PULL_REQUEST_NUMBER }}" > "${{ runner.temp }}/PULL_REQUEST_NUMBER" + cat < /home/runner/_action.yml + url: "https://${{ env.PREVIEW_DOMAIN }}" + source: "${{ github.workspace }}" + destination: "${{ runner.temp }}/site" + preview: + pr-number: "${{ env.PULL_REQUEST_NUMBER }}" + EOF + bundle install --jobs 4 + bundle exec jekyll build --trace --config _config.yml,/home/runner/_action.yml + - name: Upload Artifact + uses: actions/upload-artifact@v7 + with: + name: artifact + path: | + ${{ runner.temp }}/site + ${{ runner.temp }}/PULL_REQUEST_NUMBER diff --git a/.github/workflows/pr-preview.yml b/.github/workflows/pr-preview.yml index 8ba68eb0..28c76d4c 100644 --- a/.github/workflows/pr-preview.yml +++ b/.github/workflows/pr-preview.yml @@ -1,413 +1,114 @@ name: PR Preview + on: - schedule: - - cron: 0 0 */6 * * - issue_comment: - types: [created] pull_request_target: - types: [labeled, synchronize, closed] + types: + - closed + workflow_run: + workflows: + - "PR Preview Build" + types: + - completed + +env: + CLOUDFLARE_PAGES_PROJECT_NAME: preview-hmcl-docs + concurrency: group: pr-preview cancel-in-progress: false -env: - JEKYLL_ENV: production - GITHUB_PR_NUMBER: ${{ github.event_name == 'issue_comment' && github.event.issue.number || github.event.pull_request.number }} + jobs: - cache-refresh: - if: ${{ !github.event.repository.fork && github.event_name == 'schedule' && github.event.schedule == '0 0 */6 * *' }} - runs-on: ubuntu-latest - steps: - - name: Cache Refresh - uses: actions/cache/restore@v4 - with: - key: pages-${{ github.run_id }} - path: /home/runner/gh-pages - restore-keys: pages- - preview-remove: - if: - ${{ - !github.event.repository.fork && ( - ( github.event_name == 'pull_request_target' && ( - github.event.action == 'closed' || ( - github.event.action == 'labeled' && - github.event.label.name == 'preview/remove' - ) - ) - ) || ( - github.event_name == 'issue_comment' && - github.event.issue.pull_request && - github.event.comment.body == '/preview remove' && - contains('OWNER,MEMBER', github.event.comment.author_association) - ) - ) - }} - runs-on: ubuntu-latest - permissions: - actions: write - contents: write - pull-requests: write - steps: - - id: restore-pages - name: Restore Pages - uses: actions/cache/restore@v4 - with: - key: pages-${{ github.run_id }} - path: /home/runner/gh-pages - restore-keys: pages- - - name: Prepare Pages - run: | - mkdir -p /home/runner/gh-pages/data/{files,refs} - rm -rf /home/runner/gh-pages/PR${{ env.GITHUB_PR_NUMBER }} - grep -rlw 'PR${{ env.GITHUB_PR_NUMBER }}' /home/runner/gh-pages/data/refs | xargs -r sed -i '/\/d' - for ref in /home/runner/gh-pages/data/refs/*; do - if [ ! -s "$ref" ]; then - base=$(basename "$ref") - rm -f "/home/runner/gh-pages/data/files/$base" - rm -f "$ref" - fi - done - echo "[$(date)] Remove Preview PR${{ env.GITHUB_PR_NUMBER }}" > /home/runner/gh-pages/index.html - - name: Save Pages - uses: actions/cache/save@v4 - with: - key: pages-${{ github.run_id }} - path: /home/runner/gh-pages - - if: ${{ github.event_name == 'issue_comment' }} - id: comment-message - name: Comment Message (issue_comment) - uses: actions/github-script@v8 - with: - script: | - github.rest.issues.updateComment({ - owner: context.repo.owner, - repo: context.repo.repo, - comment_id: context.payload.comment.id, - issue_number: context.issue.number, - body: "[Preview] Preview has been removed." - }); - - if: ${{ (github.event_name == 'pull_request_target' && github.event.action != 'closed') || steps.comment-message.outcome == 'failure' }} - name: Comment Message - uses: actions/github-script@v8 - with: - script: | - github.rest.issues.createComment({ - owner: context.repo.owner, - repo: context.repo.repo, - issue_number: context.issue.number, - body: "[Preview] Preview has been removed." - }); - - if: ${{ steps.restore-pages.outputs.cache-matched-key }} - name: Remove History Cache - uses: actions/github-script@v8 - with: - script: | - github.rest.actions.deleteActionsCacheByKey({ - owner: context.repo.owner, - repo: context.repo.repo, - key: "${{ steps.restore-pages.outputs.cache-matched-key }}" - }); - - if: ${{ contains(github.event.pull_request.labels.*.name, 'preview/remove') || contains(github.event.issue.labels.*.name, 'preview/remove') }} - name: Remove Label (preview/remove) - continue-on-error: true - uses: actions/github-script@v8 - with: - script: | - github.rest.issues.removeLabel({ - owner: context.repo.owner, - repo: context.repo.repo, - issue_number: context.issue.number, - name: "preview/remove" - }); - - if: ${{ contains(github.event.pull_request.labels.*.name, 'preview/watch') || contains(github.event.issue.labels.*.name, 'preview/watch') }} - name: Remove Label (preview/watch) - continue-on-error: true - uses: actions/github-script@v8 - with: - script: | - github.rest.issues.removeLabel({ - owner: context.repo.owner, - repo: context.repo.repo, - issue_number: context.issue.number, - name: "preview/watch" - }); - preview-create-init: - if: - ${{ - !github.event.repository.fork && ( - ( github.event_name == 'pull_request_target' && ( - ( github.event.action == 'labeled' && contains(fromJSON('["preview/create", "preview/watch"]'), github.event.label.name) ) || - ( github.event.action == 'synchronize' && contains(github.event.pull_request.labels.*.name, 'preview/watch') ) - ) - ) || ( - github.event_name == 'issue_comment' && - github.event.issue.pull_request && - contains(fromJSON('["/preview create", "/preview watch"]'), github.event.comment.body) && - contains('OWNER,MEMBER', github.event.comment.author_association) - ) - ) - }} + remove: + if: ${{ github.event_name == 'pull_request_target'}} runs-on: ubuntu-latest permissions: - checks: write pull-requests: write - outputs: - sha: ${{ steps.init.outputs.sha }} - domain: ${{ steps.init.outputs.domain }} - pathname: ${{ steps.init.outputs.pathname }} - repository: ${{ steps.init.outputs.repository }} - check-id: ${{ steps.init.outputs.check-id }} - steps: - - id: init - name: Init - uses: actions/github-script@v8 - with: - script: | - const { owner, repo } = context.repo; - const pages = (await octokit.rest.repos.getPages({ owner, repo })).data; - const domain = pages.cname || `${owner.toLowerCase()}.github.io`; - core.setOutput('domain', domain); - core.setOutput('pathname', (pages.cname || repo.toLowerCase() === domain) ? '' : `/${repo}`); - const pr = context.payload.pull_request || (await github.rest.pulls.get({ - owner, repo, - pull_number: context.issue.number - })).data; - core.setOutput('sha', pr.head.sha); - core.setOutput('repository', pr.head.repo.full_name); - const { data: check } = await github.rest.checks.create({ - owner, repo, - name: "Create preview", - head_sha: pr.head.sha, - status: "in_progress", - started_at: new Date().toISOString(), - details_url: `https://github.com/${context.repo.owner}/${context.repo.repo}/actions/runs/${{ github.run_id }}`, - output: { - title: "Create preview by command", - summary: "Preview is being created..." - } - }); - core.setOutput('check-id', check.id); - - if: ${{ github.event_name == 'issue_comment' && github.event.comment.body == '/preview watch' }} - name: Add Label (preview/watch) - continue-on-error: true - uses: actions/github-script@v8 - with: - script: | - github.rest.issues.addLabels({ - owner: context.repo.owner, - repo: context.repo.repo, - issue_number: context.issue.number, - labels: ["preview/watch"] - }); - preview-create-build: - needs: preview-create-init - runs-on: ubuntu-latest env: - PREVIEW_WATCH: - ${{ - contains(github.event.pull_request.labels.*.name, 'preview/watch') || - contains(github.event.issue.labels.*.name, 'preview/watch') || ( - github.event_name == 'issue_comment' && - github.event.comment.body == '/preview watch' - ) - }} - outputs: - artifact-id: ${{ steps.upload-site.outputs.artifact-id }} + PULL_REQUEST_NUMBER: ${{ github.event.pull_request.number }} steps: - - name: Checkout - uses: actions/checkout@v5 - with: - fetch-depth: 0 - - name: Merge PR + - name: Generate Removal Notice run: | - git config user.name "github-actions[bot]" - git config user.email "41898282+github-actions[bot]@users.noreply.github.com" - git fetch https://github.com/${{ needs.preview-create-init.outputs.repository }} ${{ needs.preview-create-init.outputs.sha }} - git merge --squash ${{ needs.preview-create-init.outputs.sha }} --no-edit - git commit -m "Merge #${{ env.GITHUB_PR_NUMBER }} for preview build" - - name: Setup Ruby - uses: ruby/setup-ruby@v1 - with: - ruby-version: "3.4" - bundler-cache: ${{ env.PREVIEW_WATCH }} - cache-version: PR-${{ env.GITHUB_PR_NUMBER }} - - name: Jekyll Build - run: | - echo "url: https://${{ needs.preview-create-init.outputs.domain }}" > _action.yml - echo "baseurl: ${{ needs.preview-create-init.outputs.pathname }}/PR${{ env.GITHUB_PR_NUMBER }}" >> _action.yml - echo "source: ${{ github.workspace }}" >> _action.yml - echo "destination: /home/runner/site" >> _action.yml - echo "preview:" >> _action.yml - echo " pr-number: ${{ env.GITHUB_PR_NUMBER }}" >> _action.yml - ${{ env.PREVIEW_WATCH }} || bundle install --jobs 4 - bundle exec jekyll build --trace --config _config.yml,_action.yml - - id: upload-site - name: Upload Site - uses: actions/upload-artifact@v4 - with: - name: site - path: /home/runner/site - preview-create-deploy: - needs: [preview-create-init, preview-create-build] - runs-on: ubuntu-latest - environment: - name: github-pages - url: https://${{ needs.preview-create-init.outputs.domain }}${{ needs.preview-create-init.outputs.pathname }}/PR${{ env.GITHUB_PR_NUMBER }} - permissions: - actions: write - pages: write - id-token: write - contents: write - steps: - - id: restore-pages - name: Restore Pages - uses: actions/cache/restore@v4 - with: - key: pages-${{ github.run_id }} - path: /home/runner/gh-pages - restore-keys: pages- - - name: Merge Site Before - run: | - mkdir -p /home/runner/gh-pages/data/{files,refs} - rm -rf /home/runner/gh-pages/PR${{ env.GITHUB_PR_NUMBER }} - grep -rlw 'PR${{ env.GITHUB_PR_NUMBER }}' /home/runner/gh-pages/data/refs | xargs -r sed -i '/\/d' - - name: Merge Site - uses: actions/download-artifact@v5 - with: - name: site - path: /home/runner/gh-pages/PR${{ env.GITHUB_PR_NUMBER }} - - name: Merge Site After - run: | - find /home/runner/gh-pages/PR${{ env.GITHUB_PR_NUMBER }} -type f | while read file; do - hash=$(sha256sum "$file" | cut -d' ' -f1) - size=$(stat -c%s "$file") - key="${hash}-${size}" - target="/home/runner/gh-pages/data/files/$key" - if [ ! -f "$target" ]; then - mv "$file" "$target" - else - rm -f "$file" - fi - ln -s "$(realpath --relative-to="$(dirname "$file")" "$target")" "$file" - echo "PR${{ env.GITHUB_PR_NUMBER }}" >> "/home/runner/gh-pages/data/refs/$key" - done - for ref in /home/runner/gh-pages/data/refs/*; do - if [ ! -s "$ref" ]; then - base=$(basename "$ref") - rm -f "/home/runner/gh-pages/data/files/$base" - rm -f "$ref" - fi - done - echo "[$(date)] Preview PR${{ env.GITHUB_PR_NUMBER }}" > /home/runner/gh-pages/index.html - - id: upload-pages - name: Upload Pages - uses: actions/upload-pages-artifact@v4 - with: - name: github-pages - path: /home/runner/gh-pages + echo "Preview already removed" > index.html - name: Deploy Pages - uses: actions/deploy-pages@v4 - with: - artifact_name: github-pages - - name: Save Pages - uses: actions/cache/save@v4 - with: - key: pages-${{ github.run_id }} - path: /home/runner/gh-pages - - if: ${{ steps.restore-pages.outputs.cache-matched-key }} - name: Remove History Cache - uses: actions/github-script@v8 - with: - script: | - github.rest.actions.deleteActionsCacheByKey({ - owner: context.repo.owner, - repo: context.repo.repo, - key: "${{ steps.restore-pages.outputs.cache-matched-key }}" - }); - - if: ${{ steps.upload-pages.outputs.artifact_id }} - name: Remove Pages Artifact - uses: actions/github-script@v8 + uses: cloudflare/wrangler-action@v4 with: - script: | - github.rest.actions.deleteArtifact({ - owner: context.repo.owner, - repo: context.repo.repo, - artifact_id: "${{ steps.upload-pages.outputs.artifact_id }}", - }); - - if: ${{ needs.preview-create-build.outputs.artifact-id }} - name: Remove Temp Artifact - uses: actions/github-script@v8 - with: - script: | - github.rest.actions.deleteArtifact({ - owner: context.repo.owner, - repo: context.repo.repo, - artifact_id: "${{ needs.preview-create-build.outputs.artifact-id }}" - }); - preview-create-finally: - if: ${{ always() && needs.preview-create-init.result == 'success' }} - needs: [preview-create-init, preview-create-deploy] + apiToken: ${{ secrets.CLOUDFLARE_API_TOKEN }} + command: | + pages deploy "." --project-name="${{ env.CLOUDFLARE_PAGES_PROJECT_NAME }}" --branch="pr${{ env.PULL_REQUEST_NUMBER }}" --no-bundle + - name: Upsert Removal Comment on PR + env: + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} + run: | + gh pr comment "${{ env.PULL_REQUEST_NUMBER }}" \ + --repo "${{ github.repository }}" \ + --body "Preview already removed" \ + --edit-last \ + --create-if-none + deploy: + if: ${{ github.event_name == 'workflow_run' && github.event.workflow_run.event == 'pull_request' && github.event.workflow_run.conclusion == 'success' }} runs-on: ubuntu-latest permissions: - checks: write pull-requests: write steps: - - if: ${{ github.event_name == 'issue_comment' }} - id: comment-message - name: Comment Message (issue_comment) - env: - PREVIEW_URL: https://${{ needs.preview-create-init.outputs.domain }}${{ needs.preview-create-init.outputs.pathname }}/PR${{ env.GITHUB_PR_NUMBER }} - continue-on-error: true - uses: actions/github-script@v8 - with: - script: | - github.rest.issues.updateComment({ - owner: context.repo.owner, - repo: context.repo.repo, - comment_id: context.payload.comment.id, - issue_number: context.issue.number, - body: "${{ needs.preview-create-deploy.result == 'success' && format('[Preview] {0}', env.PREVIEW_URL) || '[Preview] Failed, see logs for more information.' }}" - }); - - if: ${{ steps.comment-message.outcome == 'failure' }} - name: Comment Message + - name: Download Build Artifacts + uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1 + with: + name: artifact + path: ${{ runner.temp }}/artifact + run-id: ${{ github.event.workflow_run.id }} + github-token: ${{ secrets.GITHUB_TOKEN }} + - name: Validate PR Context & Setup Environment + uses: actions/github-script@v9 env: - PREVIEW_URL: https://${{ needs.preview-create-init.outputs.domain }}${{ needs.preview-create-init.outputs.pathname }}/PR${{ env.GITHUB_PR_NUMBER }} - uses: actions/github-script@v8 - with: - script: | - github.rest.issues.createComment({ - owner: context.repo.owner, - repo: context.repo.repo, - issue_number: context.issue.number, - body: "${{ needs.preview-create-deploy.result == 'success' && format('[Preview] {0}', env.PREVIEW_URL) || '[Preview] Failed, see logs for more information.' }}" - }); - - if: ${{ contains(github.event.pull_request.labels.*.name, 'preview/create') || contains(github.event.issue.labels.*.name, 'preview/create') }} - name: Remove Label (preview/create) - continue-on-error: true - uses: actions/github-script@v8 + SITE_PATH: ${{ runner.temp }}/artifact/site + PULL_REQUEST_NUMBER_PATH: ${{ runner.temp }}/artifact/PULL_REQUEST_NUMBER with: script: | - github.rest.issues.removeLabel({ - owner: context.repo.owner, - repo: context.repo.repo, - issue_number: context.issue.number, - name: "preview/create" - }); - - name: Check Over + const fs = require("fs"); + const prNumberPath = process.env.PULL_REQUEST_NUMBER_PATH; + if (!prNumberPath || !fs.existsSync(prNumberPath) || !fs.statSync(prNumberPath).isFile()) { + throw new Error("Pull request number file not found."); + } + const sitePath = process.env.SITE_PATH; + if (!sitePath || !fs.existsSync(sitePath) || !fs.statSync(sitePath).isDirectory()) { + throw new Error("Site dir not found."); + } + const PULL_REQUEST_NUMBER = parseInt(fs.readFileSync(prNumberPath, "utf8").trim(), 10); + if (isNaN(PULL_REQUEST_NUMBER)) { + throw new Error("Failed to parse the pull request number."); + } + const { owner, repo } = context.repo; + const { data: pr } = await github.rest.pulls.get({ owner, repo, pull_number: PULL_REQUEST_NUMBER }); + core.info(`Current PR state: ${pr.state}`); + if (pr.state !== "open") { + throw new Error("The pull request is not open."); + } + const run = context.payload.workflow_run; + if (!run) { + throw new Error("context.payload.workflow_run is undefined. Ensure this script runs on the 'workflow_run' event."); + } + if (pr.head.sha !== run.head_sha) { + throw new Error("PR head SHA does not match the workflow run head SHA."); + } + if (pr.head.ref !== run.head_branch) { + throw new Error("PR head branch does not match the workflow run head branch."); + } + if (pr.head.repo.full_name !== run.head_repository.full_name) { + throw new Error("PR head repository fullname does not match the workflow run head repository fullname."); + } + core.exportVariable('PULL_REQUEST_NUMBER', PULL_REQUEST_NUMBER); + - name: Deploy Preview to Cloudflare Pages + uses: cloudflare/wrangler-action@v4 + with: + apiToken: ${{ secrets.CLOUDFLARE_API_TOKEN }} + command: | + pages deploy "${{ runner.temp }}/artifact/site" --project-name="${{ env.CLOUDFLARE_PAGES_PROJECT_NAME }}" --branch="pr${{ env.PULL_REQUEST_NUMBER }}" --no-bundle + - name: Upsert Preview URL Comment on PR env: - PREVIEW_URL: https://${{ needs.preview-create-init.outputs.domain }}${{ needs.preview-create-init.outputs.pathname }}/PR${{ env.GITHUB_PR_NUMBER }} - uses: actions/github-script@v8 - with: - script: | - github.rest.checks.update({ - owner: context.repo.owner, - repo: context.repo.repo, - check_run_id: ${{ needs.preview-create-init.outputs.check-id }}, - status: "completed", - conclusion: "${{ needs.preview-create-deploy.result == 'success' && 'success' || 'failure' }}", - completed_at: new Date().toISOString(), - details_url: `https://github.com/${context.repo.owner}/${context.repo.repo}/runs/${{ github.run_id }}`, - output: { - title: "Create preview ${{ needs.preview-create-deploy.result == 'success' && 'success' || 'failure' }}", - summary: "${{ needs.preview-create-deploy.result == 'success' && format('[Preview] {0}', env.PREVIEW_URL) || '[Preview] Failed, see logs for more information.' }}" - } - }); + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} + run: | + gh pr comment "${{ env.PULL_REQUEST_NUMBER }}" \ + --repo "${{ github.repository }}" \ + --body "Preview URL: https://pr${{ env.PULL_REQUEST_NUMBER }}.${{ env.CLOUDFLARE_PAGES_PROJECT_NAME }}.pages.dev" \ + --edit-last \ + --create-if-none From e6467d9832dbc336249a79b12aed329fd2aa2915 Mon Sep 17 00:00:00 2001 From: neveler <55753029+neveler@users.noreply.github.com> Date: Fri, 21 Aug 2026 09:32:21 +0800 Subject: [PATCH 2/3] update --- .github/workflows/pr-preview-build.yml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/.github/workflows/pr-preview-build.yml b/.github/workflows/pr-preview-build.yml index 0b92a690..d7b30bf5 100644 --- a/.github/workflows/pr-preview-build.yml +++ b/.github/workflows/pr-preview-build.yml @@ -13,8 +13,8 @@ concurrency: env: JEKYLL_ENV: production + CLOUDFLARE_PAGES_PROJECT_NAME: preview-hmcl-docs PULL_REQUEST_NUMBER: ${{ github.event.pull_request.number }} - PREVIEW_DOMAIN: "pr${{ github.event.pull_request.number }}.preview-hmcl-docs.pages.dev" jobs: pr-preview-build: @@ -28,6 +28,8 @@ jobs: with: ruby-version: "3.4" - name: Build Artifact + env: + PREVIEW_DOMAIN: "pr${{ env.PULL_REQUEST_NUMBER }}.${{ env.CLOUDFLARE_PAGES_PROJECT_NAME }}.pages.dev" run: | echo "${{ env.PULL_REQUEST_NUMBER }}" > "${{ runner.temp }}/PULL_REQUEST_NUMBER" cat < /home/runner/_action.yml From 6acf33137d4ba3fc957afb480be37fb783aacdfc Mon Sep 17 00:00:00 2001 From: neveler <55753029+neveler@users.noreply.github.com> Date: Fri, 21 Aug 2026 14:13:43 +0800 Subject: [PATCH 3/3] update --- .github/workflows/pr-preview-build.yml | 100 ++++++++++++------------- 1 file changed, 50 insertions(+), 50 deletions(-) diff --git a/.github/workflows/pr-preview-build.yml b/.github/workflows/pr-preview-build.yml index d7b30bf5..fcdc89f1 100644 --- a/.github/workflows/pr-preview-build.yml +++ b/.github/workflows/pr-preview-build.yml @@ -1,50 +1,50 @@ -name: PR Preview Build - -on: - pull_request: - types: - - opened - - reopened - - synchronize - -concurrency: - group: pr-preview-build-${{ github.event.pull_request.number }} - cancel-in-progress: true - -env: - JEKYLL_ENV: production - CLOUDFLARE_PAGES_PROJECT_NAME: preview-hmcl-docs - PULL_REQUEST_NUMBER: ${{ github.event.pull_request.number }} - -jobs: - pr-preview-build: - if: ${{ github.event_name == 'pull_request' }} - runs-on: ubuntu-latest - steps: - - name: Checkout - uses: actions/checkout@v7 - - name: Setup Ruby - uses: ruby/setup-ruby@v1 - with: - ruby-version: "3.4" - - name: Build Artifact - env: - PREVIEW_DOMAIN: "pr${{ env.PULL_REQUEST_NUMBER }}.${{ env.CLOUDFLARE_PAGES_PROJECT_NAME }}.pages.dev" - run: | - echo "${{ env.PULL_REQUEST_NUMBER }}" > "${{ runner.temp }}/PULL_REQUEST_NUMBER" - cat < /home/runner/_action.yml - url: "https://${{ env.PREVIEW_DOMAIN }}" - source: "${{ github.workspace }}" - destination: "${{ runner.temp }}/site" - preview: - pr-number: "${{ env.PULL_REQUEST_NUMBER }}" - EOF - bundle install --jobs 4 - bundle exec jekyll build --trace --config _config.yml,/home/runner/_action.yml - - name: Upload Artifact - uses: actions/upload-artifact@v7 - with: - name: artifact - path: | - ${{ runner.temp }}/site - ${{ runner.temp }}/PULL_REQUEST_NUMBER +name: PR Preview Build + +on: + pull_request: + types: + - opened + - reopened + - synchronize + +concurrency: + group: pr-preview-build-${{ github.event.pull_request.number }} + cancel-in-progress: true + +env: + JEKYLL_ENV: production + CLOUDFLARE_PAGES_PROJECT_NAME: preview-hmcl-docs + PULL_REQUEST_NUMBER: ${{ github.event.pull_request.number }} + +jobs: + pr-preview-build: + if: ${{ github.event_name == 'pull_request' }} + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v7 + - name: Setup Ruby + uses: ruby/setup-ruby@v1 + with: + ruby-version: "3.4" + - name: Build Artifact + env: + PREVIEW_DOMAIN: "pr${{ env.PULL_REQUEST_NUMBER }}.${{ env.CLOUDFLARE_PAGES_PROJECT_NAME }}.pages.dev" + run: | + echo "${{ env.PULL_REQUEST_NUMBER }}" > "${{ runner.temp }}/PULL_REQUEST_NUMBER" + cat < /home/runner/_action.yml + url: "https://${{ env.PREVIEW_DOMAIN }}" + source: "${{ github.workspace }}" + destination: "${{ runner.temp }}/site" + preview: + pr-number: "${{ env.PULL_REQUEST_NUMBER }}" + EOF + bundle install --jobs 4 + bundle exec jekyll build --trace --config _config.yml,/home/runner/_action.yml + - name: Upload Artifact + uses: actions/upload-artifact@v7 + with: + name: artifact + path: | + ${{ runner.temp }}/site + ${{ runner.temp }}/PULL_REQUEST_NUMBER