w9jds / firebase-action

GitHub Action for interacting with Firebase
MIT License
923 stars 198 forks source link

Deploying function fails without error message #134

Closed khromov closed 2 years ago

khromov commented 2 years ago

Recently (in the past month) this action stopped working for us. Running firebase deploy --only=functions works from a local machine. It could be connected to us upgrading functions to run on Node 16 but even after reverting that change it still doesn't deploy. There is no error message but the task exits with an error code and without output.

Log:

2022-05-22T00:00:22.9458047Z ##[group]Pull down action image 'w9jds/firebase-action:v2.1.2'
//...
2022-05-22T00:01:25.4068711Z ##[group]Run w9jds/firebase-action@master
2022-05-22T00:01:25.4069020Z with:
2022-05-22T00:01:25.4069246Z   args: deploy --only functions
2022-05-22T00:01:25.4069490Z env:
2022-05-22T00:01:25.4070139Z   FIREBASE_TOKEN: ***
2022-05-22T00:01:25.4070388Z ##[endgroup]
2022-05-22T00:01:25.4075500Z ##[command]/usr/bin/docker run --name w9jdsfirebaseactionv212_1fe9e7 --label 08450d --workdir /github/workspace --rm -e FIREBASE_TOKEN -e INPUT_ARGS -e HOME -e GITHUB_JOB -e GITHUB_REF -e GITHUB_SHA -e GITHUB_REPOSITORY -e GITHUB_REPOSITORY_OWNER -e GITHUB_RUN_ID -e GITHUB_RUN_NUMBER -e GITHUB_RETENTION_DAYS -e GITHUB_RUN_ATTEMPT -e GITHUB_ACTOR -e GITHUB_WORKFLOW -e GITHUB_HEAD_REF -e GITHUB_BASE_REF -e GITHUB_EVENT_NAME -e GITHUB_SERVER_URL -e GITHUB_API_URL -e GITHUB_GRAPHQL_URL -e GITHUB_REF_NAME -e GITHUB_REF_PROTECTED -e GITHUB_REF_TYPE -e GITHUB_WORKSPACE -e GITHUB_ACTION -e GITHUB_EVENT_PATH -e GITHUB_ACTION_REPOSITORY -e GITHUB_ACTION_REF -e GITHUB_PATH -e GITHUB_ENV -e GITHUB_STEP_SUMMARY -e RUNNER_OS -e RUNNER_ARCH -e RUNNER_NAME -e RUNNER_TOOL_CACHE -e RUNNER_TEMP -e RUNNER_WORKSPACE -e ACTIONS_RUNTIME_URL -e ACTIONS_RUNTIME_TOKEN -e ACTIONS_CACHE_URL -e GITHUB_ACTIONS=true -e CI=true -v "/var/run/docker.sock":"/var/run/docker.sock" -v "/home/runner/work/_temp/_github_home":"/github/home" -v "/home/runner/work/_temp/_github_workflow":"/github/workflow" -v "/home/runner/work/_temp/_runner_file_commands":"/github/file_commands" -v "/home/runner/work/project-svelte/project-svelte":"/github/workspace" w9jds/firebase-action:v2.1.2 deploy --only functions
2022-05-22T00:01:49.3177787Z Post job cleanup.

Workflow file:

# This file was auto-generated by the Firebase CLI
# https://github.com/firebase/firebase-tools

name: Deploy firebase functions and Firestore rules on merge or push to master
'on':
  push:
    branches:
      - master
jobs:
  build_and_deploy:
    runs-on: ubuntu-latest
    steps:
      - name: Checkout Repo
        uses: actions/checkout@v2
      - name: Set the correct Node version using nvm
        shell: bash -l {0} 
        run: cd functions && nvm install && nvm use
      - name: Setup dependencies
        run: |
          cd functions/
          npm ci
          npm run build
      - name: Deploy Firestore rules
        uses: w9jds/firebase-action@master
        with:
          args: deploy --only firestore
        env:
          FIREBASE_TOKEN: ${{ secrets.FIREBASE_TOKEN }}
      - name: Deploy functions
        uses: w9jds/firebase-action@master
        with:
          args: deploy --only functions
        env:
          FIREBASE_TOKEN: ${{ secrets.FIREBASE_TOKEN }}
w9jds commented 2 years ago

This might be related to the action now supporting outputs, it tries to store what the CLI spits out and if it errors out and ends the action before it can echo it this might stop it from printing out the response. Let me try removing this from master and if you want try using the docker option to point to the master image instead. Should give you a real response.

Greg001100 commented 2 years ago

We were having this problem too, functions deployment failing but no error logging. Pointing to the docker master fixed it and we are now getting the logs we need, thanks!

gelouko commented 2 years ago

FWIW: to use the docker options pointed by @w9jds , just change

uses: w9jds/firebase-action@master

to

uses: docker://w9jds/firebase-action:master
mithun-halo commented 2 years ago

@gelouko I tried updating this and running it, and I do get further than before, but it still fails with An unexpected error has occurred

##[debug]Evaluating: secrets.FIREBASE_TOKEN_ACCOUNT_HALO_APP_PROD_<>
##[debug]Evaluating Index:
##[debug]..Evaluating secrets:
##[debug]..=> Object
##[debug]..Evaluating String:
##[debug]..=> 'FIREBASE_TOKEN_ACCOUNT_HALO_APP_PROD_<>'
##[debug]=> '***'
##[debug]Result: '***'
##[debug]Evaluating condition for step: 'Deploy to Firebase'
##[debug]Evaluating: success()
##[debug]Evaluating success:
##[debug]=> true
##[debug]Result: true
##[debug]Starting: Deploy to Firebase
##[debug]Loading inputs
##[debug]Loading env
Run docker://w9jds/firebase-action:master
/usr/bin/docker run --name w9jdsfirebaseactionmaster_5944[2](https://github.com/urbanrobo/app/runs/6629626694?check_suite_focus=true#step:8:2)b --label 08[4](https://github.com/urbanrobo/app/runs/6629626694?check_suite_focus=true#step:8:4)[5](https://github.com/urbanrobo/app/runs/6629626694?check_suite_focus=true#step:8:5)0d --workdir /github/workspace --rm -e FIREBASE_TOKEN -e PROJECT_ID -e INPUT_ARGS -e HOME -e GITHUB_JOB -e GITHUB_REF -e GITHUB_SHA -e GITHUB_REPOSITORY -e GITHUB_REPOSITORY_OWNER -e GITHUB_RUN_ID -e GITHUB_RUN_NUMBER -e GITHUB_RETENTION_DAYS -e GITHUB_RUN_ATTEMPT -e GITHUB_ACTOR -e GITHUB_WORKFLOW -e GITHUB_HEAD_REF -e GITHUB_BASE_REF -e GITHUB_EVENT_NAME -e GITHUB_SERVER_URL -e GITHUB_API_URL -e GITHUB_GRAPHQL_URL -e GITHUB_REF_NAME -e GITHUB_REF_PROTECTED -e GITHUB_REF_TYPE -e GITHUB_WORKSPACE -e GITHUB_ACTION -e GITHUB_EVENT_PATH -e GITHUB_ACTION_REPOSITORY -e GITHUB_ACTION_REF -e GITHUB_PATH -e GITHUB_ENV -e GITHUB_STEP_SUMMARY -e RUNNER_DEBUG -e RUNNER_OS -e RUNNER_ARCH -e RUNNER_NAME -e RUNNER_TOOL_CACHE -e RUNNER_TEMP -e RUNNER_WORKSPACE -e ACTIONS_RUNTIME_URL -e ACTIONS_RUNTIME_TOKEN -e ACTIONS_CACHE_URL -e GITHUB_ACTIONS=true -e CI=true -v "/var/run/docker.sock":"/var/run/docker.sock" -v "/home/runner/work/_temp/_github_home":"/github/home" -v "/home/runner/work/_temp/_github_workflow":"/github/workflow" -v "/home/runner/work/_temp/_runner_file_commands":"/github/file_commands" -v "/home/runner/work/app/app":"/github/workspace" w9jds/firebase-action:master deploy -f
setting firebase project to halo-app-prod-<>
Now using project halo-app-prod-<>

=== Deploying to 'halo-app-prod-<>'...

i  deploying database, storage, firestore, functions, hosting, remoteconfig
Running command: yarn workspace @urbanrobo/functions bundle

  bundled/index.js       7.[6](https://github.com/urbanrobo/app/runs/6629626694?check_suite_focus=true#step:8:6)mb ⚠️
  bundled/index.js.map  26.5mb

⚡ Done in 1446ms
Running command: mv packages/functions/package.bundle.json packages/functions/package.json
✔  functions: Finished running predeploy script.
i  database: checking rules syntax...
✔  database: rules syntax for database halo-app-prod-<>-default-rtdb is valid
i  firebase.storage: checking storage.rules for compilation errors...
✔  firebase.storage: rules file storage.rules compiled successfully
i  firestore: reading indexes from firestore.indexes.json...
i  cloud.firestore: checking firestore.rules for compilation errors...
⚠  [W] [8](https://github.com/urbanrobo/app/runs/6629626694?check_suite_focus=true#step:8:8):14 - Unused function: isSignedIn.
⚠  [W] [9](https://github.com/urbanrobo/app/runs/6629626694?check_suite_focus=true#step:8:9):[14](https://github.com/urbanrobo/app/runs/6629626694?check_suite_focus=true#step:8:14) - Invalid variable name: request.
✔  cloud.firestore: rules file firestore.rules compiled successfully
i  functions: ensuring required API cloudfunctions.googleapis.com is enabled...
i  functions: ensuring required API cloudbuild.googleapis.com is enabled...
✔  functions: required API cloudbuild.googleapis.com is enabled
✔  functions: required API cloudfunctions.googleapis.com is enabled
i  functions: preparing codebase default for deployment

Error: An unexpected error has occurred.
##[debug]Docker Action run completed with exit code 2
##[debug]Finishing: Deploy to Firebase

Could it be that I'm trying to deploy to alias prod? What does codebase default mean? That didn't show up in the non-dockerized tool

khromov commented 2 years ago

@w9jds Tried to point to master or even the exact commit hash of your fix but still no logs. Noticed that the command itself still refers to v2.1.2 of the action, even though it's fetching the latest commit:

2022-05-29T21:17:56.7224198Z ##[group]Run w9jds/firebase-action@1e278621b8467eff7eb0248e275bef80e85360df
2022-05-29T21:17:56.7224486Z with:
2022-05-29T21:17:56.7224682Z   args: deploy --only functions
2022-05-29T21:17:56.7224881Z env:
2022-05-29T21:17:56.7225425Z   FIREBASE_TOKEN: ***
2022-05-29T21:17:56.7225632Z ##[endgroup]
2022-05-29T21:17:56.7229869Z ##[command]/usr/bin/docker run --name w9jdsfirebaseactionv212_360f88 --label 08450d --workdir /github/workspace --rm -e FIREBASE_TOKEN -e INPUT_ARGS -e HOME -e GITHUB_JOB -e GITHUB_REF -e GITHUB_SHA -e GITHUB_REPOSITORY -e GITHUB_REPOSITORY_OWNER -e GITHUB_RUN_ID -e GITHUB_RUN_NUMBER -e GITHUB_RETENTION_DAYS -e GITHUB_RUN_ATTEMPT -e GITHUB_ACTOR -e GITHUB_WORKFLOW -e GITHUB_HEAD_REF -e GITHUB_BASE_REF -e GITHUB_EVENT_NAME -e GITHUB_SERVER_URL -e GITHUB_API_URL -e GITHUB_GRAPHQL_URL -e GITHUB_REF_NAME -e GITHUB_REF_PROTECTED -e GITHUB_REF_TYPE -e GITHUB_WORKSPACE -e GITHUB_ACTION -e GITHUB_EVENT_PATH -e GITHUB_ACTION_REPOSITORY -e GITHUB_ACTION_REF -e GITHUB_PATH -e GITHUB_ENV -e GITHUB_STEP_SUMMARY -e RUNNER_OS -e RUNNER_ARCH -e RUNNER_NAME -e RUNNER_TOOL_CACHE -e RUNNER_TEMP -e RUNNER_WORKSPACE -e ACTIONS_RUNTIME_URL -e ACTIONS_RUNTIME_TOKEN -e ACTIONS_CACHE_URL -e GITHUB_ACTIONS=true -e CI=true -v "/var/run/docker.sock":"/var/run/docker.sock" -v "/home/runner/work/_temp/_github_home":"/github/home" -v "/home/runner/work/_temp/_github_workflow":"/github/workflow" -v "/home/runner/work/_temp/_runner_file_commands":"/github/file_commands" -v "/home/runner/work/project/project":"/github/workspace" w9jds/firebase-action:v2.1.2 deploy --only functions
2022-05-29T21:18:18.0081320Z Post job cleanup.

I did try to use docker://w9jds/firebase-action:master as @gelouko suggested and that gave me the root cause of my issue, I had removed a function from the code and the action wouldn't proceed:

Error: The following functions are found in your project but do not exist in your local source code:
    newUserV2(europe-west1)

But it still seems like no logs are shown if you're not using 🐋 Docker.

w9jds commented 2 years ago

Both technically use docker, using the docker image directly above just points to the code currently in master branch instead of what is currently in the latest release. Latest release tries to take the output of the command and return it as an output for the action, where I disabled the functionality on master so you can properly get your logs.

That error doesn't look related to the action though, that looks like either code is missing in your pipeline or deployment is expecting a configured function that is missing.

khromov commented 2 years ago

@w9jds Great, understood. ⭐ In my specific case I had removed a function that existed in production and that is why the action bailed (which is sane behaviour). I can also confirm that switching to the Docker version on master works and produces output, so I guess the issue is that the error is not sent to the output properly in the latest tagged version.

actuallymentor commented 2 years ago

@w9jds could you please revert to the previous behaviour. It is extremely frustrating to have errorless fails and to have to edit the action ymls to find out what is wrong :)

otech47 commented 2 years ago

Changing the version to v2.1.0 should get the errors to appear

Screen Shot 2022-06-09 at 8 14 21 PM

w9jds commented 2 years ago

This should be fixed (without removing the outputs) with v2.2.0

actuallymentor commented 2 years ago

This should be fixed (without removing the outputs) with v2.2.0

@w9jds I'm still experiencing the issue, is v2.2.0 rolled out yet?

john-s-morgan commented 2 years ago

I just ran a quick POC and it seems like the shell is returning 0 regardless of what firebase is saying should be the exit code. Threw up a PR to address this.