Skip to content

Commit 46f3953

Browse files
committed
setup-node.sh
1 parent 0aaaf9b commit 46f3953

File tree

2 files changed

+18
-16
lines changed

2 files changed

+18
-16
lines changed

.github/alpine/setup-node.sh

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
#!/bin/sh
2+
3+
[ -n "$1" ] || { echo "Usage: $0 <path>"; exit 1; }
4+
5+
# A workaround for "JavaScript Actions in Alpine containers are only supported on x64 Linux runners."
6+
# https://github.com/actions/runner/blob/8a9b96806d12343f7d123c669e29c629138023dd/src/Runner.Worker/Handlers/StepHost.cs#L283-L290
7+
if [ "$(uname -m)" != "x86_64" ]; then
8+
mkdir -p $1
9+
ln -s /usr/bin/node $1
10+
ln -s /usr/bin/npm $1
11+
sed -i 's/ID=alpine/ID=unknown/' /usr/lib/os-release
12+
fi

.github/workflows/build.yml

Lines changed: 6 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -41,15 +41,10 @@ jobs:
4141
rid: win-arm64
4242

4343
steps:
44-
### TODO: clean up
45-
- name: Prepare Node.js for non-x64 Alpine Linux
46-
if: ${{ contains(matrix.container.image, 'alpine') && runner.arch != 'X64' }}
47-
shell: bash
44+
- name: Initialize Alpine Linux
45+
if: ${{ contains(matrix.container.image, 'alpine') }}
4846
run: |
49-
sudo mkdir -p /__e/node20/bin
50-
sudo ln -sf /usr/bin/node /__e/node20/bin/node
51-
sudo ln -sf /usr/bin/npm /__e/node20/bin/npm
52-
sudo sed -i 's/ID=alpine/ID=unknown/' /usr/lib/os-release
47+
curl -sSL https://raw.githubusercontent.com/${{ github.repository }}/${{ github.sha }}/.github/alpine/setup-node.sh | sudo bash /dev/stdin /__e/node20/bin/
5348
5449
- name: Checkout
5550
uses: actions/checkout@v4
@@ -118,15 +113,10 @@ jobs:
118113
slnf: Sentry-CI-Build-Windows-arm64.slnf
119114

120115
steps:
121-
### TODO: clean up
122-
- name: Prepare Node.js for non-x64 Alpine Linux
123-
if: ${{ contains(matrix.container.image, 'alpine') && runner.arch != 'X64' }}
124-
shell: bash
116+
- name: Initialize Alpine Linux
117+
if: ${{ contains(matrix.container.image, 'alpine') }}
125118
run: |
126-
sudo mkdir -p /__e/node20/bin
127-
sudo ln -sf /usr/bin/node /__e/node20/bin/node
128-
sudo ln -sf /usr/bin/npm /__e/node20/bin/npm
129-
sudo sed -i 's/ID=alpine/ID=unknown/' /usr/lib/os-release
119+
curl -sSL https://raw.githubusercontent.com/${{ github.repository }}/${{ github.sha }}/.github/alpine/setup-node.sh | sudo bash /dev/stdin /__e/node20/bin/
130120
131121
- name: Cancel Previous Runs
132122
if: github.ref_name != 'main' && !startsWith(github.ref_name, 'release/')

0 commit comments

Comments
 (0)