Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG] Cannot Deploy Angular App To Firebase Hosting #283

Open
lisk8 opened this issue May 7, 2023 · 2 comments
Open

[BUG] Cannot Deploy Angular App To Firebase Hosting #283

lisk8 opened this issue May 7, 2023 · 2 comments
Labels
bug Something isn't working

Comments

@lisk8
Copy link

lisk8 commented May 7, 2023

Hello,

I can't deploy my Angular application either by CI/CD or CLI command.
This worked a while and after a while it started showing the error...

The angular application runs without any errors when serving it.

Action config

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: npm i && npm run build
      - uses: FirebaseExtended/action-hosting-deploy@v0
        with:
          repoToken: '${{ secrets.GITHUB_TOKEN }}'
          firebaseServiceAccount: '${{ secrets.FIREBASE_SERVICE_ACCOUNT_MY_HOSTING }}'
          channelId: live
          projectId: my-hosting
        env: 
          FIREBASE_CLI_EXPERIMENTS: webframeworks

or

firebase deploy --only hosting

Error message

Error
    at scheduleTarget (C:\Users\user\AppData\Roaming\nvm\v18.15.0\node_modules\firebase-tools\lib\frameworks\angular\index.js:51:19)
    at async build (C:\Users\user\AppData\Roaming\nvm\v18.15.0\node_modules\firebase-tools\lib\frameworks\angular\index.js:64:9)
    at async prepareFrameworks (C:\Users\user\AppData\Roaming\nvm\v18.15.0\node_modules\firebase-tools\lib\frameworks\index.js:193:108)
    at async deploy (C:\Users\user\AppData\Roaming\nvm\v18.15.0\node_modules\firebase-tools\lib\deploy\index.js:55:13)
@lisk8 lisk8 added the bug Something isn't working label May 7, 2023
@JuHue
Copy link

JuHue commented May 30, 2023

Hi, I got the same errors as you. Here it is my workflow:

name: Deploy to Firebase Hosting on merge
'on':
  push:
    branches:
      - main

jobs:     
  build_and_deploy:
    name: Build then deploy to Firebase Hosting
    runs-on: ubuntu-latest
    steps:
      - name: Checkout Git Repo
        uses: actions/checkout@v3
      - name: Use Node.js 20.1.0
        uses: actions/setup-node@v3
        with:
          node-version: 20.1.0
      - name: npm install, build
        run: |
          npm install
          npm run build
      - name: Install Firebase CLI
        run: |  
          npm install -g firebase-tools
          firebase --version
      - name: Deploy to Firebase
        run: |
          echo '${{secrets.FIREBASE_SERVICE_ACCOUNT}}' > $HOME/gcloud-service-key.json
          export GOOGLE_APPLICATION_CREDENTIALS="$HOME/gcloud-service-key.json"
          firebase deploy --only hosting

and if you are building a SPA, make sure that your firebase.json file look like this:

{
  "hosting": {
    "public": "dist/your-app-name",
    "ignore": [
      "firebase.json",
      "**/.*",
      "**/node_modules/**"
    ],
    "frameworksBackend": {
      "region": "europe-west1"
    },
    "rewrites": [
      {
        "source": "**",
        "destination": "/index.html"
      }
    ]
  }
}

@janet-dev
Copy link

Thank you @JuHue this solution helped me too with my Angular 17 app. I use your code up until & incl.
- name: Deploy to Firebase
Merge workflow now works.
Thank you @lisk8 for posting the issue - discussions like this help beginners like me.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants