This GitHub Action syncs files from a local directory to an S3 bucket using the
s3-sync-client
package. It supports excluding and including files based on
patterns and setting custom content types.
bucket_name
: The name of the S3 bucket.source_directory
: The local directory to sync.aws_region
: The AWS region of the S3 bucket.aws_access_key_id
: AWS Access Key ID.aws_secret_access_key
: AWS Secret Access Key.aws_session_token
: AWS session token for those using roles/temporary credentials for deployment (optional)
Create a new workflow in .github/workflows/s3-sync.yml
:
name: Sync to S3
on:
push:
branches:
- main
jobs:
s3_sync:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v2
- name: Run S3 Sync
uses: basaldev/s3-file-sync@v1
with:
bucket_name: ${{ secrets.S3_BUCKET_NAME }}
source_directory: './dist'
aws_region: ${{ secrets.AWS_REGION }}
aws_access_key_id: ${{ secrets.AWS_ACCESS_KEY_ID }}
aws_secret_access_key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
- Node.js
- npm
Install the dependencies:
npm install
To build the action, run:
npm run build
To run the action locally, use:
npm start
Contributions are welcome! Please open an issue or submit a pull request with your changes.
This project is licensed under the MIT License.