Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Couldn't find a package.json file when setting up Github actions for Firebase Hosting

When initializing github actions for firebase hosting i specified the following:

Set up the workflow to run a build script before every deploy? Yes What script should be run before every deploy? yarn run build.

This workflow gives me the error

Run yarn run build
yarn run v1.22.10
error Couldn't find a package.json file in "/home/runner/work/SpaceBar/SpaceBar"
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
Error: Process completed with exit code 1.

I have a package.json file in my project directory. Why is it saying that it cannot find it?

firebase-hosting-merge.yml is in the directory called spacebar, which contains another directory called spacebar containing the package.json file. Is there anyway to cd into the sub directory in this file

name: Deploy to Firebase Hosting on merge
'on':
  push:
    branches:
      - main
jobs:
  build_and_deploy:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v2
      - run: yarn run build
      - uses: FirebaseExtended/action-hosting-deploy@v0
like image 455
ryantan Avatar asked Sep 01 '25 04:09

ryantan


1 Answers

As the actions/checkout action gave you access to the repository files and directories, you can just cd into the directory where the package.json file is located before executing the yarn command. Otherwise, it will only look for it at the repository root.

Example (for your second step)

run: |
   cd spacebar/spacebar
   yarn run build
like image 73
GuiFalourd Avatar answered Sep 02 '25 19:09

GuiFalourd