forked from higress-group/higress-standalone
-
Notifications
You must be signed in to change notification settings - Fork 0
72 lines (63 loc) · 2.18 KB
/
build-runner-image-and-push.yaml
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
69
70
71
72
name: Build Runner Image and Push to Image Registry
on:
push:
tags:
- "runner-v*.*.*"
workflow_dispatch: ~
jobs:
build-runner-image:
runs-on: ubuntu-latest
env:
IMAGE_REGISTRY: ${{ vars.IMAGE_REGISTRY || 'higress-registry.cn-hangzhou.cr.aliyuncs.com' }}
IMAGE_NAME: ${{ vars.RUNNER_IMAGE_NAME || 'higress/runner' }}
steps:
- name: "Checkout ${{ github.ref }}"
uses: actions/checkout@v3
with:
fetch-depth: 1
- name: "Setup Go"
uses: actions/setup-go@v3
with:
go-version: 1.21.5
- name: Setup Golang Caches
uses: actions/cache@v3
with:
path: |-
~/.cache/go-build
~/go/pkg/mod
key: ${{ runner.os }}-go-${{ github.run_id }}
restore-keys: ${{ runner.os }}-go
- name: Calculate Docker metadata
id: docker-meta
uses: docker/metadata-action@v4
with:
images: |
${{ env.IMAGE_REGISTRY }}/${{ env.IMAGE_NAME }}
tags: |
type=sha
type=match,pattern=runner-v(.*),group=1
type=raw,value=latest,enable=${{ github.ref == format('refs/heads/{0}', 'main') }}
- name: Login to Docker Registry
uses: docker/login-action@v2
with:
registry: ${{ env.IMAGE_REGISTRY }}
username: ${{ secrets.REGISTRY_USERNAME }}
password: ${{ secrets.REGISTRY_PASSWORD }}
- name: Set up QEMU
uses: docker/setup-qemu-action@v2
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
- name: Build Docker Image and Push
run: |
cd src/runner/
readarray -t IMAGES <<< "${{ steps.docker-meta.outputs.tags }}"
baseImage=""
for image in ${IMAGES[@]}; do
echo "Image: $image"
if [ -z "$baseImage" ]; then
GOPROXY="https://proxy.golang.org,direct" IMG="${image}" make docker-buildx-push
baseImage="$image"
else
docker buildx imagetools create "$baseImage" --tag "$image"
fi
done