From ca925d65198b4856bf1e1b0bd165eee465363da8 Mon Sep 17 00:00:00 2001 From: "kirill.chalov" Date: Wed, 11 Dec 2024 12:01:37 +0800 Subject: [PATCH] feat: add final fixes to preview workflows --- .github/workflows/pr-build-preview.yml | 10 +++++++++- .github/workflows/pr-deploy-preview.yml | 13 ++++++++----- 2 files changed, 17 insertions(+), 6 deletions(-) diff --git a/.github/workflows/pr-build-preview.yml b/.github/workflows/pr-build-preview.yml index 3869ce5a..61c18bcd 100644 --- a/.github/workflows/pr-build-preview.yml +++ b/.github/workflows/pr-build-preview.yml @@ -7,6 +7,9 @@ on: permissions: contents: read +env: + HUGO_BASEURL: "https://preview-developer.espressif.com/pr${{ github.event.pull_request.number }}/" + jobs: build-preview: runs-on: ubuntu-latest @@ -31,11 +34,16 @@ jobs: HUGO_ENV: preview run: | hugo \ + --baseURL ${{ env.HUGO_BASEURL }} \ --gc \ --minify + - name: Print preview link to PR + run: | + echo "Preview link ${{ env.HUGO_BASEURL }}" + - name: Upload artifacts - uses: actions/upload-artifact@v3 + uses: actions/upload-artifact@v4 with: name: public-folder path: ./public diff --git a/.github/workflows/pr-deploy-preview.yml b/.github/workflows/pr-deploy-preview.yml index 793e95e0..0a611667 100644 --- a/.github/workflows/pr-deploy-preview.yml +++ b/.github/workflows/pr-deploy-preview.yml @@ -2,7 +2,8 @@ name: Deploy preview for PR on: workflow_run: - workflows: ["Build preview for PR"] + workflows: + - "Build preview for PR" types: - completed @@ -27,10 +28,12 @@ jobs: steps: - name: Download artifacts - uses: actions/download-artifact@v3 + uses: actions/download-artifact@v4 with: name: public-folder path: ./public + run-id: ${{ github.event.workflow_run.id }} + github-token: ${{ secrets.GITHUB_TOKEN }} - name: Deploy to AWS S3 PR-specific subdirectory uses: jakejarvis/s3-sync-action@master @@ -50,11 +53,11 @@ jobs: github-token: ${{ secrets.GITHUB_TOKEN }} script: | github.rest.issues.createComment({ - issue_number: context.event.workflow_run.pull_requests[0].number, + issue_number: ${{ github.event.workflow_run.pull_requests[0].number }}, owner: context.repo.owner, repo: context.repo.repo, - body: `🎉 A preview of this PR is available at: ${{ env.HUGO_BASEURL }}` - }) + body: `🎉 A preview for this PR is available at: ${{ env.HUGO_BASEURL }}` + }); - name: Invalidate CloudFront cache for PR uses: chetan/invalidate-cloudfront-action@v2