Skip to content

Commit

Permalink
Merge pull request layer5io#225 from coder12git/deploy
Browse files Browse the repository at this point in the history
GitHub workflows for deployment preview
  • Loading branch information
leecalcote authored Nov 5, 2023
2 parents d0c43df + 2c0793c commit d2d550c
Show file tree
Hide file tree
Showing 3 changed files with 108 additions and 0 deletions.
28 changes: 28 additions & 0 deletions .github/workflows/build-and-deploy-site.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
name: Build and Deploy Site
on:
push:
branches: [ master ]
paths:
- '!**'
- 'site/**'
jobs:
build-and-deploy:
runs-on: ubuntu-latest
steps:
- name: Checkout 🛎️
uses: actions/checkout@master
with:
fetch-depth: 1

- name: Install and Build 🔧
run: |
cd site
npm install
npm run build
- name: Deploy 🚀
uses: JamesIves/[email protected]
with:
branch: site # The branch the action should deploy to.
folder: public # The folder the action should deploy.
clean: true
34 changes: 34 additions & 0 deletions .github/workflows/build-and-preview-site.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
name: Build and Preview Site
on:
pull_request:
branches: [ master ]
types: [opened, synchronize, reopened]
paths:
- '!**'
- 'site/**'

jobs:
site-preview:
runs-on: ubuntu-latest
steps:
- name: Checkout 🛎️
uses: actions/checkout@master
with:
persist-credentials: false
fetch-depth: 1

- name: Install and Build 🔧
run: |
cd site
npm install
npm run noIndex
- name: Zip Site
run: bash site/script.sh
- name: Upload files
uses: actions/upload-artifact@master
with:
name: public-dir
path: ./public-dir.zip
retention-days: 1
- name: Triger Inner workflow
run: echo "trigering inner workflow"
46 changes: 46 additions & 0 deletions .github/workflows/preview-site.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
name: Deploy Preview
on:
workflow_run:
workflows:
- Build and Preview Site
types:
- completed

jobs:
deploy-preview:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/[email protected]

- name: Download Site dir
uses: dawidd6/action-download-artifact@v2
with:
github_token: ${{ secrets.GH_ACCESS_TOKEN }}
workflow: build-and-preview-site.yml
run_id: ${{ github.event.workflow_run.id }}
name: public-dir

- name: Unzip Site
run: |
rm -rf ./site/public
unzip public-dir.zip
rm -f public-dir.zip
- name: Deploy to Netlify
id: netlify
uses: nwtgck/[email protected]
with:
publish-dir: 'site/public'
production-deploy: false
github-token: ${{ secrets.GH_ACCESS_TOKEN }}
enable-commit-comment: false
env:
NETLIFY_AUTH_TOKEN: ${{ secrets.NETLIFY_AUTH_TOKEN }}
NETLIFY_SITE_ID: ${{ secrets.NETLIFY_SITE_ID }}

- name: Comment Deploy URL
uses: ./.github/actions/comment-preview-on-pr
with:
token: ${{ secrets.GH_ACCESS_TOKEN }}
deploy_url: "${{ steps.netlify.outputs.deploy-url }}"

0 comments on commit d2d550c

Please sign in to comment.