This repository was archived by the owner on Jun 1, 2026. It is now read-only.
forked from router-for-me/CLIProxyAPI
-
Notifications
You must be signed in to change notification settings - Fork 48
108 lines (96 loc) · 3.51 KB
/
Copy pathdocker-image.yml
File metadata and controls
108 lines (96 loc) · 3.51 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
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
name: docker-image
on:
push:
branches:
- main
tags:
- v*
workflow_dispatch:
permissions:
contents: read
packages: write
env:
REGISTRY: ghcr.io
jobs:
docker:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Set up Go
uses: actions/setup-go@v5
with:
go-version-file: go.mod
cache: true
- name: Refresh models catalog
run: |
tmp="$(mktemp)"
git fetch --depth 1 https://github.com/router-for-me/models.git main
git show FETCH_HEAD:models.json > "$tmp"
if go run ./cmd/validate_models_catalog -input "$tmp"; then
cp "$tmp" internal/registry/models/models.json
else
echo "::warning title=Models catalog refresh skipped::Fetched models.json failed validation; keeping committed internal/registry/models/models.json"
fi
rm -f "$tmp"
- name: Prepare image metadata
id: prep
run: |
owner="$(echo "${GITHUB_REPOSITORY_OWNER}" | tr '[:upper:]' '[:lower:]')"
repo="$(echo "${GITHUB_REPOSITORY#*/}" | tr '[:upper:]' '[:lower:]')"
commit="$(git rev-parse --short HEAD)"
if [ "${GITHUB_REF_TYPE}" = "tag" ]; then
version="${GITHUB_REF_NAME}"
else
version="beta-${commit}"
fi
echo "image=${owner}/${repo}" >> "$GITHUB_OUTPUT"
echo "version=${version}" >> "$GITHUB_OUTPUT"
echo "commit=${commit}" >> "$GITHUB_OUTPUT"
echo "build_date=$(date -u +%Y-%m-%dT%H:%M:%SZ)" >> "$GITHUB_OUTPUT"
- name: Determine target platforms
id: platforms
run: |
platforms="linux/amd64"
if [ "${GITHUB_REF_TYPE}" = "tag" ]; then
platforms="${platforms},linux/arm64"
fi
echo "platforms=${platforms}" >> "$GITHUB_OUTPUT"
- name: Set up QEMU
if: ${{ github.ref_type == 'tag' }}
uses: docker/setup-qemu-action@v3
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Log in to GHCR
uses: docker/login-action@v3
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Extract Docker metadata
id: meta
uses: docker/metadata-action@v5
with:
images: ${{ env.REGISTRY }}/${{ steps.prep.outputs.image }}
tags: |
type=raw,value=beta,enable=${{ github.ref_type == 'branch' }}
type=raw,value=stable,enable=${{ github.ref_type == 'tag' }}
type=raw,value=latest,enable=${{ github.ref_type == 'tag' }}
type=ref,event=tag,enable=${{ github.ref_type == 'tag' }}
type=semver,pattern={{version}},enable=${{ github.ref_type == 'tag' }}
type=semver,pattern={{major}}.{{minor}},enable=${{ github.ref_type == 'tag' }}
type=sha,prefix=sha-
- name: Build and push image
uses: docker/build-push-action@v6
with:
context: .
platforms: ${{ steps.platforms.outputs.platforms }}
push: true
cache-from: type=gha
cache-to: type=gha,mode=max
labels: ${{ steps.meta.outputs.labels }}
tags: ${{ steps.meta.outputs.tags }}
build-args: |
VERSION=${{ steps.prep.outputs.version }}
COMMIT=${{ steps.prep.outputs.commit }}
BUILD_DATE=${{ steps.prep.outputs.build_date }}