Skip to content

Commit

Permalink
Adding preview also for main branch
Browse files Browse the repository at this point in the history
  • Loading branch information
lukdog committed May 9, 2024
1 parent 960dba9 commit 5dce1f5
Showing 1 changed file with 19 additions and 3 deletions.
22 changes: 19 additions & 3 deletions .github/workflows/preview.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
name: Preview Deployment

on:
push:
branches:
- main
pull_request:
types: [opened, synchronize, labeled]

Expand All @@ -10,14 +13,15 @@ concurrency:

jobs:
run:
if: contains(github.event.pull_request.labels.*.name, 'preview')
if: contains(github.event.pull_request.labels.*.name, 'preview') || ${{ github.ref_name == 'main' }}
runs-on: ubuntu-latest
concurrency:
group: netlify
cancel-in-progress: false
env:
REPO_ACCESS_TOKEN: ${{ secrets.REPO_ACCESS_TOKEN }}
APP_ENV: prod
BRANCH_NAME: ${{ github.ref_name }}

steps:

Expand Down Expand Up @@ -83,17 +87,29 @@ jobs:
- name: Install Netlify
run: npm install [email protected] -g

- name: Deploy to Netlify
id: netlify_deploy
- name: Deploy to Netlify Preview
if: github.event_name == 'pull_request'
run: |
netlify deploy \
--dir public \
--site ${{ secrets.NETLIFY_SITE_ID }} \
--auth ${{ secrets.NETLIFY_AUTH_TOKEN }} \
--json \
> deploy_output.json
- name: Deploy to Netlify Prod
if: github.event_name != 'pull_request'
run: |
netlify deploy \
--prod \
--dir public \
--site ${{ secrets.NETLIFY_SITE_ID }} \
--auth ${{ secrets.NETLIFY_AUTH_TOKEN }} \
--json \
> deploy_output.json
- name: Generate URL Preview
if: github.event_name == 'pull_request'
id: url_preview
run: |
NETLIFY_PREVIEW_URL=$(jq -r '.deploy_url' deploy_output.json)
Expand Down

0 comments on commit 5dce1f5

Please sign in to comment.