11name : Deploy preview for PR
22
33on :
4- pull_request :
5- types : [opened, synchronize, reopened]
6- # branches: [ main]
4+ push :
5+ branches :
6+ - main
77 # Allow manual runs from the Actions tab
88 workflow_dispatch :
99
1010# Set permissions of the GITHUB_TOKEN
1111permissions :
1212 contents : read
1313 id-token : write
14+ pull-requests : write
1415
1516# Allow only one concurrent deployment
1617concurrency :
1718 group : ${{ github.workflow }}-${{ github.ref }}
1819 cancel-in-progress : false
1920
21+ # Define environment variables
22+ env :
23+ HUGO_BASEURL : " https://preview-developer.espressif.com/pr${{ github.event.pull_request.number }}/"
24+
2025# Default to bash
2126defaults :
2227 run :
@@ -25,8 +30,6 @@ defaults:
2530jobs :
2631 build-and-deploy-preview :
2732 runs-on : ubuntu-latest
28- env :
29- HUGO_BASEURL : " https://preview-developer.espressif.com/pr${{ github.event.pull_request.number }}/"
3033
3134 steps :
3235
@@ -65,17 +68,22 @@ jobs:
6568 AWS_ACCESS_KEY_ID : ${{ secrets.AWS_ACCESS_KEY_ID }}
6669 AWS_SECRET_ACCESS_KEY : ${{ secrets.AWS_SECRET_ACCESS_KEY }}
6770
71+ post-comment :
72+ needs : build-and-deploy-preview
73+ runs-on : ubuntu-latest
74+ steps :
75+
6876 - name : Post Preview Link to PR
6977 uses : actions/github-script@v7
7078 with :
7179 github-token : ${{secrets.GITHUB_TOKEN}}
7280 script : |
7381 github.rest.issues.createComment({
82+ issue_number: context.issue.number,
7483 owner: context.repo.owner,
7584 repo: context.repo.repo,
76- issue_number: context.payload.pull_request.number,
77- body: `🎉 A preview of this PR is available at: [${process.env.HUGO_BASEURL}](${process.env.HUGO_BASEURL})`
78- });
85+ body: `🎉 A preview of this PR is available at: ${{ env.HUGO_BASEURL }} `
86+ })
7987
8088 invalidate-cache :
8189 needs : build-and-deploy-preview
0 commit comments