actions-netlify
March 10, 2024 ยท View on GitHub
GitHub Actions for deploying to Netlify
Deploy URLs are commented on your pull requests and commit comments!
GitHub Deployments are also supported!
Usage
# .github/workflows/netlify.yml
name: Build and Deploy to Netlify
on:
push:
pull_request:
jobs:
build:
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v4
# ( Build to ./dist or other directory... )
- name: Deploy to Netlify
uses: nwtgck/actions-netlify@v3.0
with:
publish-dir: './dist'
production-branch: master
github-token: ${{ secrets.GITHUB_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 }}
timeout-minutes: 1
Required inputs and env
publish-dir(e.g. "dist", "_site")NETLIFY_AUTH_TOKEN: Personal access tokens > New access tokenNETLIFY_SITE_ID: team page > your site > Settings > Site details > Site information > API ID- NOTE: API ID is
NETLIFY_SITE_ID.
- NOTE: API ID is
Optional inputs
production-branch(e.g. "master")production-deploy: Deploy as Netlify production deploy (default: false)github-token: ${{ secrets.GITHUB_TOKEN }}deploy-messageA custom deploy message to see on Netlify deployment (e.g.${{ github.event.pull_request.title }})enable-pull-request-comment: trueComment on pull request (default: true)enable-commit-comment: trueComment on GitHub commit (default: true)enable-commit-status: trueGitHub commit status (default: true)overwrites-pull-request-comment: trueOverwrites comment on pull request (default: true)netlify-config-path: ./netlify.tomlPath tonetlify.toml(default: undefined)functions-dirNetlify functions output directory (default: undefined)aliasSpecifies the prefix for the deployment URL, must not have uppercase or special characters (default: Netlify build ID)alias: ${{ github.head_ref }}replicates the branch deploy prefixalias: deploy-preview-${{ github.event.number }}replicates the deploy preview prefix
enable-github-deploymentWhether or not to deploy to GitHub (default: true)github-deployment-environmentEnvironment name of GitHub Deploymentsgithub-deployment-descriptionDescription of the GitHub Deploymentfails-without-credentialsFails if no credentials provided (default: false)
Paths are relative to the project's root
All paths (eg, publish-dir, netlify-config-path, functions-dir) are relative to the project's root or absolute paths.
Outputs
deploy-urlA deployment URL generated by Netlify
Build on local
npm ci
npm run all