From 549bd325ee6de191b565d08b607f50a844ce9b01 Mon Sep 17 00:00:00 2001 From: clkj <919284064@qq.com> Date: Mon, 15 Jun 2026 10:50:06 +0800 Subject: [PATCH] =?UTF-8?q?=E6=9B=B4=E6=96=B0=20.gitea/workflows/test.yml?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .gitea/workflows/test.yml | 50 +++++++++++++++++++++++++++------------ 1 file changed, 35 insertions(+), 15 deletions(-) diff --git a/.gitea/workflows/test.yml b/.gitea/workflows/test.yml index d67ac59..9833290 100644 --- a/.gitea/workflows/test.yml +++ b/.gitea/workflows/test.yml @@ -1,19 +1,39 @@ -name: Gitea Actions Demo -run-name: ${{ gitea.actor }} is testing out Gitea Actions 🚀 -on: [push] +name: Build and Push Next.js to Private Registry + +on: + push: + branches: + - main jobs: - Explore-Gitea-Actions: + build-and-push: runs-on: ubuntu-latest steps: - - run: echo "🎉 The job was automatically triggered by a ${{ gitea.event_name }} event." - - run: echo "🐧 This job is now running on a ${{ runner.os }} server hosted by Gitea!" - - run: echo "🔎 The name of your branch is ${{ gitea.ref }} and your repository is ${{ gitea.repository }}." - - name: Check out repository code - uses: actions/checkout@v3 - - run: echo "💡 The ${{ gitea.repository }} repository has been cloned to the runner." - - run: echo "🖥️ The workflow is now ready to test your code on the runner." - - name: List files in the repository - run: | - ls ${{ gitea.workspace }} - - run: echo "🍏 This job's status is ${{ job.status }}." \ No newline at end of file + - name: 检查代码 + uses: actions/checkout@v4 + + - name: 生成短哈希版本号 + id: vars + run: echo "sha_short=$(git rev-parse --short HEAD)" >> $GITHUB_OUTPUT + + # 关键步骤:配置 Buildx 允许不安全的 HTTP 私有仓库 + - name: 设置 Docker Buildx + uses: docker/setup-buildx-action@v3 + with: + driver-opts: | + image=moby/buildkit:master + config-inline: | + [registry."192.168.10.236:31051"] + http = true + insecure = true + + - name: 构建并推送镜像 + uses: docker/build-push-action@v5 + with: + context: . + file: ./Dockerfile + push: true + # 必须将镜像前缀改为你的私有仓库 IP 和端口 + tags: | + 192.168.10.236:31051/你的应用名:latest + 192.168.10.236:31051/你的应用名:${{ steps.vars.outputs.sha_short }} \ No newline at end of file