File tree Expand file tree Collapse file tree 2 files changed +33
-8
lines changed Expand file tree Collapse file tree 2 files changed +33
-8
lines changed Original file line number Diff line number Diff line change 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
@@ -71,11 +74,11 @@ jobs:
7174 github-token : ${{secrets.GITHUB_TOKEN}}
7275 script : |
7376 github.rest.issues.createComment({
77+ issue_number: context.issue.number,
7478 owner: context.repo.owner,
7579 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- });
80+ body: `🎉 A preview of this PR is available at: ${{ env.HUGO_BASEURL }} `
81+ })
7982
8083 invalidate-cache :
8184 needs : build-and-deploy-preview
Original file line number Diff line number Diff line change 1+ on :
2+ # Trigger the workflow on push or pull request
3+ pull_request :
4+ types : [opened, synchronize, reopened]
5+
6+ jobs :
7+ comment :
8+ runs-on : ubuntu-latest
9+ env :
10+ HUGO_BASEURL : " https://preview-developer.espressif.com/pr${{ github.event.pull_request.number }}/"
11+ steps :
12+ - name : Post Preview Link to PR
13+ uses : actions/github-script@v7
14+ with :
15+ github-token : ${{secrets.GITHUB_TOKEN}}
16+ script : |
17+ github.rest.issues.createComment({
18+ issue_number: context.issue.number,
19+ owner: context.repo.owner,
20+ repo: context.repo.repo,
21+ body: `🎉 A preview of this PR is available at: [${{ env.HUGO_BASEURL }}](${{ env.HUGO_BASEURL }}) `
22+ })
You can’t perform that action at this time.
0 commit comments