manual checkout source code
Build and Push Edge Proxy Image / build-and-push (push) Failing after 0s
Details
Build and Push Edge Proxy Image / build-and-push (push) Failing after 0s
Details
This commit is contained in:
parent
877609dabf
commit
c6f277cf33
|
|
@ -1,30 +1,66 @@
|
||||||
name: Build and Push Edge Proxy Image
|
name: Build and Push Edge Proxy Image
|
||||||
|
|
||||||
on:
|
on:
|
||||||
# create:
|
push:
|
||||||
# tags:
|
branches:
|
||||||
# - 'v*.*.*'
|
- cicd-testing # 保持在测试分支触发
|
||||||
branches:
|
|
||||||
- cicd-testing
|
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
build-and-push:
|
build-and-push:
|
||||||
runs-on: arm64
|
runs-on: arm64
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
|
# 步骤 1: 手动检出代码
|
||||||
|
# 替代 "uses: actions/checkout@v3"
|
||||||
|
# 适用于 Runner 无法访问外网,但可以访问 Gitea 实例的场景
|
||||||
|
- name: Manual Checkout
|
||||||
|
run: |
|
||||||
|
echo "正在手动检出代码..."
|
||||||
|
echo "当前工作目录 (pwd):"
|
||||||
|
pwd
|
||||||
|
|
||||||
|
# 1. 清理 Runner 的工作目录 (以防万一)
|
||||||
|
# '|| true' 确保在目录为空时命令不会失败
|
||||||
|
echo "清理工作目录..."
|
||||||
|
rm -rf * .gitea .git || true
|
||||||
|
|
||||||
|
# 2. 构造带有身份验证的 Git URL
|
||||||
|
# 我们将使用您用于 Docker 登录的 gitea.actor 和 secrets.cicd
|
||||||
|
# gitea.repository_url = http://192.168.0.75:3000/guanyuankai/bonus-edge-proxy
|
||||||
|
# 转换后 = http://guanyuankai:YOUR_SECRET@192.168.0.75:3000/guanyuankai/bonus-edge-proxy.git
|
||||||
|
echo "构造 Git URL..."
|
||||||
|
REPO_URL_WITH_CREDS=$(echo "${{ gitea.repository_url }}" | sed "s|://|://${{ gitea.actor }}:${{ secrets.cicd }}@|").git
|
||||||
|
|
||||||
|
# 3. 执行 Git Clone
|
||||||
|
# gitea.ref_name = "cicd-testing" (即您的分支名)
|
||||||
|
# --branch 指定分支, '.' 表示克隆到当前目录
|
||||||
|
echo "开始克隆分支: ${{ gitea.ref_name }}"
|
||||||
|
git clone --quiet --branch ${{ gitea.ref_name }} $REPO_URL_WITH_CREDS .
|
||||||
|
|
||||||
|
echo "代码检出成功。当前目录内容:"
|
||||||
|
ls -la
|
||||||
|
echo "---"
|
||||||
|
echo "确认 'docker' 目录存在:"
|
||||||
|
ls -la docker
|
||||||
|
echo "---"
|
||||||
|
|
||||||
|
# 步骤 2: 登录 Gitea 容器注册表
|
||||||
- name: Login to Gitea Container Registry
|
- name: Login to Gitea Container Registry
|
||||||
run: |
|
run: |
|
||||||
echo ${{ secrets.cicd }} | docker login http://192.168.0.75:3000 -u ${{ gitea.actor }} --password-stdin
|
echo ${{ secrets.cicd }} | docker login http://192.168.0.75:3000 -u ${{ gitea.actor }} --password-stdin
|
||||||
|
|
||||||
|
# 步骤 3: 构建并推送镜像 (保持不变)
|
||||||
- name: Build and Push Image
|
- name: Build and Push Image
|
||||||
run: |
|
run: |
|
||||||
|
# 注意:您的 VERSION 变量现在是分支名 "cicd-testing"
|
||||||
|
# 这在测试阶段是OK的。
|
||||||
VERSION=$(echo ${{ gitea.ref_name }} | sed 's/v//')
|
VERSION=$(echo ${{ gitea.ref_name }} | sed 's/v//')
|
||||||
|
|
||||||
IMAGE_PATH="192.168.0.75:3000/guanyuankai/bonus-edge-proxy:${VERSION}"
|
IMAGE_PATH="192.168.0.75:3000/guanyuankai/bonus-edge-proxy:${VERSION}"
|
||||||
LATEST_PATH="192.168.0.75:3000/guanyuankai/bonus-edge-proxy:latest"
|
LATEST_PATH="192.168.0.75:3000/guanyuankai/bonus-edge-proxy:latest"
|
||||||
|
|
||||||
echo "Building and pushing $IMAGE_PATH..."
|
echo "Building and pushing $IMAGE_PATH..."
|
||||||
|
|
||||||
|
# 这里的路径 -f docker/Dockerfile.prod . 现在是正确的
|
||||||
docker buildx build \
|
docker buildx build \
|
||||||
--platform linux/arm64 \
|
--platform linux/arm64 \
|
||||||
-t $IMAGE_PATH \
|
-t $IMAGE_PATH \
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue