-
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdocker-kube-controllers-publish.yml
More file actions
154 lines (138 loc) · 5.76 KB
/
docker-kube-controllers-publish.yml
File metadata and controls
154 lines (138 loc) · 5.76 KB
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
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
name: Docker calico/kube-controllers
concurrency:
group: docker-kube-controllers-${{ github.head_ref }}
on:
workflow_dispatch: # Allow manual triggers
inputs:
tags:
description: 'Tags'
required: false
push:
# Publish `main` as Docker `latest` image.
branches:
- main
# Publish `v1.2.3` tags as releases.
tags:
- v*
env:
SITE: docker.io
# Change variable to your image's name.
IMAGE_NAME: calico-kube-controllers-openeuler
jobs:
build-amd64:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@main
- name: Pull from upstream
run: |
git clone https://github.com/projectcalico/calico
if [ ! -z "${{ github.event.inputs.tags }}" ]; then
cd calico; git reset --hard ${{ github.event.inputs.tags }}; cd ..;
fi
cp -arf kube-controllers/* calico/kube-controllers/
sed -i 's/docker build/docker buildx build --platform $(ARCH) --output type=docker/g' calico/kube-controllers/Makefile
- name: Log into Docker Hub
run: echo ${{ secrets.DOCKERHUB_PW }} | docker login $SITE -u ${{ secrets.DOCKERHUB_UN }} --password-stdin
- name: Build calico-kube-controllers-openeuler image and Push to Docker Hub
run: |
IMAGE_ID=$SITE/${{ secrets.DOCKERHUB_UN }}/$IMAGE_NAME
# Change all uppercase to lowercase
IMAGE_ID=$(echo $IMAGE_ID | tr '[A-Z]' '[a-z]')
if [ -z "${{ github.event.inputs.tags }}" ]
then
# Strip git ref prefix from version
VERSION=$(echo "${{ github.ref }}" | sed -e 's,.*/\(.*\),\1,')
# Strip "v" prefix from tag name
[[ "${{ github.ref }}" == "refs/tags/"* ]] && VERSION=$(echo $VERSION | sed -e 's/^v//')
# Use Docker `latest` tag convention
[ "$VERSION" == "main" ] && VERSION=latest
else
VERSION=${{ github.event.inputs.tags }}
fi
echo IMAGE_ID=$IMAGE_ID
echo VERSION=$VERSION
cd calico/kube-controllers
make image
docker tag calico/kube-controllers:latest $IMAGE_ID:${VERSION}-amd64
docker push $IMAGE_ID:${VERSION}-amd64
- name: Upload Build Dir to Artifact
uses: actions/upload-artifact@v2
with:
name: calico_kube-controllers_amd64
path: calico/kube-controllers/*
build-arm64:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@main
- name: Set up QEMU
uses: docker/setup-qemu-action@master
- name: Set up Docker Buildx
id: buildx
uses: docker/setup-buildx-action@master
- name: Pull from upstream
run: |
git clone https://github.com/projectcalico/calico
if [ ! -z "${{ github.event.inputs.tags }}" ]; then
cd calico; git reset --hard ${{ github.event.inputs.tags }}; cd ..;
fi
cp -arf kube-controllers/* calico/kube-controllers/
sed -i 's/docker build/docker buildx build --platform $(ARCH) --output type=docker/g' calico/kube-controllers/Makefile
- name: Log into Docker Hub
run: echo ${{ secrets.DOCKERHUB_PW }} | docker login $SITE -u ${{ secrets.DOCKERHUB_UN }} --password-stdin
- name: Build calico-kube-controllers-openeuler image and Push to Docker Hub
run: |
IMAGE_ID=$SITE/${{ secrets.DOCKERHUB_UN }}/$IMAGE_NAME
# Change all uppercase to lowercase
IMAGE_ID=$(echo $IMAGE_ID | tr '[A-Z]' '[a-z]')
if [ -z "${{ github.event.inputs.tags }}" ]
then
# Strip git ref prefix from version
VERSION=$(echo "${{ github.ref }}" | sed -e 's,.*/\(.*\),\1,')
# Strip "v" prefix from tag name
[[ "${{ github.ref }}" == "refs/tags/"* ]] && VERSION=$(echo $VERSION | sed -e 's/^v//')
# Use Docker `latest` tag convention
[ "$VERSION" == "main" ] && VERSION=latest
else
VERSION=${{ github.event.inputs.tags }}
fi
echo IMAGE_ID=$IMAGE_ID
echo VERSION=$VERSION
cd calico/kube-controllers
make sub-image-arm64
docker tag calico/kube-controllers:latest-arm64 $IMAGE_ID:${VERSION}-arm64
docker push $IMAGE_ID:${VERSION}-arm64
- name: Upload Build Dir to Artifact
uses: actions/upload-artifact@v2
with:
name: calico_kube-controllers_arm64
path: calico/kube-controllers/*
merge:
runs-on: ubuntu-latest
needs: [build-amd64, build-arm64]
steps:
- name: Checkout
uses: actions/checkout@main
- name: Log into Docker Hub
run: echo ${{ secrets.DOCKERHUB_PW }} | docker login $SITE -u ${{ secrets.DOCKERHUB_UN }} --password-stdin
- name: Build calico-kube-controllers-openeuler image and Push to Docker Hub
run: |
IMAGE_ID=$SITE/${{ secrets.DOCKERHUB_UN }}/$IMAGE_NAME
# Change all uppercase to lowercase
IMAGE_ID=$(echo $IMAGE_ID | tr '[A-Z]' '[a-z]')
if [ -z "${{ github.event.inputs.tags }}" ]
then
# Strip git ref prefix from version
VERSION=$(echo "${{ github.ref }}" | sed -e 's,.*/\(.*\),\1,')
# Strip "v" prefix from tag name
[[ "${{ github.ref }}" == "refs/tags/"* ]] && VERSION=$(echo $VERSION | sed -e 's/^v//')
# Use Docker `latest` tag convention
[ "$VERSION" == "main" ] && VERSION=latest
else
VERSION=${{ github.event.inputs.tags }}
fi
echo IMAGE_ID=$IMAGE_ID
echo VERSION=$VERSION
docker manifest create $IMAGE_ID:${VERSION} $IMAGE_ID:${VERSION}-amd64 $IMAGE_ID:${VERSION}-arm64
docker manifest push $IMAGE_ID:${VERSION}