Skip to content

Instantly share code, notes, and snippets.

@sajithneyo
Last active May 25, 2020 21:18
Show Gist options
  • Save sajithneyo/45f5f1c9fcec60e64d2b7d2c947e3dfe to your computer and use it in GitHub Desktop.
Save sajithneyo/45f5f1c9fcec60e64d2b7d2c947e3dfe to your computer and use it in GitHub Desktop.
GitHub actions cache config file for yarn locals and globals
name: dev release
on:
push:
branches:
- dev
pull_request:
branches:
- dev
jobs:
configure-env:
runs-on: ubuntu-latest
steps:
- name: CHECKOUT ACTION
uses: actions/checkout@v2
- name: NODE SETUP ACTION
uses: actions/setup-node@master
with:
node-version: '12.x'
- name: Get yarn cache directory path
id: yarn-cache-dir-path
run: |
echo "::set-output name=dir::$(yarn cache dir)"
- name: Set yarn global bin path
run: |
yarn config set prefix $(yarn cache dir)
- name: Set yarn global installation path
run: |
yarn config set global-folder $(yarn cache dir)
yarn global dir
yarn config list
- name: Add yarn bin to system path
run: |
yarn global bin
echo "::add-path::$(yarn global bin)"
echo $PATH
- name: YARN CACHE ACTION
uses: actions/cache@v1
env:
cache-name: v1
id: yarn-cache
with:
path: ${{ steps.yarn-cache-dir-path.outputs.dir }}
key: ${{ runner.os }}-yarn-v2-${{ env.cache-name }}-${{ hashFiles('**/yarn.lock') }}
restore-keys: |
${{ runner.os }}-yarn-${{ env.cache-name }}-
${{ runner.os }}-yarn-
${{ runner.os }}-
- name: Print cache
run: |
ls -al /home/runner/.cache/yarn/v6
ls -al
- name: Installing dependencies
if: steps.yarn-cache.outputs.cache-hit != 'true'
run: |
echo "NO CACHE HIT"
yarn install
- name: Installing sls global
if: steps.yarn-cache.outputs.cache-hit != 'true'
run: |
echo "NO CACHE HIT"
yarn global add serverless
- name: Print cache
run: |
ls -al /home/runner/.cache/yarn/v6
ls -al
- name: Print sls
run: |
sls -v
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment