Skip to content

CI/CD

CI/CD #66

Workflow file for this run

name: "CI/CD"
on:
push:
branches: [main]
workflow_dispatch:
repository_dispatch:
types:
- webhook
jobs:
build:
runs-on: ubuntu-latest
name: Build
concurrency:
group: ${{ github.ref }}
cancel-in-progress: true
steps:
- uses: actions/checkout@v4
with:
show-progress: false
- uses: actions/setup-node@v4
with:
node-version-file: .nvmrc
cache: "npm"
- uses: actions/cache@v4
with:
path: |
~/.npm
${{ github.workspace }}/.next/cache
key: ${{ runner.os }}-nextjs-${{ hashFiles('**/package-lock.json') }}-${{ hashFiles('**.[jt]s', '**.[jt]sx') }}
restore-keys: ${{ runner.os }}-nextjs-${{ hashFiles('**/package-lock.json') }}-
- name: Install dependencies
run: npm install
- name: Generate GraphQL hooks
run: npm run graphql:generate
- name: Build
run: npm run build
env:
NEXT_TELEMETRY_DISABLED: true
NEXT_PUBLIC_CMS_GRAPHQL_API_URL: ${{ secrets.CMS_GRAPHQL_API_URL }}
NEXT_PUBLIC_CMS_REST_API_URL: ${{ secrets.CMS_REST_API_URL }}
NEXT_PUBLIC_CMS_API_TOKEN: ${{ secrets.CMS_API_TOKEN }}
NEXT_PUBLIC_DISCORD_REPORTING_WEBHOOK_URL: ${{ secrets.DSICORD_REPORTING_WEBHOOK_URL }}
NEXT_PUBLIC_DISCORD_CONTACT_WEBHOOK_URL: ${{ secrets.DISCORD_CONTACT_WEBHOOK_URL }}
NEXT_PUBLIC_DISCORD_ROLE_SERVICE_REQUESTS: ${{ secrets.DISCORD_ROLE_SERVICE_REQUESTS }}
NEXT_PUBLIC_MAPBOX_API_KEY: ${{ secrets.MAPBOX_API_KEY }}
NEXT_PUBLIC_POSTHOG_KEY: ${{ secrets.POSTHOG_KEY }}
NEXT_PUBLIC_POSTHOG_HOST: ${{ secrets.POSTHOG_HOST }}
WORKBOX_APP_ID: ${{ secrets.WORKBOX_APP_ID }}
WORKBOX_APP_VERSION: ${{ secrets.WORKBOX_APP_VERSION }}
BUILD_ID_NAMESPACE: ${{ secrets.BUILD_ID_NAMESPACE }}
NODE_ENV: ${{ secrets.NODE_ENV }}
NEXT_PUBLIC_ENABLE_STAGING_INDICATOR: ${{ github.ref != 'refs/heads/main' }}
NEXT_PUBLIC_GITHUB_SHA: ${{ github.sha }}
NEXT_PUBLIC_GITHUB_REF: ${{ github.ref }}
NEXT_PUBLIC_GITHUB_RUN_ID: ${{ github.run_id }}
- uses: actions/upload-artifact@v4
with:
name: build-output
path: build/
- name: Report issue to Discord
if: failure()
uses: Ilshidur/action-discord@0.3.2
env:
DISCORD_WEBHOOK: ${{ secrets.DISCORD_INTEGRATION_REPORTER_WEBHOOK_URL }}
DISCORD_USERNAME: "GitHub Actions"
DISCORD_EMBEDS: "{}"
with:
args: "Website build on `{{ EVENT_PAYLOAD.ref }}` failed :bomb:"
deploy-staging:
name: Deploy - Staging
needs: [build]
if: github.ref != 'refs/heads/main'
runs-on: ubuntu-latest
environment: Staging
continue-on-error: true
steps:
- uses: actions/checkout@v4
with:
show-progress: false
- uses: actions/download-artifact@v4
with:
name: build-output
path: build
- name: Deploy Website
uses: SamKirkland/FTP-Deploy-Action@v4.3.5
with:
server: ${{ secrets.FTP_SERVER }}
username: ${{ secrets.FTP_USER }}
password: ${{ secrets.FTP_PASSWORD }}
local-dir: ./build/
# server-dir: ${{ vars.SERVER_DIR }}
exclude: |
**/.DS_Store
**/.vscode
**/.git*
**/.git*/**
**/.github/**
out/robots.txt
- name: Report issue to Discord
if: failure() && github.ref == 'refs/heads/main'
uses: Ilshidur/action-discord@0.3.2
env:
DISCORD_WEBHOOK: ${{ secrets.DISCORD_INTEGRATION_REPORTER_WEBHOOK_URL }}
DISCORD_USERNAME: "GitHub Actions"
DISCORD_EMBEDS: "{}"
with:
args: "Website deployment to **staging** failed :warning:"
deploy-production:
name: Deploy - Production
needs: [build]
if: github.ref == 'refs/heads/main'
runs-on: ubuntu-latest
environment: Production
continue-on-error: true
steps:
- uses: actions/checkout@v4
with:
show-progress: false
- uses: actions/download-artifact@v4
with:
name: build-output
path: build
- name: Deploy Website
uses: SamKirkland/FTP-Deploy-Action@v4.3.5
with:
server: ${{ secrets.FTP_SERVER }}
username: ${{ secrets.FTP_USER }}
password: ${{ secrets.FTP_PASSWORD }}
local-dir: ./build/
# server-dir: ${{ vars.SERVER_DIR }}
exclude: |
**/.DS_Store
**/.vscode
**/.git*
**/.git*/**
**/.github/**
- name: Report issue to Discord
if: failure() && github.ref == 'refs/heads/main'
uses: Ilshidur/action-discord@0.3.2
env:
DISCORD_WEBHOOK: ${{ secrets.DISCORD_INTEGRATION_REPORTER_WEBHOOK_URL }}
DISCORD_USERNAME: "GitHub Actions"
DISCORD_EMBEDS: "{}"
with:
args: "Website deployment to **production** failed :rotating_light:"
# deploy-styleguide:
# name: Deploy - Styleguide
# needs: [build]
# environment: Styleguide
# runs-on: ubuntu-latest
# steps:
# - uses: actions/checkout@v4
# - uses: dorny/paths-filter@v2
# id: changes
# with:
# filters: |
# src:
# - 'tailwind.config.js'
# - 'postcss.config.js'
# - 'package.json'
# - uses: actions/setup-node@v3
# if: steps.changes.outputs.src == 'true'
# with:
# node-version-file: .nvmrc
# cache: "npm"
# - run: npm install
# if: steps.changes.outputs.src == 'true'
# - run: npm run tailwind:export
# if: steps.changes.outputs.src == 'true'
# - name: Deploy Styleguide
# if: steps.changes.outputs.src == 'true'
# uses: SamKirkland/FTP-Deploy-Action@v4.3.4
# continue-on-error: true
# with:
# server: ${{ secrets.FTP_SERVER }}
# username: ${{ secrets.FTP_USER }}
# password: ${{ secrets.FTP_PASSWORD }}
# local-dir: ./styleguide/
# server-dir: ${{ vars.SERVER_DIR }}
# exclude: |
# **/.DS_Store
# **/.vscode
# **/.git*
# **/.git*/**
# **/.github/**
notify:
name: Notify
needs: [deploy-production]
if: github.ref == 'refs/heads/main'
runs-on: ubuntu-latest
steps:
- name: Report to Discord
uses: Ilshidur/action-discord@0.3.2
env:
DISCORD_WEBHOOK: ${{ secrets.DISCORD_INTEGRATION_DEPLOYMENT_WEBHOOK_URL }}
DISCORD_USERNAME: "GitHub Actions"
with:
args: "The website has been deployed to production successfully :white_check_mark:"