fix: aliyun-metadata should have registry name for image

This commit is contained in:
Yuxing Deng 2024-10-21 20:59:39 +08:00
parent 4d17a53d3e
commit 1633838017
3 changed files with 23 additions and 8 deletions

View File

@ -8,6 +8,9 @@ on:
tags:
- "v*.*.*" # Matches any tag that starts with 'v' and follows semantic versioning
env:
ALIYUN_REGISTRY: ${{ vars.ALIYUN_REGISTRY || '' }}
jobs:
build-and-deploy:
runs-on: ubuntu-latest
@ -18,36 +21,35 @@ jobs:
fetch-depth: 0
- name: CI
env:
CROSS: push
SKIP_PACKAGE: "true"
run: make ci
- name: Prepare for packaging image
run: cp dist/* package/
# aliyun image to test the docker build is ok
- name: Login to Aliyun ACR
if: ${{ vars.ALIYUN_REGISTRY != '' }}
uses: docker/login-action@v3
with:
registry: registry.cn-shenzhen.aliyuncs.com
registry: ${{ env.ALIYUN_REGISTRY }}
username: ${{ secrets.ACR_USERNAME }}
password: ${{ secrets.ACR_TOKEN }}
if: ${{ vars.ALIYUN == 'true' }}
- name: Aliyun image docker meta
if: ${{ vars.ALIYUN == 'true' }}
if: ${{ vars.ALIYUN_REGISTRY != '' }}
id: aliyun-meta
uses: docker/metadata-action@v5
with:
images: ${{ vars.REPO || 'cnrancher' }}/${{ vars.IMAGE || 'kube-explorer' }}
images: ${{ env.ALIYUN_REGISTRY }}/${{ vars.REPO || 'cnrancher' }}/${{ vars.IMAGE || 'kube-explorer' }}
tags: |
type=ref,event=tag
type=ref,event=branch,suffix=-head
- name: Build to Aliyun
if: ${{ vars.ALIYUN_REGISTRY != '' }}
uses: docker/build-push-action@v6
with:
labels: ${{ steps.aliyun-meta.outputs.labels }}
tags: "${{ steps.aliyun-meta.outputs.tags }}"
context: package
push: true
if: ${{ vars.ALIYUN == 'true' }}
# docker hub multi-arch image
- name: Login to Dockerhub

View File

@ -44,6 +44,7 @@ builds:
- CGO_ENABLED=0
targets:
- "linux_amd64"
- "linux_arm64"
flags:
- -tags=embed
binary: '{{ .ProjectName }}-{{ .Os }}-{{ .Arch }}'

View File

@ -7,11 +7,23 @@ cd "$(dirname $0)/.."
rm -rf ./bin/* ./dist/*
BUILD_TARGET="${BUILD_TARGET:-dev}"
CROSS=${CROSS:-}
if [ -n "$CROSS" ]; then
BUILD_TARGET="prod"
if [[ $GITHUB_REF == refs/tags/* ]]; then
CROSS=tag
fi
case "$CROSS" in
"tag")
BUILD_TARGET="prod"
;;
"push")
;;
*)
BUILD_ARG="${BUILD_ARG} --single-target"
;;
esac
BUILD_ARG="${BUILD_ARG:-} --skip validate --id ${BUILD_TARGET}"
mkdir -p "./bin"