Skip to content

Commit cc9194f

Browse files
authored
Use a GHCR mirror for manylinux CI (#2098)
* Add manylinux image mirror workflow * Use mirrored manylinux image in CI
1 parent 44adfed commit cc9194f

2 files changed

Lines changed: 105 additions & 3 deletions

File tree

.github/workflows/manylinux.yml

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,10 @@ on:
77
branches:
88
- main
99

10+
permissions:
11+
contents: read
12+
packages: read
13+
1014
env:
1115
DEBIAN_FRONTEND: noninteractive
1216
OPENCV_VERSION: 5.0.0
@@ -23,7 +27,10 @@ jobs:
2327
name: Linux (x64, full)
2428
runs-on: ubuntu-24.04
2529
container:
26-
image: quay.io/pypa/manylinux_2_28_x86_64
30+
image: ghcr.io/shimat/opencvsharp-manylinux@sha256:fdb9a9c223b215604dc7b6f7e8fff4b39bfea5fbaa7777a2e5544a60dfa437f8
31+
credentials:
32+
username: ${{ github.actor }}
33+
password: ${{ secrets.GITHUB_TOKEN }}
2734
options: --user root
2835

2936
steps:
@@ -54,7 +61,10 @@ jobs:
5461
name: Linux (x64, headless)
5562
runs-on: ubuntu-24.04
5663
container:
57-
image: quay.io/pypa/manylinux_2_28_x86_64
64+
image: ghcr.io/shimat/opencvsharp-manylinux@sha256:fdb9a9c223b215604dc7b6f7e8fff4b39bfea5fbaa7777a2e5544a60dfa437f8
65+
credentials:
66+
username: ${{ github.actor }}
67+
password: ${{ secrets.GITHUB_TOKEN }}
5868
options: --user root
5969

6070
steps:
@@ -88,7 +98,10 @@ jobs:
8898
name: Linux (x64, slim)
8999
runs-on: ubuntu-24.04
90100
container:
91-
image: quay.io/pypa/manylinux_2_28_x86_64
101+
image: ghcr.io/shimat/opencvsharp-manylinux@sha256:fdb9a9c223b215604dc7b6f7e8fff4b39bfea5fbaa7777a2e5544a60dfa437f8
102+
credentials:
103+
username: ${{ github.actor }}
104+
password: ${{ secrets.GITHUB_TOKEN }}
92105
options: --user root
93106

94107
steps:
Lines changed: 89 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,89 @@
1+
name: Sync manylinux image to GHCR
2+
3+
on:
4+
workflow_dispatch:
5+
inputs:
6+
source_ref:
7+
description: Upstream manylinux image reference to mirror
8+
required: true
9+
default: quay.io/pypa/manylinux_2_28_x86_64:latest
10+
type: string
11+
12+
permissions:
13+
contents: read
14+
packages: write
15+
16+
concurrency:
17+
group: sync-manylinux-image
18+
cancel-in-progress: false
19+
20+
env:
21+
DEFAULT_SOURCE_REF: quay.io/pypa/manylinux_2_28_x86_64:latest
22+
DESTINATION_IMAGE: ghcr.io/shimat/opencvsharp-manylinux
23+
DESTINATION_TAG: manylinux_2_28_x86_64
24+
25+
jobs:
26+
sync:
27+
name: Mirror manylinux_2_28 x64
28+
runs-on: ubuntu-24.04
29+
timeout-minutes: 20
30+
31+
steps:
32+
- name: Pull upstream image with retries
33+
id: pull
34+
env:
35+
SOURCE_REF: ${{ inputs.source_ref || env.DEFAULT_SOURCE_REF }}
36+
run: |
37+
set -euo pipefail
38+
39+
for attempt in 1 2 3 4 5; do
40+
if docker pull "${SOURCE_REF}"; then
41+
break
42+
fi
43+
44+
if [ "${attempt}" -eq 5 ]; then
45+
echo "Failed to pull ${SOURCE_REF} after ${attempt} attempts." >&2
46+
exit 1
47+
fi
48+
49+
delay=$((attempt * 15))
50+
echo "Pull attempt ${attempt} failed; retrying in ${delay} seconds." >&2
51+
sleep "${delay}"
52+
done
53+
54+
echo "source_ref=${SOURCE_REF}" >> "${GITHUB_OUTPUT}"
55+
56+
- name: Log in to GHCR
57+
env:
58+
GHCR_TOKEN: ${{ secrets.GITHUB_TOKEN }}
59+
run: echo "${GHCR_TOKEN}" | docker login ghcr.io --username "${GITHUB_ACTOR}" --password-stdin
60+
61+
- name: Push mirror and report digest
62+
id: push
63+
env:
64+
SOURCE_REF: ${{ steps.pull.outputs.source_ref }}
65+
run: |
66+
set -euo pipefail
67+
68+
destination_ref="${DESTINATION_IMAGE}:${DESTINATION_TAG}"
69+
push_log="${RUNNER_TEMP}/manylinux-push.log"
70+
71+
docker tag "${SOURCE_REF}" "${destination_ref}"
72+
docker push "${destination_ref}" | tee "${push_log}"
73+
74+
digest="$(sed -n 's/.*digest: \(sha256:[0-9a-f]\{64\}\).*/\1/p' "${push_log}" | tail -n 1)"
75+
if [ -z "${digest}" ]; then
76+
echo "Could not determine the pushed image digest." >&2
77+
exit 1
78+
fi
79+
80+
docker pull "${DESTINATION_IMAGE}@${digest}"
81+
82+
echo "digest=${digest}" >> "${GITHUB_OUTPUT}"
83+
{
84+
echo "### manylinux mirror"
85+
echo
86+
echo "- Source: \`${SOURCE_REF}\`"
87+
echo "- Destination: \`${destination_ref}\`"
88+
echo "- Pinned reference: \`${DESTINATION_IMAGE}@${digest}\`"
89+
} >> "${GITHUB_STEP_SUMMARY}"

0 commit comments

Comments
 (0)