-
Notifications
You must be signed in to change notification settings - Fork 0
85 lines (78 loc) · 2.36 KB
/
Copy pathtest-image.yml
File metadata and controls
85 lines (78 loc) · 2.36 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
name: Smoke 測試:CLI 已安裝 (Install Check)
on:
workflow_dispatch:
inputs:
image:
description: |
Image name (directory name under images/).
required: true
type: choice
options:
- py-devkit-image-base
- all
tag:
description: |
Image tag to test (default: latest).
Ignored when image=all (always uses :latest).
required: false
default: 'latest'
env:
REGISTRY: ghcr.io
ORG: shumingyang-opencode
jobs:
discover:
runs-on: ubuntu-latest
outputs:
matrix: ${{ steps.discover.outputs.matrix }}
steps:
- uses: actions/checkout@v7
- id: discover
run: |
if [ "all" = "${{ inputs.image }}" ]; then
FIRST=true
JSON='{"image":['
for dir in images/*/; do
name=$(basename "$dir")
[ -f "images/$name/Dockerfile" ] || continue
[ -f "images/$name/test-smoke.sh" ] || continue
if [ "$FIRST" = true ]; then
JSON="$JSON\"$name\""
FIRST=false
else
JSON="$JSON,\"$name\""
fi
done
JSON="$JSON]}"
echo "matrix=$JSON" >> "$GITHUB_OUTPUT"
else
if [ ! -f "images/${{ inputs.image }}/test-smoke.sh" ]; then
echo "Error: no test-smoke.sh found for ${{ inputs.image }}"
exit 1
fi
echo "matrix={\"image\":[\"${{ inputs.image }}\"]}" >> "$GITHUB_OUTPUT"
fi
smoke-test:
needs: discover
runs-on: ubuntu-latest
permissions:
contents: read
packages: read
strategy:
matrix: ${{ fromJSON(needs.discover.outputs.matrix) }}
steps:
- uses: actions/checkout@v7
- name: Login to GHCR
uses: docker/login-action@v4
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Pull and test
run: |
TAG="${{ inputs.tag }}"
if [ "${{ inputs.image }}" = "all" ]; then
TAG="latest"
fi
IMAGE="${{ env.REGISTRY }}/${{ env.ORG }}/${{ matrix.image }}:${TAG}"
docker pull "$IMAGE"
docker run --rm -i "$IMAGE" bash < images/${{ matrix.image }}/test-smoke.sh