Update FirebaseDeploy.yml #19
Workflow file for this run
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 Firebase Function, Indexes and Rules | |
on: | |
push: | |
jobs: | |
deploy: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout Repository | |
uses: actions/checkout@v4 | |
- name: Setup Node.js | |
uses: actions/setup-node@v4 | |
with: | |
node-version: 20 | |
- name: Cache Dependencies | |
uses: actions/cache@v4 | |
id: cache-dependencies | |
with: | |
path: | | |
~/.npm | |
~/.cache/firebase | |
key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }} | |
restore-keys: | | |
${{ runner.os }}-node- | |
- name: Install Dependencies | |
working-directory: functions | |
run: | | |
npm install | |
- name: Install Firebase CLI | |
run: | | |
npm install -g firebase-tools | |
- name: Authenticate Firebase using the service account | |
env: | |
FIREBASE_PROJECT_ID: ${{ secrets.FIREBASE_PROJECT_ID }} | |
FIREBASE_SERVICE_JSON: ${{ secrets.FIREBASE_SERVICE_JSON }} | |
run: | | |
echo $FIREBASE_SERVICE_JSON | base64 --decode > firebase-service-account.json | |
export GOOGLE_APPLICATION_CREDENTIALS=$(pwd)/firebase-service-account.json | |
# firebase use --add $FIREBASE_PROJECT_ID --token "$(firebase login:ci --key-file=firebase-service-account.json)" | |
# firebase auth:activate-service-account --key-file=firebase-service-account.json | |
# firebase --project $FIREBASE_PROJECT_ID projects:list | |
- name: Deploy Firestore Rules and Indexes | |
env: | |
FIREBASE_TOKEN: ${{ secrets.FIREBASE_TOKEN }} | |
FIREBASE_PROJECT_ID: ${{ secrets.FIREBASE_PROJECT_ID }} | |
run: | | |
firebase deploy --only firestore:rules,firestore:indexes --token ${{ secrets.FIREBASE_TOKEN }} --project $FIREBASE_PROJECT_ID | |
- name: Deploy Cloud Functions | |
env: | |
FIREBASE_TOKEN: ${{ secrets.FIREBASE_TOKEN }} | |
FIREBASE_PROJECT_ID: ${{ secrets.FIREBASE_PROJECT_ID }} | |
run: | | |
cd functions | |
firebase deploy --only functions --token ${{ secrets.FIREBASE_TOKEN }} --project $FIREBASE_PROJECT_ID |