Skip to content

Commit

Permalink
feat: add final fixes to preview workflows
Browse files Browse the repository at this point in the history
  • Loading branch information
f-hollow committed Dec 11, 2024
1 parent f853ed1 commit ca925d6
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 6 deletions.
10 changes: 9 additions & 1 deletion .github/workflows/pr-build-preview.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
13 changes: 8 additions & 5 deletions .github/workflows/pr-deploy-preview.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@ name: Deploy preview for PR

on:
workflow_run:
workflows: ["Build preview for PR"]
workflows:
- "Build preview for PR"
types:
- completed

Expand All @@ -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
Expand All @@ -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
Expand Down

0 comments on commit ca925d6

Please sign in to comment.