Build production #2068
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: "Build production" | |
on: | |
push: | |
branches: [ master ] | |
schedule: | |
- cron: '30 5,16 * * *' | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
steps: | |
- name: "Checkout Source Code" | |
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4 | |
- name: "Setup Node.js environment" | |
uses: actions/setup-node@v4.1.0 | |
with: | |
node-version-file: .nvmrc | |
- name: Caching Gatsby | |
id: gatsby-cache-build | |
uses: actions/cache@v4 | |
with: | |
path: | | |
public | |
.cache | |
key: ${{ runner.os }}-gatsby-build-${{ github.run_id }} | |
restore-keys: | | |
${{ runner.os }}-gatsby-build- | |
- name: Create .env file | |
uses: SpicyPizza/create-envfile@v2 | |
with: | |
envkey_GATSBY_API_DOMAIN: ${{ secrets.GATSBY_API_DOMAIN }} | |
envkey_GATSBY_GTM_ID: ${{ secrets.GATSBY_GTM_ID }} | |
envkey_KCVV_PSD_API: ${{ secrets.KCVV_PSD_API }} | |
envkey_TYPEKIT_ID: ${{ secrets.TYPEKIT_ID }} | |
- uses: chrnorm/deployment-action@releases/v2 | |
name: Create GitHub deployment | |
id: deployment | |
with: | |
token: "${{ github.token }}" | |
environment: production | |
initial-status: queued | |
description: "Create new production deployment to netlify." | |
- name: "Build the website (production build)" | |
run: | | |
yarn install --production | |
yarn run build | |
- name: "Deploy to netlify server" | |
uses: South-Paw/action-netlify-cli@v2 | |
env: | |
NETLIFY_AUTH_TOKEN: ${{ secrets.NETLIFY_AUTH_TOKEN }} | |
NETLIFY_SITE_ID: ${{ secrets.NETLIFY_SITE_ID }} | |
with: | |
args: deploy --dir=public --prod | |
# - name: "Deploy to netlify server" | |
# id: deploy_preview | |
# run: npx netlify deploy --dir=public --prod | |
# env: | |
# NETLIFY_AUTH_TOKEN: ${{ secrets.NETLIFY_AUTH_TOKEN }} | |
# NETLIFY_SITE_ID: ${{ secrets.NETLIFY_SITE_ID }} | |
# with: | |
# secrets: '["NETLIFY_AUTH_TOKEN", "NETLIFY_SITE_ID"]' | |
- name: Update deployment status (success) | |
if: success() | |
uses: chrnorm/deployment-status@releases/v2 | |
with: | |
token: "${{ github.token }}" | |
environment-url: ${{ steps.deploy_preview.outputs.NETLIFY_URL }} | |
state: "success" | |
deployment-id: ${{ steps.deployment.outputs.deployment_id }} | |
log-url: ${{ steps.deploy_preview.outputs.NETLIFY_LOGS_URL }} | |
- name: Update deployment status (failure) | |
if: failure() | |
uses: chrnorm/deployment-status@releases/v2 | |
with: | |
token: "${{ github.token }}" | |
environment-url: ${{ steps.deploy_preview.outputs.NETLIFY_LIVE_URL }} | |
state: "failure" | |
deployment-id: ${{ steps.deployment.outputs.deployment_id }} | |
log-url: ${{ steps.deploy_preview.outputs.NETLIFY_LOGS_URL }} | |
# - name: "Deploy to netlify" | |
# uses: nwtgck/actions-netlify@v1.2.3 | |
# with: | |
# publish-dir: './public' | |
# production-branch: 'master' | |
# deploy-message: '${{ github.event.head_commit.message }}' | |
# production-deploy: true | |
# github-token: ${{ secrets.GITHUB_TOKEN }} | |
# netlify-config-path: ./netlify.toml | |
# env: | |
# NETLIFY_SITE_ID: ${{ secrets.NETLIFY_SITE_ID }} | |
# NETLIFY_AUTH_TOKEN: ${{ secrets.NETLIFY_AUTH_TOKEN }} | |
# GATSBY_GTM_ID: ${{ secrets.GATSBY_GTM_ID }} | |
# KCVV_PSD_API: ${{ secrets.KCVV_PSD_API }} | |
# GATSBY_API_DOMAIN: ${{ secrets.GATSBY_API_DOMAIN }} |