Skip to content

Commit 5b74fe9

Browse files
committed
Move away from raw github domain to API
Signed-off-by: apostasie <[email protected]>
1 parent 848062e commit 5b74fe9

File tree

5 files changed

+28
-9
lines changed

5 files changed

+28
-9
lines changed

.github/workflows/job-test-dependencies.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ jobs:
4949
args=(--build-arg CONTAINERD_VERSION=${{ inputs.containerd-version }})
5050
fi
5151
docker buildx build \
52+
--build-arg GITHUB_TOKEN=${{ secrets.GITHUB_TOKEN }} \
5253
--cache-to type=gha,compression=zstd,mode=max,scope=test-integration-dependencies-"$arch" \
5354
--cache-from type=gha,scope=test-integration-dependencies-"$arch" \
5455
--target build-dependencies "${args[@]}" .

.github/workflows/job-test-in-container.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,7 @@ jobs:
104104
arch=${{ env.RUNNER_ARCH == 'ARM64' && 'arm64' || 'amd64' }}
105105
docker buildx create --name with-gha --use
106106
docker buildx build \
107+
--build-arg GITHUB_TOKEN=${{ secrets.GITHUB_TOKEN }} \
107108
--output=type=docker \
108109
--cache-from type=gha,scope=test-integration-dependencies-"$arch" \
109110
-t "$target" --target "$target" \

.github/workflows/job-test-in-lima.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,7 @@ jobs:
8888
[ "$TARGET" = "rootless" ] && TARGET=test-integration-rootless || TARGET=test-integration
8989
docker buildx create --name with-gha --use
9090
docker buildx build \
91+
--build-arg GITHUB_TOKEN=${{ secrets.GITHUB_TOKEN }} \
9192
--output=type=docker \
9293
--cache-from type=gha,scope=test-integration-dependencies-amd64 \
9394
-t test-integration --target "${TARGET}" \

Dockerfile

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,8 @@ ARG NYDUS_VERSION=v2.3.1
5252
ARG SOCI_SNAPSHOTTER_VERSION=0.9.0
5353
ARG KUBO_VERSION=v0.34.1
5454

55+
ARG GITHUB_TOKEN=""
56+
5557
FROM --platform=$BUILDPLATFORM tonistiigi/xx:1.6.1@sha256:923441d7c25f1e2eb5789f82d987693c47b8ed987c4ab3b075d6ed2b5d6779a3 AS xx
5658

5759

@@ -61,6 +63,7 @@ ENV DEBIAN_FRONTEND=noninteractive
6163
RUN apt-get update -qq && apt-get install -qq --no-install-recommends \
6264
make \
6365
git \
66+
jq \
6467
curl \
6568
dpkg-dev
6669
ARG TARGETARCH
@@ -75,6 +78,7 @@ RUN xx-apt-get update -qq && xx-apt-get install -qq --no-install-recommends \
7578
pkg-config
7679
RUN git config --global advice.detachedHead false
7780
ADD hack/git-checkout-tag-with-hash.sh /usr/local/bin/
81+
ADD hack/scripts/lib.sh /usr/local/bin/http::helper
7882

7983
FROM build-base AS build-containerd
8084
ARG TARGETARCH
@@ -136,6 +140,7 @@ RUN BINDIR=/out/bin make binaries install
136140
# We do not set CMD to `go test` here, because it requires systemd
137141

138142
FROM build-base AS build-dependencies
143+
ARG GITHUB_TOKEN
139144
ARG TARGETARCH
140145
ENV GOARCH=${TARGETARCH}
141146
COPY ./Dockerfile.d/SHA256SUMS.d/ /SHA256SUMS.d
@@ -177,7 +182,7 @@ ARG STARGZ_SNAPSHOTTER_VERSION
177182
RUN STARGZ_SNAPSHOTTER_VERSION=${STARGZ_SNAPSHOTTER_VERSION%%@*}; \
178183
fname="stargz-snapshotter-${STARGZ_SNAPSHOTTER_VERSION}-${TARGETOS:-linux}-${TARGETARCH:-amd64}.tar.gz" && \
179184
curl -o "${fname}" -fsSL --proto '=https' --tlsv1.2 "https://github.com/containerd/stargz-snapshotter/releases/download/${STARGZ_SNAPSHOTTER_VERSION}/${fname}" && \
180-
curl -o "stargz-snapshotter.service" -fsSL --proto '=https' --tlsv1.2 "https://raw.githubusercontent.com/containerd/stargz-snapshotter/${STARGZ_SNAPSHOTTER_VERSION}/script/config/etc/systemd/system/stargz-snapshotter.service" && \
185+
http::helper github::file containerd/stargz-snapshotter script/config/etc/systemd/system/stargz-snapshotter.service "${STARGZ_SNAPSHOTTER_VERSION}" > "stargz-snapshotter.service" && \
181186
grep "${fname}" "/SHA256SUMS.d/stargz-snapshotter-${STARGZ_SNAPSHOTTER_VERSION}" | sha256sum -c - && \
182187
grep "stargz-snapshotter.service" "/SHA256SUMS.d/stargz-snapshotter-${STARGZ_SNAPSHOTTER_VERSION}" | sha256sum -c - && \
183188
tar xzf "${fname}" -C /out/bin && \
@@ -245,6 +250,9 @@ RUN ROOTLESSKIT_VERSION=${ROOTLESSKIT_VERSION%%@*}; \
245250
ARG GOMODJAIL_VERSION
246251
COPY --from=build-gomodjail /out/${TARGETARCH:-amd64}/* /out/bin/
247252
RUN echo "- gomodjail: ${GOMODJAIL_VERSION}" >> /out/share/doc/nerdctl-full/README.md
253+
ARG CONTAINERIZED_SYSTEMD_VERSION
254+
RUN http::helper github::file AkihiroSuda/containerized-systemd docker-entrypoint.sh "${CONTAINERIZED_SYSTEMD_VERSION}" > /docker-entrypoint.sh && \
255+
chmod +x /docker-entrypoint.sh
248256

249257
RUN echo "" >> /out/share/doc/nerdctl-full/README.md && \
250258
echo "## License" >> /out/share/doc/nerdctl-full/README.md && \
@@ -281,9 +289,7 @@ RUN apt-get update -qq && apt-get install -qq -y --no-install-recommends \
281289
iproute2 iptables \
282290
dbus dbus-user-session systemd systemd-sysv \
283291
fuse3
284-
ARG CONTAINERIZED_SYSTEMD_VERSION
285-
RUN curl -o /docker-entrypoint.sh -fsSL --proto '=https' --tlsv1.2 https://raw.githubusercontent.com/AkihiroSuda/containerized-systemd/${CONTAINERIZED_SYSTEMD_VERSION}/docker-entrypoint.sh && \
286-
chmod +x /docker-entrypoint.sh
292+
COPY --from=build-full /docker-entrypoint.sh /docker-entrypoint.sh
287293
COPY --from=out-full / /usr/local/
288294
RUN perl -pi -e 's/multi-user.target/docker-entrypoint.target/g' /usr/local/lib/systemd/system/*.service && \
289295
systemctl enable containerd buildkit stargz-snapshotter && \

hack/scripts/lib.sh

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -226,9 +226,10 @@ github::settoken(){
226226
}
227227

228228
github::request(){
229-
local endpoint="$1"
229+
local accept="$1"
230+
local endpoint="$2"
230231
local args=(
231-
"Accept: application/vnd.github+json"
232+
"Accept: $accept"
232233
"X-GitHub-Api-Version: 2022-11-28"
233234
)
234235

@@ -237,21 +238,30 @@ github::request(){
237238
http::get /dev/stdout https://api.github.com/"$endpoint" "${args[@]}"
238239
}
239240

241+
github::file(){
242+
local repo="$1"
243+
local path="$2"
244+
local ref="${3:-main}"
245+
github::request "application/vnd.github.v3.raw" "repos/$repo/contents/$path?ref=$ref"
246+
}
247+
240248
github::tags::latest(){
241249
local repo="$1"
242-
github::request "repos/$repo/tags" | jq -rc .[0].name
250+
github::request "application/vnd.github+json" "repos/$repo/tags" | jq -rc .[0].name
243251
}
244252

245253
github::releases(){
246254
local repo="$1"
247-
github::request "repos/$repo/releases" |
255+
github::request "application/vnd.github+json" "repos/$repo/releases" |
248256
jq -rc .[]
249257
}
250258

251259
github::releases::latest(){
252260
local repo="$1"
253-
github::request "repos/$repo/releases/latest" | jq -rc .
261+
github::request "application/vnd.github+json" "repos/$repo/releases/latest" | jq -rc .
254262
}
255263

256264
log::init
257265
host::require jq tar curl shasum
266+
267+
[[ "${1:-}" != "github"* ]] || "$@"

0 commit comments

Comments
 (0)