Skip to content

Instantly share code, notes, and snippets.

@scottjacobsen
Created July 15, 2020 00:24
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save scottjacobsen/ef7ccdf0ef48080a63e2fd4076d4e83f to your computer and use it in GitHub Desktop.
Save scottjacobsen/ef7ccdf0ef48080a63e2fd4076d4e83f to your computer and use it in GitHub Desktop.
Cache gems to s3
env:
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
AWS_DEFAULT_REGION: us-east-1
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
jobs:
rspec:
runs-on: ubuntu-16.04
steps:
- name: Restore bundle cache
run: >
aws s3 ls s3://mybucket/build-cache/gems-${{ hashFiles('Gemfile.lock') }}.tar.gz &&
aws s3 cp s3://mybucket/build-cache/gems-${{ hashFiles('Gemfile.lock') }}.tar.gz bundle_cache.tar.gz --only-show-errors &&
tar -xf bundle_cache.tar.gz ||
true
- name: Bundle install
run: bundle install --deployment --jobs 4 --full-index
- name: Cache bundle
run: >
aws s3 ls s3://mybucket/build-cache/gems-${{ hashFiles('Gemfile.lock') }}.tar.gz ||
(tar -acf gems-${{ hashFiles('Gemfile.lock') }}.tar.gz vendor/bundle &&
aws s3 cp gems-${{ hashFiles('Gemfile.lock') }}.tar.gz s3://mybucket/build-cache/ --only-show-errors)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment