Skip to content

Instantly share code, notes, and snippets.

@DawidvanGraan
Last active February 25, 2020 22:50
Show Gist options
  • Star 9 You must be signed in to star a gist
  • Fork 3 You must be signed in to fork a gist
  • Save DawidvanGraan/d87b83ea2b8027e208c5168145ff1df5 to your computer and use it in GitHub Desktop.
Save DawidvanGraan/d87b83ea2b8027e208c5168145ff1df5 to your computer and use it in GitHub Desktop.
Deploy your Angular 2 project with Bitbucket Pipelines to Firebase Hosting

Deploy your Angular 2 project with Bitbucket Pipelines to Firebase Hosting

Firebase

Please see the Firebase setup instruction to setup a project on Firebase.

Firebase CI Token

To run the firebase deploy command you need to obtain a login token from Firebase. To do so, run the firebase login:ci on your command line which will generate a token. Copy the generated token.

Environment Variables

Goto your project in Bitbucket, open the Settings and select Environment variables. Create a new variable with FIREBASE_TOKEN as the key and paste in the token as the value. Save the configuration.

Pipelines file

Create a bitbucket-pipelines.yml in branch you want to deploy.

image: node:7.4.0

pipelines:
  default:
    - step:
        script:
          - npm install -g @angular/cli
          - npm install -g firebase-tools
          - npm install
          - ng build --env=prod
          - firebase deploy --only hosting --token "$FIREBASE_TOKEN"

Deploy

After a commit on your branch, the pipeline with deploy your changes to Firebase.

@LarryCodes
Copy link

Ok thats understood if I want to deploy to Firebase. Here is a scenario where I want to deploy the project to a shared hosting service, how can I go about that?

@okevese
Copy link

okevese commented Jun 7, 2018

@alexejkornilov
Copy link

Strange problem in firebase.json:

{
  "hosting": {
    "public": "dist",
    ...
  }
}

but in pipe failed result "Error: Specified public directory does not exist, can't deploy hosting"

@woeterman94
Copy link

Use ng build --prod

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment