-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathaction.yml
More file actions
110 lines (98 loc) · 4.66 KB
/
action.yml
File metadata and controls
110 lines (98 loc) · 4.66 KB
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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
name: 'CI setup'
description: 'Checkout, Turbo cache, asdf/Node, corepack'
inputs:
github-token:
description: 'GitHub token for npm auth (e.g. GitHub Packages). When set, configures npm for //npm.pkg.github.com'
required: false
default: ${{ github.token }}
git-user-name:
description: 'Git user name'
required: false
default: 'github-actions[bot]'
git-user-email:
description: 'Git user email'
required: false
default: 'github-actions[bot]@users.noreply.github.com'
node-version:
description: 'Node.js version to set with asdf before install; supports major-only (e.g. 24), major.minor (e.g. 24.14), or exact semver (e.g. 24.14.0).'
required: false
node-cache:
description: 'Enable or disable node package manager (npm, pnpm, etc) cache from github actions cache. When unset, cache is enabled based on the presence of the lockfile.'
required: false
nx-cache:
description: 'Enable or disable Nx cache from github actions cache. When unset, Nx cache runs only if nx.json exists.'
required: false
turbo-cache:
description: 'Enable or disable TurboRepo cache from github actions cache. When unset, Turbo cache runs only if turbo.json exists.'
required: false
outputs:
resolved-node-version:
description: 'Exact Node.js version resolved and installed by asdf when node-version input is set.'
value: ${{ steps.setup-asdf.outputs.resolved-node-version }}
runs:
using: 'composite'
steps:
- name: 🔧 Configure Git
shell: bash
run: |
git config user.name "${{ inputs.git-user-name }}"
git config user.email "${{ inputs.git-user-email }}"
if: inputs.git-user-name != '' && inputs.git-user-email != ''
- name: ⚙️ Setup asdf tools
id: setup-asdf
uses: w5s/actions/setup-asdf@main
with:
node-version: ${{ inputs.node-version }}
if: hashFiles('.tool-versions') != '' || inputs.node-version != ''
# Always restore npm cache
- uses: w5s/actions/cache-npm@main
if: inputs.node-cache == 'true' || (inputs.node-cache != 'false' && hashFiles('package-lock.json') != '')
- name: ⚙️ Setup Node package manager
uses: w5s/actions/setup-corepack@main
if: hashFiles('package.json') != ''
- uses: w5s/actions/cache-yarn@main
if: inputs.node-cache == 'true' || (inputs.node-cache != 'false' && hashFiles('yarn.lock') != '')
- uses: w5s/actions/cache-pnpm@main
if: inputs.node-cache == 'true' || (inputs.node-cache != 'false' && hashFiles('pnpm-lock.yaml') != '')
- uses: w5s/actions/cache-bun@main
if: inputs.node-cache == 'true' || (inputs.node-cache != 'false' && hashFiles('bun.lockb') != '')
- name: 🔧 Configure npm for GitHub Packages
shell: bash
run: npm config set "//npm.pkg.github.com/:_authToken=${{ inputs.github-token }}" --location=user
if: inputs.github-token != ''
- name: ⚙️ Setup Turbo cache
uses: rharkor/caching-for-turbo@a1c4079258ae08389be75b57d4d7a70f23c1c66d # v1.8
if: inputs.turbo-cache == 'true' || (inputs.turbo-cache != 'false' && hashFiles('turbo.json') != '')
- name: ⚙️ Setup Nx
uses: nrwl/nx-set-shas@afb73a62d26e41464e9254689e1fd6122ee683c1 # v5
id: nx-set-shas
with:
gh-token: ${{ inputs.github-token }}
if: hashFiles('nx.json') != ''
# Local Nx cache (when not using Nx Cloud). Key by nx config + HEAD for exact re-runs;
# restore-keys use base then any OS+config cache so config changes invalidate cache.
- name: ⚙️ Setup Nx cache
uses: actions/cache@668228422ae6a00e4ad889ee87cd7109ec5666a7 # v5
with:
path: .nx/cache
key: nx-cache-${{ runner.os }}-${{ hashFiles('nx.json') }}-${{ steps.nx-set-shas.outputs.head }}
restore-keys: |
nx-cache-${{ runner.os }}-${{ hashFiles('nx.json') }}-${{ steps.nx-set-shas.outputs.base }}
nx-cache-${{ runner.os }}-${{ hashFiles('nx.json') }}-
if: steps.nx-set-shas.outcome == 'success' && (inputs.nx-cache == 'true' || (inputs.nx-cache != 'false' && hashFiles('nx.json') != ''))
- name: ⚙️ Setup Playwright cache
uses: w5s/actions/cache-playwright@main
if: inputs.node-cache == 'true' || (inputs.node-cache != 'false')
- name: ℹ️ Package manager information
shell: bash
run: |
if [ -f yarn.lock ]; then
echo "yarn: $(yarn --version)"
elif [ -f pnpm-lock.yaml ]; then
echo "pnpm: $(pnpm --version)"
elif [ -f package-lock.json ]; then
echo "npm: $(npm --version)"
else
echo 'No lockfile found (yarn.lock, pnpm-lock.yaml, or package-lock.json).'
fi
if: hashFiles('package.json') != ''