0

I am trying to upload my angular-meteor project's 'ng build' to S3 Bucket.

This is my .yml file

on:
  push:
    branches:
    - dev

jobs:
  build:

    runs-on: ubuntu-latest
    steps:
    - uses: actions/checkout@v1
    - name: Setup meteor
      uses: meteorengineer/setup-meteor@v1
      with:
        meteor-release: '1.8.1'
    

    - name: Install Node.js
      uses: actions/setup-node@v1
      with:
        node-version: '10.x'

    - name: NG build Angular
      run: ng build --prod

    - name: Deploy to S3
      uses: jakejarvis/s3-sync-action@master
      with:
        args: --acl public-read --delete

      env:
        AWS_S3_BUCKET: ${{ secrets.DEV_AWS_S3_BUCKET }}
        AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
        AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
        AWS_REGION: ${{ secrets.AWS_REGION }}
        SOURCE_DIR: 'browser'

Once I run this, I am receiving this error message for the NG build Angular section

enter image description here

Instead of running ng build --prod i have also tried to run ng build — prod — aot, ng build -- --prod & npm run build -- --prod but Still I am receiving the same error message.

Does anyone know how to solve this problem?

Istiak Mahmood
  • 2,330
  • 8
  • 31
  • 73

2 Answers2

1

By default GitHub runners won't have ng/angular cli. So we got to install it . Below piece of code should do the job for you.

on:
  push:
    branches:
    - dev

jobs:
  build:
    runs-on: ubuntu-latest
    steps:
    - uses: actions/checkout@v1
    - name: Setup meteor
      uses: meteorengineer/setup-meteor@v1
      with:
        meteor-release: '1.8.1'
    - name: Install Node.js
      uses: actions/setup-node@v1
      with:
        node-version: '10.x'

    - name: Install Angular CLI
      run: npm install -g @angular/cli

    - name: NG build Angular
      run: ng build --prod
    - name: Deploy to S3
      uses: jakejarvis/s3-sync-action@master
      with:
        args: --acl public-read --delete
Sam-Sundar
  • 511
  • 1
  • 4
  • 12
  • Thank you for the answer. Now I am receiving this error message - You have to be inside an angular-cli project in order to use the build command. npm ERR! code ELIFECYCLE npm ERR! errno 1 – Istiak Mahmood Aug 01 '21 at 18:50
  • Try replacing `ng install` with below command. `npm install -g @angular/cli@latest` – Sam-Sundar Aug 01 '21 at 18:55
  • thank you sam once again but I am still facing the same issue, see my followup questions - https://stackoverflow.com/questions/68614368/receiving-error-while-try-to-build-angular-build – Istiak Mahmood Aug 01 '21 at 21:09
1

@angular/cli is installed as a devDependency, so you have to use:

- name: NG build Angular
  run: npx ng build --prod

or in Angular 12+

- name: NG build Angular
  run: npx ng build --configuration production
coturiv
  • 2,880
  • 22
  • 39