Skip to content

GitHub Action for deploying static site on Netlify or Vercel via build hook. Skips deployment if no changes are detected.

License

Notifications You must be signed in to change notification settings

lwojcik/github-action-deploy-static-site

Use this GitHub action with your project
Add this Action to an existing workflow or create a new one
View on Marketplace

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 
 
 

Repository files navigation

GitHub Action: Deploy Static Site to Netlify or Vercel

This GitHub Action deploys your static site to Netlify or Vercel by triggering a build hook from the convenience of your GitHub repository. You can also set it up to run by cron.

The Action will skip deployment when no changes are detected since the last run. To store the commit id of the current deployment GitHub cache mechanism is used.

You can also pass always_deploy set to true to trigger deployment without checking for changes.

Usage with Netlify

To obtain build hook URL:

  1. Sign in with Netlify.
  2. Select the site you want to deploy. Go to Site configuration.
  3. Select Build & deploy.
  4. Scroll down to Build hooks and click Add build hook.
  5. Enter a descriptive name of your hook and click Save.
  6. Your webook URL has the following format: https://api.netlify.com/build_hooks/12345679abcdef. You shouldn't share it with anyone else. I recommend saving it in Secrets and variables section of your GitHub repository settings.
  7. Create your workflow as follows:
name: Deploy static site
on:
  workflow_dispatch:

jobs:
  DeploySite:
    runs-on: ubuntu-latest
    steps:
      - name: Deploy site
        uses: lwojcik/github-action-deploy-static-site@v1
        with:
          platform: netlify
          netlify_deploy_hook_url: ${{ secrets.NETLIFY_DEPLOY_HOOK_URL }}
          # always_deploy: true - if you want to skip checking for changes

Usage with Vercel

To disable automatic builds and obtain build hook URL:

  1. Sign in with Vercel.
  2. Select the project you want to deploy. Go to Settings.
  3. Select Git. Head to Deploy Hooks section and create a new hook.
  4. Your webhook URL has the following format: https://api.vercel.com/v1/integrations/deploy/12345679abcdef. You shouldn't share it with anyone else. I recommend saving it in Secrets and variables section of your GitHub repository settings.
  5. Create your workflow as follows:
name: Deploy static site
on:
  workflow_dispatch:

jobs:
  DeploySite:
    runs-on: ubuntu-latest
    steps:
      - name: Deploy site
        uses: lwojcik/github-action-deploy-static-site@v1
        with:
          platform: vercel
          vercel_deploy_hook_url: ${{ secrets.VERCEL_DEPLOY_HOOK_URL }}
          # always_deploy: true - if you want to skip checking for changes

License

Licensed under MIT License. See LICENSE for more information.

About

GitHub Action for deploying static site on Netlify or Vercel via build hook. Skips deployment if no changes are detected.

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published