|
| 1 | +# Netlify Deploy |
| 2 | + |
| 3 | +This is a simple GitHub Action to deploy a static website to Netlify. |
| 4 | + |
| 5 | +## Usage |
| 6 | +To use a GitHub action you can just reference it on your Workflow file |
| 7 | +(for more info check [this article by Github](https://help.github.com/en/actions/automating-your-workflow-with-github-actions/configuring-a-workflow)) |
| 8 | + |
| 9 | +> Important: this action will execute `npm i` and `npm run build`. Please open an issue if another command is needed |
| 10 | +
|
| 11 | +```yml |
| 12 | +name: 'My Workflow' |
| 13 | + |
| 14 | +on: |
| 15 | + release: |
| 16 | + types: [published] |
| 17 | + |
| 18 | +jobs: |
| 19 | + deploy: |
| 20 | + name: 'Deploy to Netlify' |
| 21 | + steps: |
| 22 | + - uses: jsmrcaga/action-netlify-deploy@v1 |
| 23 | + with: |
| 24 | + NETLIFY_AUTH_TOKEN: ${{ secrets.MY_TOKEN_SECRET }} |
| 25 | + NETLIFY_DEPLOY_TO_PROD: true |
| 26 | +``` |
| 27 | +
|
| 28 | +### Inputs |
| 29 | +
|
| 30 | +As most GitHub actions, this action requires and uses some inputs, that you define in |
| 31 | +your workflow file. |
| 32 | +
|
| 33 | +The inputs this action uses are: |
| 34 | +
|
| 35 | +| Name | Required | Default | Description | |
| 36 | +|:----:|:--------:|:-------:|:-----------:| |
| 37 | +| `NETLIFY_AUTH_TOKEN` | `true` | N/A | The token needed to deploy your site ([generate here](https://app.netlify.com/user/applications#personal-access-tokens))| |
| 38 | +| `NETLIFY_SITE_ID` | `true` | N/A | The site to where deploy your site (get it from the API ID on your Site Settings) | |
| 39 | +| `NETLIFY_DEPLOY_MESSAGE` | `false` | '' | An optional deploy message | |
| 40 | +| `build_directory` | `false` | `'build'` | The directory where your files are built | |
| 41 | +| `functions_directory` | `false` | N/A | The (optional) directory where your Netlify functions are stored | |
| 42 | + |
| 43 | +## Example |
| 44 | +### Deploy to production on release |
| 45 | + |
| 46 | +> You can setup repo secrets to use in your workflows |
| 47 | + |
| 48 | +```yml |
| 49 | +name: 'Netlify Deploy' |
| 50 | +
|
| 51 | +on: |
| 52 | + release: |
| 53 | + types: ['published'] |
| 54 | +
|
| 55 | +jobs: |
| 56 | + deploy: |
| 57 | + name: 'Deploy' |
| 58 | + runs-on: ubuntu-latest |
| 59 | +
|
| 60 | + steps: |
| 61 | + - uses: actions/checkout@v1 |
| 62 | + - uses: jsmrcaga/action-netlify-deploy@master |
| 63 | + with: |
| 64 | + NETLIFY_AUTH_TOKEN: ${{ secrets.NETLIFY_AUTH_TOKEN }} |
| 65 | + NETLIFY_SITE_ID: ${{ secrets.NETLIFY_SITE_ID }} |
| 66 | + NETLIFY_DEPLOY_MESSAGE: "Prod deploy v${{ github.ref }}" |
| 67 | + NETLIFY_DEPLOY_TO_PROD: true |
| 68 | +``` |
| 69 | + |
| 70 | +### Preview Deploy on pull request |
| 71 | +```yml |
| 72 | +name: 'Netlify Preview Deploy' |
| 73 | +
|
| 74 | +on: |
| 75 | + pull_request: |
| 76 | + types: ['opened', 'edited', 'synchronize'] |
| 77 | +
|
| 78 | +jobs: |
| 79 | + deploy: |
| 80 | + name: 'Deploy' |
| 81 | + runs-on: ubuntu-latest |
| 82 | +
|
| 83 | + steps: |
| 84 | + - uses: actions/checkout@v1 |
| 85 | + - uses: jsmrcaga/action-netlify-deploy@master |
| 86 | + with: |
| 87 | + NETLIFY_AUTH_TOKEN: ${{ secrets.NETLIFY_AUTH_TOKEN }} |
| 88 | + NETLIFY_SITE_ID: ${{ secrets.NETLIFY_SITE_ID }} |
| 89 | +
|
| 90 | +``` |
0 commit comments