Skip to content

Commit

Permalink
test cache actions
Browse files Browse the repository at this point in the history
  • Loading branch information
dnnnvx committed Jul 4, 2023
1 parent 6f67d4f commit 6bb0993
Show file tree
Hide file tree
Showing 3 changed files with 59 additions and 14 deletions.
48 changes: 48 additions & 0 deletions .github/actions/yarn-install/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
name: 'Yarn install'
description: 'Run yarn install with node_modules linker and cache enabled'

runs:
using: 'composite'
steps:
- name: Setup Node.js
uses: actions/setup-node@v3
with:
node-version: lts/*
registry-url: 'https://registry.npmjs.org'

- name: Expose yarn config as "$GITHUB_OUTPUT"
id: yarn-config
shell: bash
run: |
echo "CACHE_FOLDER=$(yarn config get cacheFolder)" >> $GITHUB_OUTPUT
# Yarn rotates the downloaded cache archives, @see https://github.com/actions/setup-node/issues/325
# Yarn cache is also reusable between arch and os.
- name: Restore yarn cache
uses: actions/cache@v3
id: yarn-download-cache
with:
path: ${{ steps.yarn-config.outputs.CACHE_FOLDER }}
key: yarn-download-cache-${{ hashFiles('yarn.lock') }}
restore-keys: |
yarn-download-cache-
# Invalidated on yarn.lock changes
- name: Restore yarn install state
id: yarn-install-state-cache
uses: actions/cache@v3
with:
path: .yarn/ci-cache/
key: ${{ runner.os }}-yarn-install-state-cache-${{ hashFiles('yarn.lock', '.yarnrc.yml') }}

- name: Install dependencies
env:
# CI optimizations. Overrides yarnrc.yml options (or their defaults) in the CI action.
YARN_ENABLE_GLOBAL_CACHE: 'false' # Use local cache folder to keep downloaded archives
YARN_NM_MODE: 'hardlinks-local' # Hardlinks-(local|global) reduces io / node_modules size
YARN_INSTALL_STATE_PATH: .yarn/ci-cache/install-state.gz # Very small speedup when lock does not change
# Other environment variables
HUSKY: '0' # By default do not run HUSKY install
shell: bash
run: |
yarn install --immutable --inline-builds
16 changes: 9 additions & 7 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ name: Deploy Widget to S3
on:
push:
branches:
- main
- cache-actions

jobs:
build:
Expand All @@ -14,19 +14,21 @@ jobs:
steps:
- uses: actions/checkout@v3
- name: Configure AWS Credentials
uses: aws-actions/configure-aws-credentials@v1-node16
uses: aws-actions/configure-aws-credentials@v2
with:
role-to-assume: arn:aws:iam::403372804574:role/github-actions
role-session-name: github-actions-role-session
aws-region: us-east-2
- name: Amazon ECR login
id: login-ecr
uses: aws-actions/amazon-ecr-login@v1
- name: Install dependencies
uses: ./.github/actions/yarn-install
- name: Build React App
env:
NODE_OPTIONS: "--max_old_space_size=4096"
run: yarn install && yarn build
- name: Deploy app build to S3 bucket
run: |
aws s3 sync ./packages/widget-playground/dist/ s3://playground.li.fi --delete
aws s3 sync ./packages/widget-embedded/dist/ s3://widget.li.fi --delete
run: yarn build
# - name: Deploy app build to S3 bucket
#  run: |
#  aws s3 sync ./packages/widget-playground/dist/ s3://playground.li.fi --delete
#  aws s3 sync ./packages/widget-embedded/dist/ s3://widget.li.fi --delete
9 changes: 2 additions & 7 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,13 +27,8 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Setup .npmrc file to publish to npm
uses: actions/setup-node@v3
with:
node-version: lts/*
registry-url: 'https://registry.npmjs.org'
- name: Install modules
run: yarn install
- name: Install dependencies
uses: ./.github/actions/yarn-install
- name: Build
run: yarn release:build
- name: Publish to npm
Expand Down

0 comments on commit 6bb0993

Please sign in to comment.