Files
Prism/.gitea/workflows/ci.yml
T
rose_cat707 c26b06f1cc
CI / test (push) Successful in 1m11s
CI / docker (push) Failing after 17s
feat: Prism HTTP/SOCKS5 代理网关及管理台
Go 控制面(SQLite + REST API)嵌入 Mihomo 数据面,Vue 3 多语言 Web 管理台。
含订阅/节点/规则/出站/监控/日志、OpenAPI、API Key、Gitea Actions CI 与开源文档;
CI 使用 ubuntu-latest runner,Go/Docker 步骤走国内镜像与 shell,避免 GitHub 下载超时。

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-06-23 14:07:40 +08:00

113 lines
3.3 KiB
YAML
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
# Prism CI:单元测试 + 多架构镜像发布到 Gitea Container Registry
#
# 前置条件:
# 1. 在线 act_runnerruns-on: ubuntu-latest
# 2. 仓库 SecretREGISTRY_TOKENwrite:package 权限的 PAT
#
# 说明:Go/Docker 步骤使用 shell + 国内镜像,避免 actions/setup-go 从 GitHub 下载卡住
name: CI
on:
push:
branches: [main, master]
tags: ['v*']
pull_request:
env:
REGISTRY: git.rc707blog.top
IMAGE_NAME: prism
GOPROXY: https://goproxy.cn,direct
GOSUMDB: sum.golang.google.cn
jobs:
test:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup Go
run: |
set -eux
GO_VERSION=$(grep '^go ' go.mod | awk '{print $2}')
ARCH=$(uname -m | sed 's/x86_64/amd64/; s/aarch64/arm64/')
TAR="go${GO_VERSION}.linux-${ARCH}.tar.gz"
if command -v go >/dev/null 2>&1 && go version | grep -q "go${GO_VERSION} "; then
go version
else
downloaded=0
for url in \
"https://mirrors.aliyun.com/golang/${TAR}" \
"https://golang.google.cn/dl/${TAR}" \
"https://go.dev/dl/${TAR}"; do
echo "trying ${url}"
if curl -fsSL --connect-timeout 20 --retry 3 --retry-delay 5 --max-time 600 \
"$url" -o /tmp/go.tgz; then
downloaded=1
break
fi
done
if [ "$downloaded" -ne 1 ]; then
echo "failed to download Go ${GO_VERSION}" >&2
exit 1
fi
rm -rf /usr/local/go
tar -C /usr/local -xzf /tmp/go.tgz
fi
echo "/usr/local/go/bin" >> "$GITHUB_PATH"
/usr/local/go/bin/go version
- name: Run tests
run: go test ./...
docker:
runs-on: ubuntu-latest
needs: test
if: gitea.event_name == 'push'
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Log in to Gitea Container Registry
run: |
set -eux
echo "${{ secrets.REGISTRY_TOKEN }}" | \
docker login "${{ env.REGISTRY }}" -u "${{ gitea.actor }}" --password-stdin
- name: Build and push
env:
GITEA_SHA: ${{ gitea.sha }}
GITEA_REF: ${{ gitea.ref }}
GITEA_REPOSITORY_OWNER: ${{ gitea.repository_owner }}
run: |
set -eux
image="${REGISTRY}/${GITEA_REPOSITORY_OWNER}/${IMAGE_NAME}"
tags="${image}:sha-${GITEA_SHA:0:7}"
case "${GITEA_REF}" in
refs/heads/main|refs/heads/master)
tags="${tags},${image}:latest"
;;
refs/tags/v*)
tags="${tags},${image}:${GITEA_REF#refs/tags/}"
;;
esac
docker run --privileged --rm tonistiigi/binfmt --install all 2>/dev/null || true
docker buildx create --name prism-builder --use 2>/dev/null || docker buildx use prism-builder
docker buildx inspect --bootstrap
tag_args=()
IFS=',' read -r -a tag_list <<< "$tags"
for t in "${tag_list[@]}"; do
tag_args+=(-t "$t")
done
docker buildx build \
--platform linux/amd64,linux/arm64 \
-f Dockerfile \
"${tag_args[@]}" \
--push \
.