Skip to content

ci: 修 GHCR 标签大小写(仓库名必须全小写) #2

ci: 修 GHCR 标签大小写(仓库名必须全小写)

ci: 修 GHCR 标签大小写(仓库名必须全小写) #2

Workflow file for this run

name: Build test images
# 只服务 test 分支:把两个镜像都构建并推到 GHCR,标签固定为 test / test-console。
# 与 docker-publish.yml(release 分支与 v* tag,推 latest / release / v*)互不干扰:
# 那边用的标签这里一个都不碰,所以 test 上的构建不会影响用 :latest 的人。
#
# 两个镜像:
# - Dockerfile → 形态 A:单文件代理
# - Dockerfile.console → 形态 B:控制台 + 账号池(入口 console/server.mjs)
#
# 两个 Dockerfile 都是 node:22-alpine + COPY,没有编译步骤,所以多架构(amd64/arm64)
# 的额外代价只有拉基础镜像,顺手就跟发布线保持一致,免得 test 机器是 ARM 时拉不动。
on:
push:
branches:
- test
workflow_dispatch:
# 同一分支的新推送取消旧运行,避免排队
concurrency:
group: test-images-${{ github.ref }}
cancel-in-progress: true
jobs:
build:
runs-on: ubuntu-latest
timeout-minutes: 20
permissions:
contents: read
packages: write
strategy:
fail-fast: false
matrix:
include:
- name: proxy
dockerfile: Dockerfile
tag: test
- name: console
dockerfile: Dockerfile.console
tag: test-console
name: ${{ matrix.name }}
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Set up QEMU
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: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
# GHCR 要求仓库名全小写,而 github.repository 会保留大小写(MAXeaglet/...)。
# 发布线那条用的是 metadata-action(它会自动转小写),这里手写标签就必须自己转,
# 否则 buildx 直接报 "repository name must be lowercase"。
- name: Resolve lowercase image name
id: img
run: echo "name=ghcr.io/${GITHUB_REPOSITORY,,}" >> "$GITHUB_OUTPUT"
- name: Build and push
uses: docker/build-push-action@v6
with:
context: .
file: ${{ matrix.dockerfile }}
platforms: linux/amd64,linux/arm64
push: true
tags: ${{ steps.img.outputs.name }}:${{ matrix.tag }}
labels: |
org.opencontainers.image.source=https://github.com/${{ github.repository }}
org.opencontainers.image.revision=${{ github.sha }}
cache-from: type=gha,scope=${{ matrix.name }}
cache-to: type=gha,mode=max,scope=${{ matrix.name }}
- name: Summary
run: |
{
echo "### ${{ matrix.name }}"
echo ""
echo "- Dockerfile: \`${{ matrix.dockerfile }}\`"
echo "- Image: \`${{ steps.img.outputs.name }}:${{ matrix.tag }}\`"
echo "- Commit: \`${{ github.sha }}\`"
} >> "$GITHUB_STEP_SUMMARY"