-
Notifications
You must be signed in to change notification settings - Fork 2
68 lines (57 loc) · 1.92 KB
/
build-image.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
name: build-image
on:
push:
branches:
- "release-2.0"
tags:
- "v*"
paths:
- "**.go"
jobs:
build:
name: build-image
runs-on: ubuntu-latest
env:
GO111MODULE: on
steps:
- name: Set up Go 1.22.1
uses: actions/setup-go@v4
with:
go-version: 1.22.1
id: go
- name: Check out code into the Go module directory
uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Extract Tag
id: extract_tag
run: echo ::set-output name=version::${GITHUB_REF/refs\/tags\//}
- name: Extract branch name
shell: bash
run: echo "##[set-output name=branch;]$(echo ${GITHUB_REF#refs/heads/})"
id: extract_branch
- name: Set up docker buildx
id: buildx
uses: docker/setup-buildx-action@v2
with:
version: latest
- name: Available platforms
run: echo ${{ steps.buildx.outputs.platforms }}
- name: Docker login
env:
DOCKER_USERNAME: ${{ secrets.ALIYUN_REGISTRY_USERNAME }}
DOCKER_PASSWORD: ${{ secrets.ALIYUN_REGISTRY_PASSWORD }}
run: |
echo "${DOCKER_PASSWORD}" | docker login --username "${DOCKER_USERNAME}" --password-stdin registry.cn-shanghai.aliyuncs.com
- name: Run buildx
run: |
tag=latest
if [[ "${{ steps.extract_branch.outputs.branch }}" == "master" ]];then
tag=latest
elif [[ "${{ steps.extract_tag.outputs.version }}" == v* ]]; then
tag="${{ steps.extract_tag.outputs.version }}"
fi
echo extract_tag ${{ steps.extract_tag.outputs.version }}
echo extract_branch ${{ steps.extract_branch.outputs.branch }}
echo current tag is ${tag}
docker buildx build --platform linux/amd64,linux/arm64 --push -t registry.cn-shanghai.aliyuncs.com/openhydra/core-api-server:${tag} .