Skip to content

Commit 72e0ded

Browse files
committed
chore: update token
1 parent 88cab23 commit 72e0ded

3 files changed

Lines changed: 22 additions & 9 deletions

File tree

.github/workflows/taimihud-datasources.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,8 @@ jobs:
108108
with:
109109
files: .ci/artifacts/share/taimihud/sources.toml
110110
updates:
111+
env:
112+
CI_GITHUB_TOKEN: ${{ github.token }}
111113
if: github.event_name != 'push'
112114
name: taimihud-datasources-updates
113115
runs-on: ubuntu-latest

ci/config.nix

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ in
3434
};
3535
};
3636
updates = {
37+
gh-actions.env.CI_GITHUB_TOKEN = "\${{ github.token }}";
3738
tasks = {
3839
build.inputs = legacyPackages.updateChecks ++ [
3940
legacyPackages.allIncompleteSrcs

modules/github/update-check.nix

Lines changed: 19 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,8 @@
1515
outputHashMode = "flat";
1616
preferLocalBuild = true;
1717
allowSubstitutes = false;
18-
impureEnvVars = lib.fetchers.proxyImpureEnvVars ++ [ "NIX_CURL_FLAGS" ];
18+
impureEnvVars = lib.fetchers.proxyImpureEnvVars ++ [ "NIX_CURL_FLAGS" "NIX_GITHUB_TOKEN" "CI_GITHUB_TOKEN" ];
19+
ghTokenEval = builtins.getEnv "CI_GITHUB_TOKEN";
1920
nativeBuildInputs = [ curl jq ];
2021
#queryRelease = "sort_by(.tag_name) | [.[]|select(.prerelease==false and .draft==false)] | .[-1].tag_name";
2122
queryTag = "sort_by(.name) | .[-1].name";
@@ -25,19 +26,28 @@
2526
#RELEASE_URL="https://api.github.com/repos/$owner/$repo/releases"
2627
RELEASE_URL="https://api.github.com/repos/$owner/$repo/releases/latest"
2728
TAGS_URL="https://api.github.com/repos/$owner/$repo/tags"
29+
GH_CURL_FLAGS=(
30+
--insecure
31+
--location-trusted
32+
-fSsL
33+
-H "X-GitHub-Api-Version: 2022-11-28"
34+
$NIX_CURL_FLAGS
35+
)
36+
if [[ -z ''${NIX_GITHUB_TOKEN:-} ]]; then
37+
NIX_GITHUB_TOKEN=''${CI_GITHUB_TOKEN:-''${ghTokenEval-}}
38+
fi
39+
if [[ -n ''${NIX_GITHUB_TOKEN-} ]]; then
40+
GH_CURL_FLAGS+=(
41+
-H "Authorization: $NIX_GITHUB_TOKEN"
42+
)
43+
fi
2844
if REPO_RELEASES=$(curl \
29-
--insecure \
30-
-fSsL \
31-
-H "X-GitHub-Api-Version: 2022-11-28" \
32-
$NIX_CURL_FLAGS \
45+
"''${GH_CURL_FLAGS[@]}" \
3346
"$RELEASE_URL"
3447
); then
3548
REPO_LATEST=$(jq -r "$queryReleaseLatest" - <<< "$REPO_RELEASES")
3649
elif REPO_TAGS=$(curl \
37-
--insecure \
38-
-fSsL \
39-
-H "X-GitHub-Api-Version: 2022-11-28" \
40-
$NIX_CURL_FLAGS \
50+
"''${GH_CURL_FLAGS[@]}" \
4151
"$TAGS_URL"
4252
); then
4353
REPO_LATEST=$(jq -r "$queryTag" - <<< "$REPO_TAGS")

0 commit comments

Comments
 (0)