Reggionick / s3-deploy

Easily deploy a static website to AWS S3 and invalidate CloudFront distribution
MIT License
242 stars 84 forks source link

Issue with folder option? #63

Open seadeep42 opened 2 years ago

seadeep42 commented 2 years ago

Hi,

I have a monorepo setup with the folder at packages/dashboard/build. But it seems to be deploying packages/dashboard for some reason since yesterday. And I haven't updated anything in the past few days

Reggionick commented 2 years ago

Which version are you using?

seadeep42 commented 2 years ago

Thank you for the quick response.

reggionick/s3-deploy@v3

Reggionick commented 2 years ago

We haven't made any change on the v3 of the action. Could you double check on your side?

callum-hyland commented 2 years ago

Same issue for me, no code changed in the action for months but randomly it's started pushing the root folder. Could be an internal Github change?

- name: Deploy
        uses: reggionick/s3-deploy@v3
        with:
          folder: ./interface/build

Screenshot 2022-04-08 at 09 50 34

ajainvivek commented 2 years ago

Same issue for me. no code changes pushing the root folder.

ajainvivek commented 2 years ago

@Reggionick Any updates on this issue?

Reggionick commented 2 years ago

No, I can't work on this right now.. But any PR is welcome!

palashkaria commented 2 years ago

This caused our prod dashboard to go down, we have migrated away from using GH actions to amplify for this reason. Would recommend anyone else using this to pin the version that works. Update: looks like it's not even a version issue; The code has had no changes for months, but our builds worked on 31st March, broke on 14th April. That's odd, and I'm unable to figure out what actually happened

seadeep42 commented 2 years ago

I'm not sure if this is the cause but in my case, the only change I notice is the Github job runner version change from 2.289.1 to 2.289.2. It's currently at version 2.290.1 but the issue seems to persist

Screenshot 2022-04-18 at 7 12 53 PM
tanmoyAtb commented 2 years ago

Same issue here. We had to move to manual deploys for the time being.

seadeep42 commented 2 years ago

Hi,

For anyone else who came across this. I couldn't solve it with the action but found an alternate to fix it. Edited my action yml file to replace this with aws cli.

      - 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: ${{ secrets.AWS_REGION }}

      - name: Deploy dashboard to bucket
        run: aws s3 sync ./packages/dashboard/build s3://<bucket-name>/<folder-path>/

      - name: Invalidate dashboard cloudfront
        run: aws cloudfront create-invalidation --distribution-id <dist-id> --paths "/<invalidation-path>/*"
Akuukis commented 1 year ago

The root cause

In simplified form, this library calls npx --cwd ./ via exec.exec(command, [], { cwd }), where's npx "walks" upwards to first package.json and uses that folder as cwd instead, partially ignoring the set cwd within exec. For a reason the upstream docs mention setting cwd: s3-deploy './dist/**' --cwd './dist/' ....

See also https://github.com/npm/cli/issues/1975

Solution

don't use npx or don't hardcode npx --cwd ./.

Workaround

None I can think of, use either upstream instead or aws cli directly as in the comment above.