duaneleem
1/20/2018 - 6:00 AM

Buildspec Example for AWS CodeBuild

Example buildspec.yaml file that is typically used for a Angular Firebase app.

post_build deploys the /dist output to Firebase.

version: 0.2

env:
    variables:
        BUILD_ENV: "prod"
    parameter-store:
        FIREBASE_TOKEN: "/RandomFolderName/some_token"
            
phases:
    install:
        commands:
        - echo Installing source NPM dependencies...
        # Need https driver.
        - sudo apt-get update -y
        - sudo apt-get install -y apt-transport-https
        # Install: Angular CLI
        - npm install -g @angular/cli@latest
        # Install: Firebase CLI
        - npm install -g firebase-tools
        # Install node dependancies.
        - npm install
    build:
        commands:
        # Builds Angular application.
        - echo Build started on `date`
        - ng build --$BUILD_ENV
    post_build:
        commands:
        # Update Firebase.
        - echo Deploying to Firebase.
        - firebase deploy --token "$FIREBASE_TOKEN" --only hosting
artifacts:
    files:
        - '**/*'
    base-directory: 'dist*'
    discard-paths: yes