Skip to content

Commit

Permalink
feat: add netlify deployment workflows
Browse files Browse the repository at this point in the history
  • Loading branch information
jdassonvil committed Jun 5, 2024
1 parent c1e24fe commit ef21979
Show file tree
Hide file tree
Showing 2 changed files with 118 additions and 0 deletions.
40 changes: 40 additions & 0 deletions .github/workflows/netlify-deploy-preview-v1.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
---
name: Deploy a preview to netlify

on:
workflow_call:
inputs:
app_name:
type: string
required: true
artifact_name:
type: string
required: true
environment:
type: string
required: true

deploy-staging-preview:
runs-on: ubuntu-latest
steps:
- uses: actions/download-artifact@v4
with:
name: ${{ inputs.artifact_name }}
path: ./build

- name: Deploy to Netlify
uses: nwtgck/actions-netlify@v3
with:
publish-dir: "./build"
production-deploy: false
deploy-message: "Deploy from GitHub Actions"
netlify-config-path: ./netlify.toml
alias: {{ inputs.app_name }}-preview-${{ inputs.environment }}-${{ github.event.number }}

Check failure on line 32 in .github/workflows/netlify-deploy-preview-v1.yml

View workflow job for this annotation

GitHub Actions / lint

32:20 [braces] too many spaces inside braces

Check failure on line 32 in .github/workflows/netlify-deploy-preview-v1.yml

View workflow job for this annotation

GitHub Actions / lint

32:36 [braces] too many spaces inside braces

Check failure on line 32 in .github/workflows/netlify-deploy-preview-v1.yml

View workflow job for this annotation

GitHub Actions / lint

32:39 syntax error: expected <block end>, but found '<scalar>' (syntax)
enable-pull-request-comment: true
overwrites-pull-request-comment: true
enable-commit-comment: false
github-token: ${{ secrets.GITHUB_TOKEN }}
env:
NETLIFY_AUTH_TOKEN: ${{ secrets.NETLIFY_AUTH_TOKEN }}
NETLIFY_SITE_ID: ${{ secrets.NETLIFY_SITE_ID }}
timeout-minutes: 5
78 changes: 78 additions & 0 deletions .github/workflows/netlify-deploy-v1.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
---
name: Deploy a netlify application

on:
workflow_call:
inputs:
app_name:
type: string
required: true
artifact_name:
type: string
required: true
environment:
type: string
required: true
version:
type: string
required: false

jobs:
deploy:
runs-on: ubuntu-latest
permissions:
actions: write
id-token: write
contents: read

steps:
- uses: actions/checkout@v4

- uses: actions/download-artifact@v4
with:
name: ${{ inputs.artifact_name }}
path: ./build

- uses: sencrop/github-workflows/actions/find-deployed-version
id: deplyed_version
with:
environment: ${{ inputs.environment }}
from: git

- name: Notify deployment in progress
uses: sencrop/github-workflows/actions/notify-deployment-in-progress@master
with:
service: ${{ inputs.appname }}
environment: ${{ inputs.environment }}

Check failure on line 46 in .github/workflows/netlify-deploy-v1.yml

View workflow job for this annotation

GitHub Actions / lint

46:24 [colons] too many spaces after colon
dd_api_key: ${{ secrets.DD_API_KEY }}
former_version: ${{ steps.deployed_version.outputs.version }}
new_version: ${{ inputs.version }}
slack_bot_token: ${{ secrets.SLACK_BOT_TOKEN }}

- uses: sencrop/github-workflows/actions/add-github-tag
with:
tag: ${{ inputs.environment }}

- name: Deploy to Netlify
uses: nwtgck/actions-netlify@v3
with:
publish-dir: ./build
# production-branch should not be used as production deploy are triggered on release
production-deploy: ${{ inputs.environment == "production" }}
github-token: ${{ secrets.GITHUB_TOKEN }}
deploy-message: "Deploy from GitHub Actions"
netlify-config-path: "./netlify.toml"
enable-pull-request-comment: false
enable-commit-comment: true
overwrites-pull-request-comment: false
env:
NETLIFY_AUTH_TOKEN: ${{ secrets.NETLIFY_AUTH_TOKEN }}
NETLIFY_SITE_ID: ${{ secrets.NETLIFY_SITE_ID }}
timeout-minutes: 2

- name: Track deployment time
uses: sencrop/github-workflows/actions/track-deployment-time@master
with:
service: ${{ inputs.app_name }}
environment: ${{ inputs.environment }}
dd_api_key: ${{ secrets.DD_API_KEY }}

Check failure on line 78 in .github/workflows/netlify-deploy-v1.yml

View workflow job for this annotation

GitHub Actions / lint

78:48 [new-line-at-end-of-file] no new line character at the end of file

0 comments on commit ef21979

Please sign in to comment.