Skip to content

Merge branch 'hotfixing-code-issues' #12

Merge branch 'hotfixing-code-issues'

Merge branch 'hotfixing-code-issues' #12

name: Deploy to Firebase
on:
push:
branches:
- main
env:
HOSTING_ENV: ${{ github.ref == 'refs/heads/main' && vars.HOSTING_ENV_PROD || vars.HOSTING_ENV_DEV }}
jobs:
code_check:
name: Code check
runs-on: ubuntu-latest
steps:
- name: Check out code
uses: actions/checkout@v4
- name: Setup node
uses: actions/setup-node@v4
with:
node-version: 20
cache: "npm"
cache-dependency-path: |
shared/package-lock.json
hosting/package-lock.json
functions/package-lock.json
- name: Run code checking and formatting (shared)
run: npm ci && npm run codecheck
working-directory: ./shared
- name: Run code checking and formatting (functions)
run: npm ci && npm run codecheck
working-directory: ./functions
- name: Run code checking and formatting (hosting)
run: npm ci && npm run codecheck
working-directory: ./hosting
- name: Ensure code is unchanged
run: git diff --exit-code
build_and_deploy:
name: Build and deploy
needs: code_check
runs-on: ubuntu-latest
steps:
- name: Check out code
uses: actions/checkout@v4
- name: Setup node
uses: actions/setup-node@v4
with:
node-version: 20
cache: "npm"
cache-dependency-path: |
shared/package-lock.json
hosting/package-lock.json
functions/package-lock.json
- name: Cache build
uses: actions/cache@v4
with:
path: |
hosting/.next/cache
# Generate a new cache whenever packages or source files change.
key: ${{ runner.os }}-nextjs-${{ hashFiles('**/package-lock.json') }}-${{ hashFiles('**/*.js', '**/*.jsx', '**/*.ts', '**/*.tsx') }}
# If source files changed but packages didn't, rebuild from a prior cache.
restore-keys: |
${{ runner.os }}-nextjs-${{ hashFiles('**/package-lock.json') }}-
- name: Set hosting environment
run: echo $HOSTING_ENV > hosting/.env
- name: Build shared code
run: npm ci && npm run build
working-directory: ./shared
- name: Build functions code
run: npm ci && npm run build
working-directory: ./functions
- name: Build web application
run: npm ci && npm run build
working-directory: ./hosting
- name: Deploy to Firebase
uses: w9jds/firebase-action@master
with:
args: deploy -m "Github action run $GITHUB_RUN_ID"
env:
GCP_SA_KEY: ${{ secrets.FIREBASE_DEPLOY_SA }}
PROJECT_ID: tanam-testing