change fb tools version in ci #10
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: Test and deploy cloud functions to firebase | |
on: | |
push: | |
branches: | |
- main | |
concurrency: | |
group: '${{ github.workflow }} @ ${{ github.ref }}' | |
cancel-in-progress: true | |
env: | |
NODE_VERSION: 22 | |
TOKEN_FOR_WORKFLOW: ${{ secrets.TOKEN_FOR_WORKFLOW }} | |
FIREBASE_PROJECT: 'production' | |
GOOGLE_APPLICATION_CREDENTIALS: ${{ github.workspace }}/firebase/functions/accounts/production.json | |
BRANCH: 'main' | |
FIREBASE_PARENT_REPO: 'dudko-dev/firebase-template' | |
FIREBASE_PARENT_BRANCH: 'main' | |
jobs: | |
test-and-deploy: | |
name: Test and deploy cloud functions to firebase | |
runs-on: ubuntu-latest | |
timeout-minutes: 30 | |
env: | |
ENVKEY: ${{ secrets.ENVKEY }} | |
steps: | |
- name: Сheckout firebase repo (${{ env.FIREBASE_PARENT_REPO }}) | |
uses: actions/checkout@v4 | |
with: | |
repository: ${{ env.FIREBASE_PARENT_REPO }} | |
ref: refs/heads/${{ env.FIREBASE_PARENT_BRANCH }} | |
token: ${{ env.TOKEN_FOR_WORKFLOW }} | |
path: 'firebase' | |
persist-credentials: false | |
- name: Сheckout functions repo (${{ github.repository }}) | |
uses: actions/checkout@v4 | |
with: | |
repository: ${{ github.repository }} | |
ref: ${{ github.ref }} | |
path: 'firebase/functions' | |
persist-credentials: false | |
- name: Change mode directory | |
run: chmod 0766 -R firebase | |
working-directory: ${{ github.workspace }} | |
- name: Install node | |
uses: actions/setup-node@v4 | |
with: | |
node-version: ${{ env.NODE_VERSION }} | |
- name: Cache node modules | |
uses: actions/cache@v4 | |
env: | |
cache-name: cache-node-modules | |
with: | |
path: ~/.npm | |
key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('**/package-lock.json') }} | |
restore-keys: | | |
${{ runner.os }}-build-${{ env.cache-name }}- | |
${{ runner.os }}-build- | |
${{ runner.os }}- | |
- name: Install test & build dependencies | |
run: sudo npm install firebase-tools -g | |
working-directory: ${{ github.workspace }}/firebase/functions | |
- name: Install dependencies | |
run: npm ci | |
working-directory: ${{ github.workspace }}/firebase/functions | |
- name: Export envkey to file | |
run: echo "$ENVKEY">./.envkey | |
working-directory: ${{ github.workspace }}/firebase/functions | |
- name: Decrypt env and accounts files | |
run: npm run decrypt | |
working-directory: ${{ github.workspace }}/firebase/functions | |
- name: Run lint | |
run: npm run lint | |
working-directory: ${{ github.workspace }}/firebase/functions | |
- name: Run build | |
run: npm run build | |
working-directory: ${{ github.workspace }}/firebase/functions | |
- name: Select firebase project | |
run: firebase use $FIREBASE_PROJECT | |
working-directory: ${{ github.workspace }}/firebase/functions | |
- name: run cov | |
if: ${{ env.FIREBASE_PROJECT != 'production' }} | |
run: npm run cov | |
working-directory: ${{ github.workspace }}/firebase/functions | |
- name: deploy to firebase | |
if: ${{ env.FIREBASE_PROJECT != 'development' || env.BRANCH == 'development' }} | |
run: firebase deploy -m "Autodeploy from GitHUB ($GITHUB_ACTOR)" --only functions --force | |
working-directory: ${{ github.workspace }}/firebase/functions | |
# - name: The job has failed - archive result | |
# if: ${{ failure() }} | |
# run: | | |
# if [[ -d ${{ github.workspace }}/firebase ]]; then | |
# tar -czf firebase.tar.gz firebase; | |
# fi | |
# working-directory: ${{ github.workspace }} | |
# - name: The job has failed - archive npm logs | |
# if: ${{ failure() }} | |
# run: | | |
# if [[ -d /home/runner/.npm/_logs ]]; then | |
# tar -czf ${{ github.workspace }}/npm-logs.tar.gz /home/runner/.npm/_logs; | |
# fi | |
# working-directory: / | |
# - name: The job has failed - upload artifacts | |
# if: ${{ failure() }} | |
# uses: actions/upload-artifact@v4 | |
# with: | |
# name: ${{ env.FIREBASE_PROJECT }}-functions-debug | |
# path: | | |
# ${{ github.workspace }}/firebase.tar.gz | |
# ${{ github.workspace }}/npm-logs.tar.gz | |
# retention-days: 1 |