Skip to content

Commit 42e4878

Browse files
committed
fixup! Filtering pr - building preview only on specific labels
1 parent 1aad3df commit 42e4878

File tree

1 file changed

+36
-4
lines changed

1 file changed

+36
-4
lines changed

.github/workflows/preview.yml

Lines changed: 36 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,6 @@
11
name: Preview Deployment
22

33
on:
4-
push:
5-
branches:
6-
- vercel-preview
74
pull_request:
85
types: [opened, synchronize, labeled]
96

@@ -15,11 +12,34 @@ jobs:
1512
run:
1613
if: ${{ github.event.label.name == 'preview' }}
1714
runs-on: ubuntu-latest
15+
concurrency:
16+
group: ${{ github.workflow }}-${{ github.ref }}
17+
cancel-in-progress: true
1818
env:
1919
REPO_ACCESS_TOKEN: ${{ secrets.REPO_ACCESS_TOKEN }}
2020
APP_ENV: prod
2121

2222
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+
2343
- uses: actions/checkout@v4
2444

2545
- uses: actions/setup-node@v4
@@ -80,10 +100,22 @@ jobs:
80100
echo "NETLIFY_PREVIEW_URL=$NETLIFY_PREVIEW_URL" >> "$GITHUB_OUTPUT"
81101
82102
- 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
84104
uses: peter-evans/create-or-update-comment@v1.4.5
85105
with:
86106
issue-number: ${{ github.event.pull_request.number }}
87107
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
88120
🚀 Preview this PR: ${{ steps.url_preview.outputs.NETLIFY_PREVIEW_URL }}
89121
📍 Commit SHA: ${{ github.sha }}

0 commit comments

Comments
 (0)