Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feat/add workflow preview prs #347

Merged
merged 1 commit into from
Dec 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading