Skip to content

Commit 1aad3df

Browse files
committed
Filtering pr - building preview only on specific labels
1 parent caa856f commit 1aad3df

File tree

1 file changed

+20
-3
lines changed

1 file changed

+20
-3
lines changed

.github/workflows/preview.yml

+20-3
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,15 @@ on:
55
branches:
66
- vercel-preview
77
pull_request:
8-
types: [opened, synchronize]
8+
types: [opened, synchronize, labeled]
99

1010
concurrency:
11-
group: vercel
11+
group: netlify
1212
cancel-in-progress: false
1313

1414
jobs:
1515
run:
16+
if: ${{ github.event.label.name == 'preview' }}
1617
runs-on: ubuntu-latest
1718
env:
1819
REPO_ACCESS_TOKEN: ${{ secrets.REPO_ACCESS_TOKEN }}
@@ -69,4 +70,20 @@ jobs:
6970
--dir public \
7071
--site ${{ secrets.NETLIFY_SITE_ID }} \
7172
--auth ${{ secrets.NETLIFY_AUTH_TOKEN }} \
72-
--json
73+
--json \
74+
> deploy_output.json
75+
76+
- name: Generate URL Preview
77+
id: url_preview
78+
run: |
79+
NETLIFY_PREVIEW_URL=$(jq -r '.deploy_url' deploy_output.json)
80+
echo "NETLIFY_PREVIEW_URL=$NETLIFY_PREVIEW_URL" >> "$GITHUB_OUTPUT"
81+
82+
- name: Create PR Preview Comment
83+
if: github.event_name == 'pull_request'
84+
uses: peter-evans/[email protected]
85+
with:
86+
issue-number: ${{ github.event.pull_request.number }}
87+
body: |
88+
🚀 Preview this PR: ${{ steps.url_preview.outputs.NETLIFY_PREVIEW_URL }}
89+
📍 Commit SHA: ${{ github.sha }}

0 commit comments

Comments
 (0)