Skip to content

Commit 1cc5703

Browse files
committed
Add 'mirror' input
1 parent 2a0f10e commit 1cc5703

File tree

3 files changed

+23
-0
lines changed

3 files changed

+23
-0
lines changed

README.md

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,19 @@ for the latest full release. The default is `latest`.
3131
> Mirrors, including the official Zig website, may purge old nightly builds at their leisure. This means
3232
> that if you target an out-of-date nightly build, such as a `0.11.0-dev` build, the download may fail.
3333

34+
If you want to use one specific mirror, you can set it using the `mirror` option:
35+
36+
```yaml
37+
- uses: mlugg/setup-zig@v1
38+
with:
39+
mirror: 'https://pkg.machengine.org/zig'
40+
```
41+
42+
Please don't do this unnecessarily; it's not nice to hammer one mirror. This mirror is not permitted to
43+
be https://ziglang.org/download to avoid the oggicial websote being hit with large amounts of requests.
44+
If you've experienced issues with a default mirror, please open an issue, and I will communicate with the
45+
mirror's owner or remove it from the list.
46+
3447
## Details
3548

3649
This action attempts to download the requested Zig tarball from a set of mirrors, in a random order. As

action.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,10 @@ inputs:
55
description: 'Version of the Zig compiler, e.g. "0.13.0" or "0.13.0-dev.351+64ef45eb0". "master" uses the latest nightly build. "latest" uses the latest tagged release.'
66
required: true
77
default: 'latest'
8+
mirror:
9+
description: 'Override of Zig download mirror to use, e.g. "https://pkg.machengine.org/zig".'
10+
required: false
11+
default: ''
812
runs:
913
using: 'node20'
1014
main: 'main.js'

main.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,12 @@ async function downloadFromMirror(mirror, tarball_name, tarball_ext) {
3838
}
3939

4040
async function downloadTarball(tarball_name, tarball_ext) {
41+
const preferred_mirror = core.getInput('mirror');
42+
if (preferred_mirror) {
43+
core.info(`Using mirror: ${preferred_mirror}`);
44+
return await downloadFromMirror(preferred_mirror, tarball_name, tarball_ext);
45+
}
46+
4147
// We will attempt all mirrors before making a last-ditch attempt to the official download.
4248
// To avoid hammering a single mirror, we first randomize the array.
4349
const shuffled_mirrors = MIRRORS.map((m) => [m, Math.random()]).sort((a, b) => a[1] - b[1]).map((a) => a[0]);

0 commit comments

Comments
 (0)