-
Notifications
You must be signed in to change notification settings - Fork 525
185 lines (183 loc) · 7.03 KB
/
build.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
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
181
182
183
184
185
#
# Copyright 2021 The Dapr Authors
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
# http://www.apache.org/licenses/LICENSE-2.0
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
name: Build Quickstarts
on:
push:
branches:
- master
- feature/new_quickstarts
- release-*
tags:
- v*
paths-ignore:
- '**.md'
workflow_dispatch:
jobs:
build:
name: Build ${{ matrix.target_os }}_${{ matrix.target_arch }} binaries
runs-on: ${{ matrix.os }}
env:
TARGET_OS: ${{ matrix.target_os }}
TARGET_ARCH: ${{ matrix.target_arch }}
DOCKER_CLI_EXPERIMENTAL: enabled
SAMPLE_REGISTRY: ${{ vars.SAMPLE_REGISTRY }}
strategy:
matrix:
os: [ubuntu-latest]
target_arch: [arm, arm64, amd64]
include:
- os: ubuntu-latest
target_os: linux
steps:
- name: Check Docker version
run: docker --version
- name: Set REPO_OWNER
run: |
REPO_OWNER=${{ github.repository_owner }}
# Lowercase the value
echo "REPO_OWNER=${REPO_OWNER,,}" >>${GITHUB_ENV}
shell: bash
- name: Check out code
uses: actions/checkout@v2
- name: Parse release version and set REL_VERSION
run: python ./.github/scripts/get_release_version.py
- name: Set up QEMU
uses: docker/setup-qemu-action@v1
if: ${{ matrix.target_arch == 'arm' || matrix.target_arch == 'arm64' }}
with:
image: tonistiigi/binfmt:latest
platforms: arm,arm64
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v1
with:
version: v0.9.1 # Don't use latest since it broke our workflow once
- name: Build docker image
run: |
SAMPLE_LIST=(tutorials/hello-kubernetes tutorials/distributed-calculator tutorials/pub-sub tutorials/bindings tutorials/observability tutorials/secretstore)
for sample in "${SAMPLE_LIST[@]}"; do
echo "Building image for ${sample}..."
pushd ${sample}
make build
popd
done
- name: docker login
run: |
docker login -u ${{ secrets.DOCKER_REGISTRY_ID }} -p ${{ secrets.DOCKER_REGISTRY_PASS }}
- name: publish image to dockerhub
run: |
SAMPLE_LIST=(tutorials/hello-kubernetes tutorials/distributed-calculator tutorials/pub-sub tutorials/bindings tutorials/observability tutorials/secretstore)
for sample in "${SAMPLE_LIST[@]}"; do
echo "Push image for ${sample}..."
pushd ${sample}
make push
popd
done
- name: GitHub container registry login
if: github.event_name != 'pull_request'
uses: docker/login-action@v1
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Build docker image
env:
SAMPLE_REGISTRY: ghcr.io/${{ env.REPO_OWNER }}/samples
run: |
SAMPLE_LIST=(tutorials/hello-kubernetes tutorials/distributed-calculator tutorials/pub-sub tutorials/bindings tutorials/observability tutorials/secretstore)
for sample in "${SAMPLE_LIST[@]}"; do
echo "Building image for ${sample}..."
pushd ${sample}
make build
popd
done
- name: publish image to ghcr
if: github.event_name != 'pull_request'
env:
SAMPLE_REGISTRY: ghcr.io/${{ env.REPO_OWNER }}/samples
run: |
SAMPLE_LIST=(tutorials/hello-kubernetes tutorials/distributed-calculator tutorials/pub-sub tutorials/bindings tutorials/observability tutorials/secretstore)
for sample in "${SAMPLE_LIST[@]}"; do
echo "Push image for ${sample}..."
pushd ${sample}
make push
popd
done
publish:
name: Publish docker manifest
needs: build
runs-on: ubuntu-latest
env:
DOCKER_CLI_EXPERIMENTAL: enabled
SAMPLE_REGISTRY: ${{ vars.SAMPLE_REGISTRY }}
steps:
- name: Set REPO_OWNER
run: |
REPO_OWNER=${{ github.repository_owner }}
# Lowercase the value
echo "REPO_OWNER=${REPO_OWNER,,}" >>${GITHUB_ENV}
- name: Check out code
uses: actions/checkout@v2
- name: Parse release version and set REL_VERSION
run: python ./.github/scripts/get_release_version.py
- name: docker login
run: |
docker login -u ${{ secrets.DOCKER_REGISTRY_ID }} -p ${{ secrets.DOCKER_REGISTRY_PASS }}
- name: create docker manifest
run: |
SAMPLE_LIST=(tutorials/hello-kubernetes tutorials/distributed-calculator tutorials/pub-sub tutorials/bindings tutorials/observability tutorials/secretstore)
for sample in "${SAMPLE_LIST[@]}"; do
echo "Building image for ${sample}..."
pushd ${sample}
make manifest-create
popd
done
- name: publish manifest to dockerhub
run: |
SAMPLE_LIST=(tutorials/hello-kubernetes tutorials/distributed-calculator tutorials/pub-sub tutorials/bindings tutorials/observability tutorials/secretstore)
for sample in "${SAMPLE_LIST[@]}"; do
echo "Push image for ${sample}..."
pushd ${sample}
make manifest-push
popd
done
- name: GitHub container registry login
if: github.event_name != 'pull_request'
uses: docker/login-action@v1
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: create ghcr manifest
if: github.event_name != 'pull_request'
env:
SAMPLE_REGISTRY: ghcr.io/${{ env.REPO_OWNER }}/samples
run: |
SAMPLE_LIST=(tutorials/hello-kubernetes tutorials/distributed-calculator tutorials/pub-sub tutorials/bindings tutorials/observability tutorials/secretstore)
for sample in "${SAMPLE_LIST[@]}"; do
echo "Building image for ${sample}..."
pushd ${sample}
make manifest-create
popd
done
- name: publish manifest to ghcr
if: github.event_name != 'pull_request'
env:
SAMPLE_REGISTRY: ghcr.io/${{ env.REPO_OWNER }}/samples
run: |
SAMPLE_LIST=(tutorials/hello-kubernetes tutorials/distributed-calculator tutorials/pub-sub tutorials/bindings tutorials/observability tutorials/secretstore)
for sample in "${SAMPLE_LIST[@]}"; do
echo "Push image for ${sample}..."
pushd ${sample}
make manifest-push
popd
done