name: 'Usage of s3-sync-action GitHub Action'
on:
push:
branches:
- main
jobs:
deploy:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: jakejarvis/s3-sync-action@master
with:
args: --acl public-read --follow-symlinks --delete
env:
AWS_S3_BUCKET: ${{ secrets.AWS_S3_BUCKET }}
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
AWS_REGION: 'us-west-1' # optional: defaults to us-east-1
SOURCE_DIR: 'public' # optional: defaults to entire repository
S3 Sync Action
GitHub Action to sync a directory with a remote S3 bucket 🧺
What is s3-sync-action?
To streamline our deployment and backup processes, leveraging GitHub Actions to synchronize our directories with AWS S3 buckets can significantly enhance efficiency. This simple GitHub Action uses basic AWS CLI commands to sync a directory from our repository—or one generated during our workflow—with a specified S3 bucket.
How to Specify AWS Region
Define the AWS region where your S3 bucket is located. This is crucial for the AWS CLI to route requests to the correct regional endpoint.
- uses: jakejarvis/s3-sync-action@master
with:
args: --acl public-read --follow-symlinks --delete
env:
AWS_REGION: 'us-east-1'
How to Configure AWS S3 Endpoint
Customize the endpoint URL, especially useful for VPC scenarios or when using non-AWS services that are compatible with the S3 API, such as DigitalOcean Spaces.
- uses: jakejarvis/s3-sync-action@master
with:
args: --acl public-read --follow-symlinks --delete
env:
AWS_S3_ENDPOINT: 's3.amazonaws.com' # Or your specific endpoint URL
How to Define the Source Directory
Set the local directory (or file) that you wish to sync or upload to S3. This can be any directory within your repository.
- uses: jakejarvis/s3-sync-action@master
with:
args: --acl public-read --follow-symlinks --delete
env:
SOURCE_DIR: 'public' # Default is the root of your cloned repository
How to Set the Destination Directory in S3
Specify the directory path inside the S3 bucket where files should be uploaded or synchronized.
- uses: jakejarvis/s3-sync-action@master
with:
args: --acl public-read --follow-symlinks --delete
env:
DEST_DIR: 'my_project/assets' # Default is the root of the bucket