-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathaction.yml
55 lines (53 loc) · 1.76 KB
/
action.yml
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
name: Run a command in node environment
description: A GitHub action setting up node, installing npm packages and running a specified command
inputs:
ref:
description: >
Git reference used in checkout action.
When checking out the repository that triggered a workflow, this defaults to the reference or SHA for that event.
Otherwise, uses the default branch.
node-version:
description: 'Version Spec of the version to use. Examples: 12.x, 10.15.1, >=10.15.0'
default: 20
registry-url:
description: >
Optional registry to set up for auth. Will set the registry
in a project level .npmrc and .yarnrc file, and set up auth to read in from env.NODE_AUTH_TOKEN
scope:
description: Optional scope for authenticating against scoped registries
directory:
description: A directory to run the command in
default: ./
command:
description: A shell command to run
required: true
runs:
using: composite
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
ref: ${{ inputs.ref }}
- name: Cache node_modules
id: cache-npm
uses: actions/cache@v4
with:
key: ${{ hashFiles( format('{0}/{1}', inputs.directory, 'package.json') ) }}
path: ${{ inputs.directory }}/node_modules
- name: Set up Node
uses: actions/setup-node@v4
with:
node-version: ${{ inputs.node-version }}
registry-url: ${{ inputs.registry-url }}
scope: ${{ inputs.scope }}
- if: ${{ steps.cache-npm.outputs.cache-hit != 'true' }}
name: Install
run: |
cd ${{ inputs.directory }}
npm install
shell: bash
- name: Execute the command
run: |
cd ${{ inputs.directory }}
${{ inputs.command }}
shell: bash