-
Notifications
You must be signed in to change notification settings - Fork 0
180 lines (150 loc) · 5.71 KB
/
docker-build.yaml
File metadata and controls
180 lines (150 loc) · 5.71 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
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
name: Docker build
# Controls when the workflow will run
on:
release:
types:
- published
pull_request:
branches:
- main
label:
types:
- created
- edited
- deleted
jobs:
check_labels:
name: Check labels
runs-on: ubuntu-latest
steps:
- uses: docker://agilepathway/pull-request-label-checker:latest
with:
one_of: major,minor,patch
any_of: bug,enhancement,chore
repo_token: ${{ secrets.GITHUB_TOKEN }}
build:
runs-on: ubuntu-latest
if: ${{ github.event_name != 'label' }}
strategy:
matrix:
base:
- alpine
- fedora
terraform:
- 1.6.3
- 1.7.7
- 1.8.7
- 1.9.0
env:
TERRAFORM_LATEST: "1.9.0"
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
- name: Set up Docker Buildx
id: buildx
uses: docker/setup-buildx-action@v3
- name: Login to Docker Hub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKER_USER }}
password: ${{ secrets.DOCKER_TOKEN }}
- name: Login to CNTK Quay
uses: docker/login-action@v3
with:
registry: quay.io
username: ${{ secrets.QUAY_CNTK_USERNAME }}
password: ${{ secrets.QUAY_CNTK_TOKEN }}
- name: Setup variables ${{ matrix.base }}:${{ matrix.terraform }}
id: variables
shell: bash
run: |
SHORT_TERRAFORM=$(echo ${{ matrix.terraform }} | sed -E "s/([0-9]+[.][0-9]+)[.][0-9]+/\1/g")
SHORT_TAG_ENABLED="false"
if [[ "${{ matrix.base }}" == "alpine" ]]; then
SHORT_TAG_ENABLED="true"
fi
BASE_ENABLED="false"
LATEST_ENABLED="false"
if [[ "${SHORT_TERRAFORM}" == "${TERRAFORM_LATEST}" ]]; then
BASE_ENABLED="true"
if [[ "${{ matrix.base }}" == "alpine" ]]; then
LATEST_ENABLED="true"
fi
fi
RELEASE_TAG=${GITHUB_REF#refs/tags/}
RELEASE_TAG_ENABLED="false"
RELEASE_TAG_SHORT_ENABLED="false"
if [[ "${GITHUB_REF}" =~ refs/tags ]] && [[ "${RELEASE_TAG}" != "main" ]]; then
RELEASE_TAG_ENABLED="true"
if [[ "${{ matrix.base }}" == "alpine" ]]; then
RELEASE_TAG_SHORT_ENABLED="true"
fi
else
RELEASE_TAG="main"
fi
echo "Short terraform: ${SHORT_TERRAFORM}"
echo "terraform=$SHORT_TERRAFORM" >> $GITHUB_OUTPUT
echo "Short tag enabled: $SHORT_TAG_ENABLED"
echo "short-enabled=$SHORT_TAG_ENABLED" >> $GITHUB_OUTPUT
echo "Release tag: ${RELEASE_TAG}"
echo "release-tag=$RELEASE_TAG" >> $GITHUB_OUTPUT
echo "Release tag enabled: $RELEASE_TAG_ENABLED"
echo "release-tag-enabled=$RELEASE_TAG_ENABLED" >> $GITHUB_OUTPUT
echo "Release tag short enabled: $RELEASE_TAG_SHORT_ENABLED"
echo "release-tag-short-enabled=$RELEASE_TAG_SHORT_ENABLED" >> $GITHUB_OUTPUT
echo "Base enabled: $BASE_ENABLED"
echo "base-enabled=$BASE_ENABLED" >> $GITHUB_OUTPUT
echo "Latest enabled: $LATEST_ENABLED"
echo "latest-enabled=$LATEST_ENABLED" >> $GITHUB_OUTPUT
- name: Docker CNTK meta ${{ matrix.base }}:${{ matrix.terraform }}
id: cntk-meta
uses: docker/metadata-action@v5
with:
# list of Docker images to use as base name for tags
images: |
quay.io/cloudnativetoolkit/terraform
# Docker tags based on the following events/attributes
tags: |
type=raw,value=v${{ steps.variables.outputs.terraform }}-${{ matrix.base }}
type=raw,value=v${{ steps.variables.outputs.terraform }},enable=${{ steps.variables.outputs.short-enabled }}
type=raw,value=v${{ steps.variables.outputs.terraform }}-${{ steps.variables.outputs.release-tag }}-${{ matrix.base }},enable=${{ steps.variables.outputs.release-tag-enabled }}
type=raw,value=v${{ steps.variables.outputs.terraform }}-${{ steps.variables.outputs.release-tag }},enable=${{ steps.variables.outputs.release-tag-short-enabled }}
type=raw,value=${{ matrix.base }},enable=${{ steps.variables.outputs.base-enabled }}
type=raw,value=latest,enable=${{ steps.variables.outputs.latest-enabled }}
- name: Build and push ${{ matrix.base }}:${{ matrix.terraform }}
uses: docker/build-push-action@v6
with:
context: .
file: Containerfile-${{ matrix.base }}
build-args: |
TERRAFORM_VERSION=${{ matrix.terraform }}
push: ${{ github.event_name != 'pull_request' }}
platforms: linux/amd64,linux/arm64
tags: ${{ steps.cntk-meta.outputs.tags }}
labels: ${{ steps.cntk-meta.outputs.labels }}
verify:
needs: ["build", "check_labels"]
runs-on: ubuntu-latest
steps:
- name: Verify
run: |
echo "Success"
notify:
needs: ["build"]
runs-on: ubuntu-latest
if: ${{ github.event_name != 'pull_request' }}
strategy:
matrix:
repo:
- cloud-native-toolkit/image-github-terraform-runner
- cloud-native-toolkit/image-cli-tools-core
steps:
- name: Repository dispatch ${{ matrix.repo }}
uses: cloud-native-toolkit/action-repository-dispatch@main
with:
notifyRepo: ${{ matrix.repo }}
eventType: released
env:
GITHUB_TOKEN: ${{ secrets.TOKEN }}