Merge pull request #173 from CheckMateSG/develop #56
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: Deploy Cloud Functions | |
on: | |
workflow_dispatch: | |
push: | |
branches: | |
- main | |
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: | | |
echo "${{ secrets.ENV_FILE }}" > .env | |
working-directory: functions | |
- name: Build Cloud Functions | |
run: npm ci | |
working-directory: functions | |
- name: Create SA key | |
run: echo '${{ secrets.FIREBASE_SERVICE_ACCOUNT }}' > $HOME/gcloud.json | |
- name: Install Firebase CLI | |
run: npm install -g firebase-tools | |
- name: Deploy Cloud Functions | |
run: export GOOGLE_APPLICATION_CREDENTIALS=$HOME/gcloud.json && npm run deploy | |
working-directory: functions |