Skip to content

Commit

Permalink
netlify-deploy
Browse files Browse the repository at this point in the history
  • Loading branch information
Reecepbcups committed Nov 2, 2024
1 parent 24971c2 commit 136a11b
Showing 1 changed file with 71 additions and 0 deletions.
71 changes: 71 additions & 0 deletions .github/workflows/deploy-netlify.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
name: 'Netlify Deploy'

on:
# release:
# types: [published]
push:
# branches:
# - main

env:
BRANCH_NAME: ${{ github.ref_name }}
SITE_ID: "reece-icf-docs-site" # TODO: this should be a secret for prod?

jobs:
deploy:
name: 'Deploy to Netlify'
runs-on: ubuntu-latest
steps:
# - uses: jsmrcaga/[email protected]
# with:
#
# NETLIFY_AUTH_TOKEN: ${{ secrets.NETLIFY_AUTH_TOKEN }}
# NETLIFY_SITE_ID: ${{ secrets.NETLIFY_SITE_ID }}
# NETLIFY_DEPLOY_MESSAGE: "Prod deploy v${{ github.ref }}"
# NETLIFY_DEPLOY_TO_PROD: true

- name: Repository Checkout
uses: actions/checkout@v4

- name: Setup NodeJS
uses: actions/setup-node@v4
with:
node-version: 20
cache: "npm"

- name: Install Netlify
run: npm install [email protected] -g

- name: Install Dependencies
run: npm ci

- name: 🤔 Sync latest Upstream
run: make sync-docs

- name: Build website 🔨
run: make build-docs

# https://app.netlify.com/user/applications#personal-access-tokens
# ref: https://www.raulmelo.me/en/blog/deploying-netlify-github-actions-guide
- name: Deploy to Netlify
id: netlify_deploy
run: |
prod_flag=""
if [ "$BRANCH_NAME" = "main" ]; then prod_flag="--prod"; fi
netlify deploy \
--dir dist \
--site ${{ env.SITE_ID }} \
--auth ${{ secrets.NETLIFY_AUTH_TOKEN }} \
$prod_flag \
--json
> deploy_output.json
- name: Generate URL Preview
id: url_preview
if: ${{ env.BRANCH_NAME != 'main' }}
run: |
NETLIFY_PREVIEW_URL=$(jq -r '.deploy_url' deploy_output.json)
echo "NETLIFY_PREVIEW_URL=$NETLIFY_PREVIEW_URL" >> "$GITHUB_OUTPUT"
- name: DEBUG=WILL BE REMOVED
run: echo ${{ steps.url_preview.outputs.NETLIFY_PREVIEW_URL }}

0 comments on commit 136a11b

Please sign in to comment.