-
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: Fabiana Campanari <[email protected]>
- Loading branch information
1 parent
959e6af
commit c1db24d
Showing
1 changed file
with
89 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,89 @@ | ||
# This is the composite action: | ||
# https://docs.github.com/en/actions/creating-actions/creating-a-composite-action | ||
# | ||
# Composite actions have some limitations: | ||
# - many contexts are unavailable, e.g. `runner` | ||
# - `env` can be specified per-step only | ||
# - if `run` is used, `shell` must be explicitly specified | ||
name: 'Setup Node and install dependencies' | ||
description: 'Setup Node and install dependencies using cache' | ||
inputs: | ||
node-version: | ||
description: 'Node version' | ||
required: true | ||
os: | ||
description: 'Composite actions do not support `runner.os`, so it must be passed in as an input' | ||
required: true | ||
save-cache: | ||
description: 'Save cache when needed' | ||
required: false | ||
default: 'false' | ||
runs: | ||
using: 'composite' | ||
steps: | ||
- name: Calculate `CACHE_KEY` | ||
shell: bash | ||
run: | | ||
echo 'CACHE_KEY=node_modules-${{ | ||
inputs.os | ||
}}-${{ | ||
inputs.node-version | ||
}}-${{ | ||
hashFiles('pnpm-lock.yaml', 'package.json') | ||
}}' >> "$GITHUB_ENV" | ||
- name: Restore `node_modules` | ||
id: node-modules-restore | ||
uses: actions/cache/restore@ab5e6d0c87105b4c9c2047343972218f562e4319 # v4.0.1 | ||
with: | ||
path: node_modules | ||
key: ${{ env.CACHE_KEY }} | ||
enableCrossOsArchive: true | ||
|
||
- name: Calculate `CACHE_HIT` | ||
shell: bash | ||
run: | | ||
echo 'CACHE_HIT=${{ | ||
(steps.node-modules-restore.outputs.cache-hit == 'true') && 'true' || '' | ||
}}' >> "$GITHUB_ENV" | ||
- name: Enable corepack | ||
shell: bash | ||
run: corepack enable | ||
|
||
- name: Setup Node | ||
uses: actions/setup-node@60edb5dd545a775178f52524783378180af0d1f8 # v4.0.2 | ||
with: | ||
node-version: ${{ inputs.node-version }} | ||
cache: ${{ env.CACHE_HIT != 'true' && 'pnpm' || '' }} | ||
|
||
- name: Install dependencies | ||
uses: nick-fields/retry@7152eba30c6575329ac0576536151aca5a72780e # v3.0.0 | ||
if: env.CACHE_HIT != 'true' | ||
with: | ||
timeout_minutes: 10 | ||
max_attempts: 3 | ||
command: pnpm install --frozen-lockfile | ||
|
||
- name: Write `node_modules` cache | ||
if: inputs.save-cache == 'true' && env.CACHE_HIT != 'true' | ||
uses: actions/cache/save@ab5e6d0c87105b4c9c2047343972218f562e4319 # v4.0.1 | ||
with: | ||
path: node_modules | ||
key: ${{ env.CACHE_KEY }} | ||
enableCrossOsArchive: true | ||
|
||
- name: Generate files | ||
shell: bash | ||
run: > | ||
if [[ -d lib ]]; then | ||
pnpm prepare:generate; | ||
fi | ||
- name: Git config | ||
shell: bash | ||
run: | | ||
git config --global core.autocrlf false | ||
git config --global core.symlinks true | ||
git config --global user.email '[email protected]' | ||
git config --global user.name 'Renovate Bot' |