-
Notifications
You must be signed in to change notification settings - Fork 1
/
action.yml
109 lines (107 loc) · 3.75 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
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
name: build-node
description: Build node sources via yarn
author: datavisyn
inputs:
node_version:
description: "node version to use"
default: "20.9"
required: true
github_ro_token:
description: "github read-only token"
default: "admin"
required: true
npm_registry:
description: "npm registry"
default: "https://registry.npmjs.org/"
required: true
enable_cache:
description: "enables the yarn cache download and upload"
required: false
default: true
download_yarn_lock:
description: "downloads the node-yarn-lock artifact (only available when build-node was called before)"
required: false
default: false
upload_yarn_lock:
description: "uploads the node-yarn-lock artifact"
required: false
default: true
run_dist:
default: true
required: false
run_webpack:
default: false
required: false
runs:
using: "composite"
steps:
- name: Set up node version
uses: actions/setup-node@v3
with:
node-version: ${{ inputs.node_version }}
registry-url: ${{ inputs.npm_registry }}
- name: Show node and npm version
run: |
corepack enable
node -v
npm -v
shell: bash
- name: Git config
if: inputs.github_ro_token != ''
run: |
if [ -f ~/.gitconfig ]; then
rm ~/.gitconfig
touch ~/.gitconfig
fi
git config --global --replace-all url."https://$GITHUB_TOKEN@github.com/".insteadOf ssh://git@github.com/
git config --add --global url."https://$GITHUB_TOKEN@github.com/".insteadOf git@github.com:
env:
GITHUB_TOKEN: ${{ inputs.github_ro_token }}
shell: bash
- uses: actions/download-artifact@v3
# TODO: Remove the variable whenever we can ensure that build-node was called before
if: inputs.download_yarn_lock == 'true'
with:
name: node-yarn-lock
# Enable yarn download cache, @see https://github.com/actions/cache/tree/main/save#always-save-cache and https://github.com/actions/setup-node/issues/325
- name: Restore yarn cache
uses: actions/cache/restore@v3
if: inputs.enable_cache == 'true'
with:
# This path is the global yarn cache, because for some reason the local .yarn/cache is not used. Maybe we need to set the cacheFolder, enableGlobalCache, ... options differently? @see https://yarnpkg.com/configuration/yarnrc#cacheFolder
path: ~/.yarn/berry/cache/
key: yarn-download-cache-${{ hashFiles('package.json') }}
restore-keys: |
yarn-download-cache-
- name: Install dependencies
id: install
run: yarn install --no-immutable --inline-builds
shell: bash
- name: Save yarn cache
uses: actions/cache/save@v3
if: steps.install.outcome == 'success' && inputs.enable_cache == 'true'
with:
# This path is the global yarn cache, because for some reason the local .yarn/cache is not used. Maybe we need to set the cacheFolder, enableGlobalCache, ... options differently? @see https://yarnpkg.com/configuration/yarnrc#cacheFolder
path: ~/.yarn/berry/cache/
key: yarn-download-cache-${{ hashFiles('package.json') }}
- name: Show installed dependencies
run: yarn info --name-only
shell: bash
- name: Build
if: inputs.run_dist == 'true'
run: npm run dist
shell: bash
- uses: actions/upload-artifact@v3
if: inputs.upload_yarn_lock == 'true'
with:
name: node-yarn-lock
path: ./yarn.lock
- name: Webpack build
if: inputs.run_webpack == 'true'
run: npm run bundle:prod || npm run webpack:prod
shell: bash
- uses: actions/upload-artifact@v3
if: inputs.run_webpack == 'true'
with:
name: node-bundle
path: ./bundles