Merge pull request #190 from CheckMateSG/feature/image-caveat #59
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 | |
- 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 | |
firebase deploy --only functions --project checkmate-373101 | |
else | |
firebase deploy --only functions --project checkmate-uat | |
fi | |
working-directory: functions |