Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Deploy to AWS S3 sync with github

I am trying to deploy static site to AWS S3 and Cloudfront with github action. My Github Action code is:

name: deploy-container

on:
  push:
    branches:
      - master
    paths:
      - 'packages/container/**'

defaults:
  run:
    working-directory: packages/container

jobs:
  build:
    runs-on: ubuntu-latest

    steps:
      - uses: actions/checkout@v2
      - run: npm install
      - run: npm run build

      - uses: chrislennon/[email protected]
      - run: aws s3 sync dist s3://${{secrets.AWS_S3_BUCKET_NAME}}/container/latest
        env:
          AWS_ACCESS_KEY_ID: ${{secrets.AWS_ACCESS_KEY_ID}}
          AWS_SECRET_ACCESS_KEY: ${{secrets.AWS_SECRET_ACCESS_KEY}}

But when I try to build I got these errors

Github Actions 1 Github Actions 2

like image 549
Md Aktarul Islam Avatar asked Mar 21 '26 17:03

Md Aktarul Islam


2 Answers

GitHub will redeploy your application only if you did some change on a file inside of your application directory. I suppose that you have changed only your yml file and tried to rerun the job on GitHub. But from the error message, this is an unsecure method to use the tag ACTIONS_ALLOW_UNSECURE_COMMANDS. It is best to consider using the Official AWS for GitHub Actions instead of using the ACTIONS_ALLOW_UNSECURE_COMMANDS.

name: deploy-container

on:
  push:
    branches:
      - master
    paths:
      - 'packages/container/**'

defaults:
  run:
    working-directory: packages/container

jobs:
  build:
    runs-on: ubuntu-latest

    steps:
      - uses: actions/checkout@v2
      - run: npm install
      - run: npm run build

      - 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-west-1

      - name: Copy files to the s3 website content bucket
        run:
          aws s3 sync dist s3://${{ secrets.AWS_S3_BUCKET_NAME }}/container/latest
like image 68
Luiz Augusto Avatar answered Mar 23 '26 09:03

Luiz Augusto


jobs:
  build:
    runs-on: ubuntu-latest

    steps:
      - uses: actions/checkout@v2
      - run: npm install
      - run: npm run build

      - uses: chrislennon/[email protected]
        env:
          ACTIONS_ALLOW_UNSECURE_COMMANDS: 'true'
like image 39
Amol Pawar Avatar answered Mar 23 '26 10:03

Amol Pawar



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!