Deploy to Netlify via GitHub actions and "$ave Dat Money"

I’ve recently moved away from hosting my own site on a VPS to hosting it on Netlify, and since I’m such a cheap guy - I don’t want to constantly waste my free build minutes (of which you only get 300) with every small push I make. GitHub actions to the rescue!

GitHub gives you ~2000 build minutes (though not specified anywhere obvious) for free per repository, which is significantly more, and won’t immediately start charging you without warning if you reach that limit, unlike Netlify.

Feel free to modify and use this action to deploy your app to Netlify through Github as well:

name: $ave Dat Money by Fristys

on:
push:
branches: [ master ]
pull_request:
branches: [ master ]

jobs:
build:

runs-on: ubuntu-latest

strategy:
matrix:
node-version: [14.x]

steps:
- uses: actions/checkout@v2

- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v1
with:
node-version: ${{ matrix.node-version }}

- name: Install dependencies
run: npm i

- name: Build static site
run: npm run build --if-present

- name: Deploy to Netlify
uses: nwtgck/actions-netlify@v1.1
with:
publish-dir: './dist'
production-branch: master
github-token: ${{ secrets.GH_TOKEN }}
deploy-message: "Deploy from GitHub Actions"
enable-pull-request-comment: false
enable-commit-comment: true
overwrites-pull-request-comment: true
env:
NETLIFY_AUTH_TOKEN: ${{ secrets.NETLIFY_AUTH_TOKEN }}
NETLIFY_SITE_ID: ${{ secrets.NETLIFY_SITE_ID_BETA }}
timeout-minutes: 1

Published in Code, Github Actions


You might enjoy these as well

  1. Easy Typewriter effect/animation with Javascript
  2. React/Preact hook: usePersistedStore
  3. React/Preact hook: useEventListener
  4. Using Styled components with Preact
  5. Load a specific image depending on light/dark mode
  6. Using Angular CLI with Laravel
  7. Easily preserve any aspect ratio with pure CSS
  8. Easy Light and Dark mode switching with CSS