fix:进行流水线测试

This commit is contained in:
2026-06-30 22:01:13 +08:00
parent 1d566bd3c0
commit 09405914cd
3 changed files with 102 additions and 5 deletions
+91
View File
@@ -0,0 +1,91 @@
name: Build Docker Package
on:
push:
branches:
- master
tags:
- "v*"
workflow_dispatch:
jobs:
docker-package:
runs-on: ubuntu-latest
env:
REGISTRY: git.hanhan.ltd
NODE_IMAGE: m.daocloud.io/docker.io/library/node:22
NPM_REGISTRY: https://registry.npmmirror.com
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Prepare image metadata
id: meta
shell: bash
run: |
repository="${GITHUB_REPOSITORY:-${{ gitea.repository }}}"
repository="$(printf '%s' "$repository" | tr '[:upper:]' '[:lower:]')"
image="${REGISTRY}/${repository}"
sha="${GITHUB_SHA:-${{ gitea.sha }}}"
short_sha="${sha:0:12}"
ref="${GITHUB_REF:-${{ gitea.ref }}}"
{
echo "image=${image}"
echo "tags<<EOF"
echo "${image}:sha-${short_sha}"
if [[ "${ref}" == "refs/heads/master" ]]; then
echo "${image}:latest"
fi
if [[ "${ref}" == refs/tags/* ]]; then
tag="${ref#refs/tags/}"
echo "${image}:${tag}"
fi
echo "EOF"
} >> "${GITHUB_OUTPUT}"
- name: Login to Gitea container registry
env:
PACKAGE_USERNAME: ${{ secrets.PACKAGE_USERNAME }}
PACKAGE_TOKEN: ${{ secrets.PACKAGE_TOKEN }}
GITEA_ACTOR: ${{ gitea.actor }}
shell: bash
run: |
username="${PACKAGE_USERNAME:-${GITEA_ACTOR}}"
if [[ -z "${PACKAGE_TOKEN}" ]]; then
echo "PACKAGE_TOKEN secret is required to publish container packages." >&2
echo "Create a Gitea personal access token with package write permission and save it as PACKAGE_TOKEN." >&2
exit 1
fi
echo "${PACKAGE_TOKEN}" | docker login "${REGISTRY}" -u "${username}" --password-stdin
- name: Build image
shell: bash
run: |
mapfile -t tags <<< "${{ steps.meta.outputs.tags }}"
args=()
for tag in "${tags[@]}"; do
args+=(--tag "$tag")
done
docker build \
--build-arg "NODE_IMAGE=${NODE_IMAGE}" \
--build-arg "NPM_REGISTRY=${NPM_REGISTRY}" \
"${args[@]}" \
.
- name: Push image
shell: bash
run: |
mapfile -t tags <<< "${{ steps.meta.outputs.tags }}"
for tag in "${tags[@]}"; do
docker push "$tag"
done