Skip to content

Instantly share code, notes, and snippets.

@gajus
Created March 9, 2022 00:51
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 gajus/67f1ce8cbe95ff46746e8a9fe43a1dbc to your computer and use it in GitHub Desktop.
Save gajus/67f1ce8cbe95ff46746e8a9fe43a1dbc to your computer and use it in GitHub Desktop.
# What's going here? 😳
# GitHub action runners share cache only within the same branch or by inheriting from the parent branch (https://stackoverflow.com/a/66632107/368691).
# i.e. We need a mechanism that would create a shared cache every time that yarn.lock changes.
# We do this by forcing to cache populating action in every GitHub action runner every time yarn.lock changes.
# The number 50 comes from the contra-manager maximum number of runners.
build_cache:
name: Build cache
runs-on:
- self-hosted
- contra-general-purpose-experimental
strategy:
matrix:
concurrency:
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
- 11
- 12
- 13
- 14
- 15
- 16
- 17
- 18
- 19
- 20
- 21
- 22
- 23
- 24
- 25
- 26
- 27
- 28
- 29
- 30
- 31
- 32
- 33
- 34
- 35
- 36
- 37
- 38
- 39
- 40
- 41
- 42
- 43
- 44
- 45
- 46
- 47
- 48
- 49
- 50
steps:
- run: find . -name . -o -prune -exec rm -rf -- {} +
- uses: actions/checkout@v2
- uses: dopplerhq/cli-action@v1
- name: Load environment variables
uses: catchco/doppler-environment-loader@v1.0.2
with:
doppler-token: ${{ secrets.DOPPLER_TOKEN }}
- uses: actions/setup-node@v2
with:
node-version: '16'
- name: Setup yarn
run: npm install -g yarn
- uses: actions/setup-node@v2
with:
node-version: '16'
- name: Cache node_modules
id: cache-node-modules
uses: actions/cache@v2
with:
path: node_modules
key: node_modules-${{ hashFiles('**/yarn.lock') }}
- name: Install dependencies
if: |
steps.cache-node-modules.outputs.cache-hit != 'true'
run: |
yarn config set 'enableGlobalCache' 'true'
yarn config set 'npmRegistries["//npm.pkg.github.com"].npmAuthToken' "$GITHUB_TOKEN"
yarn --immutable
yarn config unset 'npmRegistries["//npm.pkg.github.com"].npmAuthToken'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment