-
Notifications
You must be signed in to change notification settings - Fork 4
151 lines (133 loc) · 5.61 KB
/
portainer-updater.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
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
name: portainer-updater
on:
workflow_dispatch:
push:
branches:
- develop
pull_request:
branches:
- develop
env:
DOCKER_HUB_REPO: portainerci/portainer-updater
jobs:
build_images:
if: github.event.pull_request.draft == false
runs-on: ubuntu-latest
strategy:
fail-fast: true
matrix:
config:
- { platform: linux, arch: amd64, version: "" }
- { platform: linux, arch: arm64, version: "" }
- { platform: linux, arch: arm, version: "" }
- { platform: linux, arch: ppc64le, version: "" }
- { platform: windows, arch: amd64, version: 1809 }
- { platform: windows, arch: amd64, version: ltsc2022 }
steps:
- name: "[preparation] checkout"
uses: actions/[email protected]
- name: "[preparation] set up qemu"
uses: docker/[email protected]
- name: "[preparation] set up docker context for buildx"
run: docker context create builders
- name: "[preparation] set up docker buildx"
uses: docker/[email protected]
with:
endpoint: builders
driver-opts: image=moby/buildkit:v0.16.0
- name: "[preparation] docker login"
uses: docker/[email protected]
with:
username: ${{ secrets.DOCKER_HUB_USERNAME }}
password: ${{ secrets.DOCKER_HUB_PASSWORD }}
- name: "[preparation] set the container image tag"
run: |
# set the container image tag prefix
if [[ "${GITHUB_REF_NAME}" =~ ^release/.*$ ]]; then
# use the release branch name as the tag for release branches
# for instance, release/2.19 becomes 2.19
TAG_PREFIX=$(echo $GITHUB_REF_NAME | cut -d "/" -f 2)
elif [ "${GITHUB_EVENT_NAME}" == "pull_request" ]; then
# use pr${{ github.event.number }} as the tag for pull requests
# for instance, pr123
TAG_PREFIX="pr${{ github.event.number }}"
else
# replace / with - in the branch name
# for instance, feature/1.0.0 -> feature-1.0.0
TAG_PREFIX=$(echo $GITHUB_REF_NAME | sed 's/\//-/g')
fi
# set the container image tag suffix
TAG_SUFFIX="${{ matrix.config.platform }}${{ matrix.config.version }}-${{ matrix.config.arch }}"
# set the container image tag
CONTAINER_IMAGE_TAG=${TAG_PREFIX}-${TAG_SUFFIX}
- name: "build and push images - linux"
if: ${{ matrix.config.platform == 'linux' }}
uses: docker/[email protected]
with:
context: .
tags: ${{ env.DOCKER_HUB_REPO }}:${{ env.CONTAINER_IMAGE_TAG }}
build-args: |
GIT_COMMIT=$(git log -1 --format=%h)
platforms: ${{ matrix.config.platform }}/${{ matrix.config.arch }}
file: build/${{ matrix.config.platform }}/Dockerfile
sbom: true
provenance: true
push: true
- name: "build and push images - windows"
if: ${{ matrix.config.platform == 'windows' }}
uses: docker/[email protected]
with:
context: .
tags: ${{ env.DOCKER_HUB_REPO }}:${{ env.CONTAINER_IMAGE_TAG }}
build-args: |
GIT_COMMIT=$(git log -1 --format=%h)
OSVERSION=${{ matrix.config.version }}
platforms: ${{ matrix.config.platform }}/${{ matrix.config.arch }}
file: build/${{ matrix.config.platform }}/Dockerfile
sbom: true
provenance: true
push: true
build_manifests:
if: github.event.pull_request.draft == false
runs-on: ubuntu-latest
needs: [build_images]
steps:
- name: '[preparation] docker login'
uses: docker/[email protected]
with:
username: ${{ secrets.DOCKER_HUB_USERNAME }}
password: ${{ secrets.DOCKER_HUB_PASSWORD }}
- name: '[preparation] set up docker context for buildx'
run: docker version && docker context create builders
- name: '[preparation] set up docker buildx'
uses: docker/[email protected]
with:
endpoint: builders
- name: "[preparation] set the container image tag"
run: |
# set the container image tag prefix
if [[ "${GITHUB_REF_NAME}" =~ ^release/.*$ ]]; then
# use the release branch name as the tag for release branches
# for instance, release/2.19 becomes 2.19
TAG_PREFIX=$(echo $GITHUB_REF_NAME | cut -d "/" -f 2)
elif [ "${GITHUB_EVENT_NAME}" == "pull_request" ]; then
# use pr${{ github.event.number }} as the tag for pull requests
# for instance, pr123
TAG_PREFIX="pr${{ github.event.number }}"
else
# replace / with - in the branch name
# for instance, feature/1.0.0 -> feature-1.0.0
TAG_PREFIX=$(echo $GITHUB_REF_NAME | sed 's/\//-/g')
fi
- name: '[execution] build and push manifests'
run: |
# Create image manifest
docker manifest create "${{ env.DOCKER_HUB_REPO }}:${TAG_PREFIX}" \
"${{ env.DOCKER_HUB_REPO }}:${TAG_PREFIX}-linux-amd64" \
"${{ env.DOCKER_HUB_REPO }}:${TAG_PREFIX}-linux-arm64" \
"${{ env.DOCKER_HUB_REPO }}:${TAG_PREFIX}-linux-arm" \
"${{ env.DOCKER_HUB_REPO }}:${TAG_PREFIX}-linux-ppc64le" \
"${{ env.DOCKER_HUB_REPO }}:${TAG_PREFIX}-windowsltsc2022-amd64" \
"${{ env.DOCKER_HUB_REPO }}:${TAG_PREFIX}-windows1809-amd64"
# Push image manifest to publish
docker manifest push "${{ env.DOCKER_HUB_REPO }}:${TAG_PREFIX}"