GitHub Action that allows you to cache build artifacts to S3
- An AWS account. Sign up here.
- AWS Access and Secret Keys. More info here.
- An empty S3 bucket.
Set up the following AWS credentials as secrets in your repository, AWS_ACCESS_KEY_ID
and AWS_ACCESS_KEY_ID
S3 Cache for GitHub Actions supports builds on Linux, Windows and MacOS.
- name: Save cache
uses: leroy-merlin-br/action-s3-cache@v1
with:
action: put
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
aws-region: us-east-1 # Or whatever region your bucket was created
bucket: your-bucket
s3-class: ONEZONE_IA # It's STANDARD by default. It can be either STANDARD,
# REDUCED_REDUDANCY, ONEZONE_IA, INTELLIGENT_TIERING, GLACIER, DEEP_ARCHIVE or STANDARD_IA.
key: ${{ hashFiles('yarn.lock') }}
artifacts: |
node_modules*
- name: Retrieve cache
uses: leroy-merlin-br/action-s3-cache@v1
with:
action: get
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
aws-region: us-east-1
bucket: your-bucket
key: ${{ hashFiles('yarn.lock') }}
- name: Clear cache
uses: leroy-merlin-br/action-s3-cache@v1
with:
action: delete
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
aws-region: us-east-1
bucket: your-bucket
key: ${{ hashFiles('yarn.lock') }}
The following example shows a simple pipeline using S3 Cache GitHub Action:
- name: Checkout
uses: actions/checkout@v2
- name: Retrieve cache
uses: leroy-merlin-br/action-s3-cache@v1
with:
action: get
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
aws-region: us-east-1
bucket: your-bucket
key: ${{ hashFiles('yarn.lock') }}
- name: Install dependencies
run: yarn
- name: Save cache
uses: leroy-merlin-br/action-s3-cache@v1
with:
action: put
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
aws-region: us-east-1
bucket: your-bucket
s3-class: STANDARD_IA
key: ${{ hashFiles('yarn.lock') }}
artifacts: |
node_modules/*