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
+10 -5
View File
@@ -4,8 +4,10 @@ ARG NPM_REGISTRY=https://registry.npmmirror.com
FROM ${NODE_IMAGE} AS deps
WORKDIR /app
COPY package.json package-lock.json ./
RUN npm config set registry ${NPM_REGISTRY} && npm ci
COPY package.json pnpm-lock.yaml pnpm-workspace.yaml ./
RUN corepack enable \
&& pnpm config set registry ${NPM_REGISTRY} \
&& pnpm install --frozen-lockfile
FROM ${NODE_IMAGE} AS builder
WORKDIR /app
@@ -26,8 +28,11 @@ ENV HOSTNAME=0.0.0.0
ENV PORT=3000
ENV AUDIO_DIRECTORY=/app/public/audio
COPY package.json package-lock.json ./
RUN npm config set registry ${NPM_REGISTRY} && npm ci --omit=dev && npm cache clean --force
COPY package.json pnpm-lock.yaml pnpm-workspace.yaml ./
RUN corepack enable \
&& pnpm config set registry ${NPM_REGISTRY} \
&& pnpm install --prod --frozen-lockfile \
&& pnpm store prune
COPY --from=builder /app/.next ./.next
COPY --from=builder /app/public ./public
@@ -37,4 +42,4 @@ RUN mkdir -p /app/data /app/public/audio
EXPOSE 3000
CMD ["npm", "run", "start"]
CMD ["pnpm", "start"]
+1
View File
@@ -3,6 +3,7 @@
"version": "0.2.0",
"private": true,
"type": "module",
"packageManager": "pnpm@11.7.0",
"scripts": {
"dev": "next dev",
"build": "next build",