├── .gitignore ├── netlify.toml ├── package.json ├── .github └── workflows │ └── main.yml └── README.md /.gitignore: -------------------------------------------------------------------------------- 1 | build -------------------------------------------------------------------------------- /netlify.toml: -------------------------------------------------------------------------------- 1 | [build] 2 | # Directory (relative to root of your repo) that contains the deploy-ready 3 | # HTML files and assets generated by the build. If a base directory has 4 | # been specified, include it in the publish directory path. 5 | publish = "build" 6 | 7 | # Default build command. 8 | command = "npm run build" -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "netlify-build-github-actions", 3 | "version": "1.0.0", 4 | "description": "", 5 | "main": "build.js", 6 | "scripts": { 7 | "build": "node build.js", 8 | "test": "echo \"Error: no test specified\" && exit 1" 9 | }, 10 | "keywords": [], 11 | "author": "", 12 | "license": "ISC" 13 | } 14 | -------------------------------------------------------------------------------- /.github/workflows/main.yml: -------------------------------------------------------------------------------- 1 | name: Trigger Netlify Build 2 | on: 3 | schedule: 4 | - cron: '0 0 * * 0' # every sunday 5 | jobs: 6 | build: 7 | name: Request Netlify Webhook 8 | runs-on: ubuntu-latest 9 | steps: 10 | - name: Curl request 11 | run: curl -X POST -d {} https://api.netlify.com/build_hooks/5d53b3ca3e8ebc0dbbe3bf10 12 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | ### ⏰ Trigger Netlify builds on a schedule using Github Actions 2 | 3 | 1. Add a [Build hook](https://www.netlify.com/docs/webhooks/#incoming-webhooks) to your site using the [Netlify Dashboard](https://app.netlify.com/) 4 | 5 | > Settings > Build & Deploy > Continuous Deployment > Build hooks 6 | 7 | 1. Create a `.github/workflows/main.yml` file in your Github repo, replacing _YOUR_BUILD_HOOK_ with the build hook you just created. 8 | 9 | ```yaml 10 | name: Trigger Netlify Build 11 | on: 12 | schedule: 13 | - cron: '*/15 * * * *' # every 15 mins 14 | jobs: 15 | build: 16 | name: Request Netlify Webhook 17 | runs-on: ubuntu-latest 18 | steps: 19 | - name: Curl request 20 | run: curl -X POST -d {} YOUR_BUILD_HOOK 21 | ``` 22 | 23 | 1. Adjust the `cron` settings to determine how often the build will be triggered. 24 | `15 8 * * *` would run every day at 0815 25 | `0 0,12 * * *` would run at midday and midnight every day 26 | [crontab guru](https://crontab.guru/#0_0,12_*_*_*) can help you generate the correct cron syntax. 27 | See the [Github Actions Docs](https://help.github.com/en/articles/events-that-trigger-workflows#scheduled-events) for more info. 28 | 29 | 1. Open the _Actions_ tab in you Github repo to watch the workflow complete. 🎉 30 | --------------------------------------------------------------------------------