1
1
name : Preview Deployment
2
2
3
3
on :
4
- push :
5
- branches :
6
- - vercel-preview
7
4
pull_request :
8
5
types : [opened, synchronize, labeled]
9
6
@@ -15,11 +12,34 @@ jobs:
15
12
run :
16
13
if : ${{ github.event.label.name == 'preview' }}
17
14
runs-on : ubuntu-latest
15
+ concurrency :
16
+ group : ${{ github.workflow }}-${{ github.ref }}
17
+ cancel-in-progress : true
18
18
env :
19
19
REPO_ACCESS_TOKEN : ${{ secrets.REPO_ACCESS_TOKEN }}
20
20
APP_ENV : prod
21
21
22
22
steps :
23
+
24
+ - name : Find PR Preview Comment
25
+ if : github.event_name == 'pull_request'
26
+ uses : peter-evans/find-comment@v1
27
+ id : deploy-preview-comment
28
+ with :
29
+ issue-number : ${{ github.event.pull_request.number }}
30
+ comment-author : " github-actions[bot]"
31
+ body-includes : " Preview this PR"
32
+
33
+ - name : Update Comment if exists
34
+ if : github.event_name == 'pull_request' && steps.deploy-preview-comment.outputs.comment-id != 0
35
+ uses : peter-evans/create-or-update-comment@v1.4.5
36
+ with :
37
+ comment-id : ${{ steps.deploy-preview-comment.outputs.comment-id }}
38
+ edit-mode : replace
39
+ body : |
40
+ ## Preview Deployment
41
+ Waiting for deployment to complete...
42
+
23
43
- uses : actions/checkout@v4
24
44
25
45
- uses : actions/setup-node@v4
@@ -80,10 +100,22 @@ jobs:
80
100
echo "NETLIFY_PREVIEW_URL=$NETLIFY_PREVIEW_URL" >> "$GITHUB_OUTPUT"
81
101
82
102
- name : Create PR Preview Comment
83
- if : github.event_name == 'pull_request'
103
+ if : github.event_name == 'pull_request' && steps.deploy-preview-comment.outputs.comment-id == 0
84
104
uses : peter-evans/create-or-update-comment@v1.4.5
85
105
with :
86
106
issue-number : ${{ github.event.pull_request.number }}
87
107
body : |
108
+ ## Preview Deployment
109
+ 🚀 Preview this PR: ${{ steps.url_preview.outputs.NETLIFY_PREVIEW_URL }}
110
+ 📍 Commit SHA: ${{ github.sha }}
111
+
112
+ - name : Update PR Preview Comment
113
+ if : github.event_name == 'pull_request' && steps.deploy-preview-comment.outputs.comment-id != 0
114
+ uses : peter-evans/create-or-update-comment@v1.4.5
115
+ with :
116
+ comment-id : ${{ steps.deploy-preview-comment.outputs.comment-id }}
117
+ edit-mode : replace
118
+ body : |
119
+ ## Preview Deployment
88
120
🚀 Preview this PR: ${{ steps.url_preview.outputs.NETLIFY_PREVIEW_URL }}
89
121
📍 Commit SHA: ${{ github.sha }}
0 commit comments