Skip to content

Merge pull request #196 from CheckMateSG/feat/batch-Jobs-V2-upgrade #65

Merge pull request #196 from CheckMateSG/feat/batch-Jobs-V2-upgrade

Merge pull request #196 from CheckMateSG/feat/batch-Jobs-V2-upgrade #65

name: Deploy Cloud Functions
on:
workflow_dispatch:
push:
branches:
- main
- develop
paths:
- "functions/**"
jobs:
build_and_deploy:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
with:
node-version: 18.x
- uses: actions/cache@v3
with:
path: ~/.npm
key: ${{ runner.os }}-node-${{ hashFiles('**/functions/package-lock.json') }}
restore-keys: |
${{ runner.os }}-node-
- name: Create env file
run: |
if [ "${{ github.ref }}" == "refs/heads/main" ]; then
echo "${{ secrets.ENV_FILE }}" > .env
else
echo "${{ secrets.ENV_FILE_NONPROD }}" > .env
fi
working-directory: functions
- name: Build Cloud Functions
run: npm ci
working-directory: functions
- name: Create SA key
run: |
if [ "${{ github.ref }}" == "refs/heads/main" ]; then
echo '${{ secrets.FIREBASE_SERVICE_ACCOUNT }}' > $HOME/gcloud.json
else
echo '${{ secrets.FIREBASE_SERVICE_ACCOUNT_NONPROD }}' > $HOME/gcloud.json
fi
- name: Install Firebase CLI
run: npm install -g firebase-tools
- name: Deploy Cloud Functions
run: |
export GOOGLE_APPLICATION_CREDENTIALS=$HOME/gcloud.json
if [ "${{ github.ref }}" == "refs/heads/main" ]; then
npm run deploy -- --project checkmate-373101
else
npm run deploy -- --project checkmate-uat
fi
working-directory: functions