s3-sync-action
s3-sync-action copied to clipboard
Use environment variables instead of CLI profiles
In #1, it's discussed that the action should be using profiles to prevent stomping on other AWS actions which are used by the repo.
However, in the AWS CLI documentation, it's mentioned that the CLI supports certain environment variables natively. This includes authentication-related variables such as AWS_ACCESS_KEY_ID
/AWS_SECRET_ACCESS_KEY
/AWS_SESSION_TOKEN
.
Any reason we're not relying on these instead?
AWS publish an action to set up authentication credentials, you can rely on that and remove all profile/key related code:
- 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
- uses: jakejarvis/s3-sync-action@master
with:
args: --acl public-read --follow-symlinks --delete
env:
AWS_S3_BUCKET: ${{ secrets.AWS_S3_BUCKET }}
SOURCE_DIR: 'public' # optional: defaults to entire repository
Not sure why all of this is present then:
https://github.com/jakejarvis/s3-sync-action/blob/master/entrypoint.sh#L30-L38
https://github.com/jakejarvis/s3-sync-action/blob/master/entrypoint.sh#L47-L56
Seems like that can all be gone when we use the configure-aws-credentials action?
Which then begs the question, why not remain with just this :)
- 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: Deploy static site to S3 bucket
run: aws s3 sync ./dist/ s3://<your-website-bucket> --delete
Just verified, this works perfectly:
- name: Configure AWS credentials
if: github.ref == 'refs/heads/master'
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: eu-west-3
- name: Deploy to S3
if: github.ref == 'refs/heads/master'
shell: bash
run: aws s3 sync ./dist/ s3://$AWS_S3_BUCKET --acl public-read --follow-symlinks --delete
env:
AWS_S3_BUCKET: ${{ secrets.AWS_S3_BUCKET }}
great! awscli wasn't installed on the runners originally
Just verified, this works perfectly:
- name: Configure AWS credentials if: github.ref == 'refs/heads/master' 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: eu-west-3 - name: Deploy to S3 if: github.ref == 'refs/heads/master' shell: bash run: aws s3 sync ./dist/ s3://$AWS_S3_BUCKET --acl public-read --follow-symlinks --delete env: AWS_S3_BUCKET: ${{ secrets.AWS_S3_BUCKET }}
but this just rendered this repo useless ๐