Skip to content

Commit 5dce1f5

Browse files
committed
Adding preview also for main branch
1 parent 960dba9 commit 5dce1f5

File tree

1 file changed

+19
-3
lines changed

1 file changed

+19
-3
lines changed

.github/workflows/preview.yml

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

33
on:
4+
push:
5+
branches:
6+
- main
47
pull_request:
58
types: [opened, synchronize, labeled]
69

@@ -10,14 +13,15 @@ concurrency:
1013

1114
jobs:
1215
run:
13-
if: contains(github.event.pull_request.labels.*.name, 'preview')
16+
if: contains(github.event.pull_request.labels.*.name, 'preview') || ${{ github.ref_name == 'main' }}
1417
runs-on: ubuntu-latest
1518
concurrency:
1619
group: netlify
1720
cancel-in-progress: false
1821
env:
1922
REPO_ACCESS_TOKEN: ${{ secrets.REPO_ACCESS_TOKEN }}
2023
APP_ENV: prod
24+
BRANCH_NAME: ${{ github.ref_name }}
2125

2226
steps:
2327

@@ -83,17 +87,29 @@ jobs:
8387
- name: Install Netlify
8488
run: npm install [email protected] -g
8589

86-
- name: Deploy to Netlify
87-
id: netlify_deploy
90+
- name: Deploy to Netlify Preview
91+
if: github.event_name == 'pull_request'
92+
run: |
93+
netlify deploy \
94+
--dir public \
95+
--site ${{ secrets.NETLIFY_SITE_ID }} \
96+
--auth ${{ secrets.NETLIFY_AUTH_TOKEN }} \
97+
--json \
98+
> deploy_output.json
99+
100+
- name: Deploy to Netlify Prod
101+
if: github.event_name != 'pull_request'
88102
run: |
89103
netlify deploy \
104+
--prod \
90105
--dir public \
91106
--site ${{ secrets.NETLIFY_SITE_ID }} \
92107
--auth ${{ secrets.NETLIFY_AUTH_TOKEN }} \
93108
--json \
94109
> deploy_output.json
95110
96111
- name: Generate URL Preview
112+
if: github.event_name == 'pull_request'
97113
id: url_preview
98114
run: |
99115
NETLIFY_PREVIEW_URL=$(jq -r '.deploy_url' deploy_output.json)

0 commit comments

Comments
 (0)