Merge pull request #421 from bettersg/develop #180
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/**" | |
- "checkers-app/**" | |
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: Build checkers-app | |
run: npm ci | |
working-directory: checkers-app | |
- 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:prod | |
else | |
npm run deploy:uat | |
fi |