-
Notifications
You must be signed in to change notification settings - Fork 0
53 lines (51 loc) · 1.49 KB
/
cache.yml
File metadata and controls
53 lines (51 loc) · 1.49 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
name: Cache
on:
workflow_dispatch:
inputs:
versioned-package-manager:
type: string
description: "versioned package manager (e.g. yarn@4.5.3)"
required: true
run-name: Cache ${{ inputs.versioned-package-manager }}
jobs:
cache:
name: Cache
runs-on: ubuntu-latest
timeout-minutes: 5
permissions:
contents: write
steps:
- name: Checkout
uses: actions/checkout@v4
- shell: bash
env:
CACHE_DIRECTORY: .cache/node/corepack/v1
VERSIONED_PACKAGE_MANAGER: ${{ inputs.versioned-package-manager }}
TRACE: ${{ github.run_attempt > 1 && '1' || '' }}
ACTOR: ${{ github.actor }}
ACTOR_ID: ${{ github.actor_id }}
run: |
: Get package manager
if [ -n "$TRACE" ]; then
set -x
fi
npm install -g corepack
cache_directory=$(
cd;
mkdir -p "$CACHE_DIRECTORY"
cd "$CACHE_DIRECTORY"
pwd
)
package_manager=${VERSIONED_PACKAGE_MANAGER%@*}
git checkout --orphan="new"
git rm --cached -r .
git clean -d -f
commit() {
git -c user.name="$ACTOR" -c user.email="$ACTOR_ID+$ACTOR@users.noreply.github.com" commit -m "$1"
}
corepack install -g "$VERSIONED_PACKAGE_MANAGER"
mv "$cache_directory"/* .
git add .
commit "$VERSIONED_PACKAGE_MANAGER"
git tag "$VERSIONED_PACKAGE_MANAGER"
git push origin "$VERSIONED_PACKAGE_MANAGER"