Files
rustfs-s3-toolkit/.gitea/workflows/build-and-push.yml
hotwa 3e4981a74d
Some checks failed
Build and Push to ACR / docker (push) Failing after 14m21s
use host.docker.internal proxy build
2025-09-30 16:47:16 +08:00

83 lines
2.6 KiB
YAML
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
name: Build and Push to ACR
on:
push:
branches: [ main ]
release:
types: [ published ]
workflow_dispatch:
inputs:
image_tag:
description: "Tag to push (leave empty to use 'latest')"
required: false
default: ""
jobs:
docker:
runs-on: [buildx]
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Resolve TAG
id: meta
env:
INPUT_TAG: ${{ github.event.inputs.image_tag || '' }}
run: |
set -euo pipefail
# 仅两级:手动输入 > latest
TAG="${INPUT_TAG:-}"
if [ -z "$TAG" ]; then TAG="latest"; fi
# 规范化(可留可去,但推荐保留,防止手滑输非法字符)
TAG="$(printf '%s' "$TAG" \
| tr '[:upper:]' '[:lower:]' \
| sed -E 's#[^a-z0-9._-]#-#g; s#/+#-#g; s#^[.-]+##; s#[.-]+$##')"
TAG="${TAG:0:128}"
echo "tag=$TAG" >> "$GITHUB_OUTPUT"
echo "Resolved TAG: $TAG"
- name: Login to Aliyun ACR
env:
ACR_REGISTRY: ${{ secrets.ACR_REGISTRY }}
ACR_USERNAME: ${{ secrets.ACR_USERNAME }}
ACR_PASSWORD: ${{ secrets.ACR_PASSWORD }}
run: |
set -euo pipefail
docker logout "$ACR_REGISTRY" || true
echo "$ACR_PASSWORD" | docker login "$ACR_REGISTRY" \
--username "$ACR_USERNAME" --password-stdin
- name: Build Docker Image (via host proxy)
env:
IMAGE: ${{ secrets.ACR_REGISTRY }}/${{ secrets.ACR_NAMESPACE }}/${{ vars.IMAGE_NAME }}
TAG: ${{ steps.meta.outputs.tag }}
run: |
set -euo pipefail
docker buildx build \
--progress=plain \
--add-host=host.docker.internal:host-gateway \
--build-arg HTTP_PROXY=http://host.docker.internal:7890 \
--build-arg HTTPS_PROXY=http://host.docker.internal:7890 \
--build-arg NO_PROXY=localhost,127.0.0.1 \
--load \
-t "${IMAGE}:${TAG}" -f docker/Dockerfile .
- name: Push Docker Image
env:
IMAGE: ${{ secrets.ACR_REGISTRY }}/${{ secrets.ACR_NAMESPACE }}/${{ vars.IMAGE_NAME }}
TAG: ${{ steps.meta.outputs.tag }}
run: |
set -euo pipefail
echo "Pushing ${IMAGE}:${TAG}"
docker push "${IMAGE}:${TAG}"
# 如果上一步给了 latest这里一并推
if docker image inspect "${IMAGE}:latest" > /dev/null 2>&1; then
echo "Pushing ${IMAGE}:latest"
docker push "${IMAGE}:latest"
fi