Skip to content

mirrorweb/s3-sync-action

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

13 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

GitHub Action to Sync/Cp to S3

This simple action uses the vanilla AWS CLI to sync a directory or list of files (either from your repository or generated during your workflow) to a remote S3 bucket.

Usage

workflow.yml Example

Place in a .yml file such as this one in your .github/workflows folder. Refer to the documentation on workflow YAML syntax here.

As of v0.3.0, all aws s3 sync flags are optional to allow for maximum customizability (that's a word, I promise) and must be provided by you via args:. The optimal defaults for a static website are set in this example: --acl public-read makes your files publicly readable, --follow-symlinks won't hurt and fixes some weird symbolic link problems that may come up, and most importantly, --delete permanently deletes files in the S3 bucket that are not present in the latest version of your repository/build.

name: Sync Bucket
on: push

jobs:
  deploy:
    runs-on: ubuntu-latest
    steps:
    - uses: actions/checkout@master
    - uses: mirrorweb/s3-sync-action@master
      with:
        args: --acl public-read --follow-symlinks --delete
      env:
        SOURCE_DIR: './public'
        AWS_REGION: 'us-east-1'
        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 }}

Configuration

The following settings must be passed as environment variables as shown in the example. Sensitive information, especially AWS_ACCESS_KEY_ID and AWS_SECRET_ACCESS_KEY, should be set as encrypted secrets — otherwise, they'll be public to anyone browsing your repository.

Key Value Suggested Type Required
AWS_ACCESS_KEY_ID Your AWS Access Key. More info here. secret Yes
AWS_SECRET_ACCESS_KEY Your AWS Secret Access Key. More info here. secret Yes
AWS_S3_BUCKET The name of the bucket you're syncing to. For example, jarv.is. secret Yes
AWS_GHA_ROLE The assume role to use to sync. secret Yes
AWS_REGION The region where you created your bucket in. For example, us-east-1. Full list of regions here. env Yes
SOURCE_DIR The local directory you wish to sync/upload to S3. For example, ./public. Defaults to the root of your repository (.) if not provided. env No
SOURCE_ARRAY A space delimited list of files to upload to S3. Eg:- scripts/utils.sh heimdall heimdall-ui env No

At least one of SOURCE_DIR or SOURCE_ARRAY need to be set.

License

This project is distributed under the MIT license.

Credit

https://github.com/jakejarvis/s3-sync-action

About

A github action to sync or copy files to S3 from GHA

Resources

License

Code of conduct

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published