skip to Main Content

I have written a yaml script with a help of a blog that contains all the necessary work that needs to be carried out in order to deploy my application to an ec2 instance running ubuntu. NGINX has been installed and is running.
Unfortunately, my yaml script fails silently, I do not know what is wrong, here is the code that’s in the script

name: CI

on:
  push:
    branches: [main]
  pull_request: 
    branches: [main]

jobs:
  build:
    # using Ubuntu
    runs-on: ubuntu-latest
    defaults:
      run:
        working-directory: ./
    steps:
      - uses: actions/checkout@v3
      - uses: actions/setup-node@v3
        with:
          node-version: "18.x"

      - name: Run install
        uses: borales/actions-yarn@v4 
        with:
          cmd: install
      - name: Install Angular CLI
        uses: borales/actions-yarn@v4
        with:
          cmd: yarn global add @angular/cli
      - name: Build production bundle
        uses: borales/actions-yarn@v4
        with:
          cmd: build:prod # will run `yarn build:prod` command

      - name: Deploy to my EC2 instance
        uses: easingthems/ssh/[email protected]
        with: 
          SSH_PRIVATE_KEY: $ {{ secrets.SSH_PRIVATE_KEY }} # I have the SSH_Private key of the instance saved as secrets in GitHub under the repository settings.
          SOURCE: "dist/my-client-app"
          REMOTE_HOST: "my-remote-host" # here I used my instances's IP Address. Not sure if that is what I am supposed to put there.
          REMOTE_USER: "ubuntu"
          TARGET: "/var/www/html/my-client-app"

Can anyone point out what could be the issue here?

2

Answers


  1. Chosen as BEST ANSWER

    I just wanted to let you know that I ended up using Amplify, which was a lot easier. At the end non of the recommended answers worked. The linux ubuntu EC2 was still giving me issues. It escalated to ng build not found but the environment had everything set so yaa.


  2. this is an example of workflow that build, test and deploy angular app to AWS S3:

    jobs:
      build-test-deploy:
        runs-on: ubuntu-latest
        steps:
        - name: Configure AWS Credentials
          uses: aws-actions/configure-aws-credentials@v1
          with:
            aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
            aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
            aws-region: us-east-1
    
        - name: Checkout
          uses: actions/checkout@v3
    
        - name: Setup Node.js
          uses: actions/setup-node@v3
          with:
            node-version: 16
    
        - name: Install dependencies
          run: npm install
    
        - name: test # this section runs tests
          run: npm run test
    
        - name: Build
          run: npm run build
    
        - name: Deploy
          if: success()
          run: aws s3 sync ./dist/app/ s3://your-bucket-name
    
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search