迁移到drone CI
This commit is contained in:
parent
ef17019122
commit
acde6eab7a
|
|
@ -0,0 +1,31 @@
|
||||||
|
|
||||||
|
kind: pipeline
|
||||||
|
type: docker
|
||||||
|
name: build-and-push-arm64
|
||||||
|
|
||||||
|
platform:
|
||||||
|
os: linux
|
||||||
|
arch: arm64
|
||||||
|
trigger:
|
||||||
|
branch:
|
||||||
|
- main
|
||||||
|
event:
|
||||||
|
- push
|
||||||
|
|
||||||
|
steps:
|
||||||
|
|
||||||
|
- name: build-and-push-to-gitea
|
||||||
|
image: plugins/docker
|
||||||
|
settings:
|
||||||
|
registry: 192.168.0.75:3000
|
||||||
|
username:
|
||||||
|
from_secret: gitea_username
|
||||||
|
password:
|
||||||
|
from_secret: gitea_password
|
||||||
|
repo: 192.168.0.75:3000/guanyuankai/bonus-edge-proxy
|
||||||
|
tags:
|
||||||
|
- latest
|
||||||
|
|
||||||
|
dockerfile: docker/Dockerfile.prod
|
||||||
|
context: .
|
||||||
|
platforms: linux/arm64
|
||||||
|
|
@ -1,67 +0,0 @@
|
||||||
name: Build and Push Edge Proxy Image
|
|
||||||
|
|
||||||
on:
|
|
||||||
push:
|
|
||||||
branches:
|
|
||||||
- main # 1. 触发器:改为 push 到 'main' 分支时运行
|
|
||||||
# (如果您的主分支叫 'master',请改为 'master')
|
|
||||||
|
|
||||||
jobs:
|
|
||||||
build-and-push:
|
|
||||||
runs-on: arm-builder
|
|
||||||
|
|
||||||
steps:
|
|
||||||
# 步骤 1: 手动检出代码
|
|
||||||
- name: Manual Checkout
|
|
||||||
run: |
|
|
||||||
set -e
|
|
||||||
|
|
||||||
echo "正在手动检出代码... (Main 分支模式)"
|
|
||||||
|
|
||||||
REPO_DIR="repo"
|
|
||||||
rm -rf $REPO_DIR
|
|
||||||
mkdir $REPO_DIR
|
|
||||||
|
|
||||||
HARDCODED_REPO_URL="http://192.168.0.75:3000/guanyuankai/bonus-edge-proxy"
|
|
||||||
|
|
||||||
# ----------------- (关键变更) -----------------
|
|
||||||
# 2. 我们不再需要 Tag,我们总是检出 'main' 分支
|
|
||||||
HARDCODED_BRANCH="main"
|
|
||||||
# (如果您的主分支叫 'master',请改为 'master')
|
|
||||||
# ----------------- (变更结束) -----------------
|
|
||||||
|
|
||||||
echo "将要克隆的分支 = $HARDCODED_BRANCH"
|
|
||||||
|
|
||||||
REPO_URL_AUTH=$(echo "$HARDCODED_REPO_URL" | sed "s|://|://${{ gitea.actor }}:${{ secrets.cicd }}@|")
|
|
||||||
REPO_URL_WITH_CREDS="${REPO_URL_AUTH}.git"
|
|
||||||
|
|
||||||
echo "开始克隆分支: $HARDCODED_BRANCH 到 $REPO_DIR 目录..."
|
|
||||||
git clone --quiet --branch $HARDCODED_BRANCH $REPO_URL_WITH_CREDS $REPO_DIR
|
|
||||||
|
|
||||||
echo "代码检出成功。"
|
|
||||||
|
|
||||||
# 步骤 2: 登录 Gitea 容器注册表
|
|
||||||
- name: Login to Gitea Container Registry
|
|
||||||
run: |
|
|
||||||
echo ${{ secrets.cicd }} | docker login http://192.168.0.75:3000 -u ${{ gitea.actor }} --password-stdin
|
|
||||||
|
|
||||||
# 步骤 3: 构建并推送镜像
|
|
||||||
- name: Build and Push Image
|
|
||||||
run: |
|
|
||||||
set -e
|
|
||||||
|
|
||||||
cd repo
|
|
||||||
|
|
||||||
# ----------------- (关键变更) -----------------
|
|
||||||
# 3. 我们不再需要版本号,我们只构建 'latest'
|
|
||||||
LATEST_PATH="192.168.0.75:3000/guanyuankai/bonus-edge-proxy:latest"
|
|
||||||
# ----------------- (变更结束) -----------------
|
|
||||||
|
|
||||||
echo "Building and pushing $LATEST_PATH..."
|
|
||||||
|
|
||||||
docker buildx build \
|
|
||||||
--platform linux/arm64 \
|
|
||||||
--load \
|
|
||||||
-t $LATEST_PATH \
|
|
||||||
-f docker/Dockerfile.prod . \
|
|
||||||
--push
|
|
||||||
Loading…
Reference in New Issue