Skip to content

Commit

Permalink
fix: aliyun-metadata should have registry name for image
Browse files Browse the repository at this point in the history
  • Loading branch information
orangedeng committed Oct 21, 2024
1 parent 4d17a53 commit 1633838
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 8 deletions.
14 changes: 8 additions & 6 deletions .github/workflows/push.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down
1 change: 1 addition & 0 deletions .goreleaser.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ builds:
- CGO_ENABLED=0
targets:
- "linux_amd64"
- "linux_arm64"
flags:
- -tags=embed
binary: '{{ .ProjectName }}-{{ .Os }}-{{ .Arch }}'
Expand Down
16 changes: 14 additions & 2 deletions scripts/build
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down

0 comments on commit 1633838

Please sign in to comment.