Skip to content
This repository was archived by the owner on Feb 11, 2025. It is now read-only.

Commit f2549d1

Browse files
committed
speedup workflows by adding matrix build
1 parent a7e097b commit f2549d1

File tree

2 files changed

+112
-14
lines changed

2 files changed

+112
-14
lines changed

.github/workflows/build-pr.yml

Lines changed: 47 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,26 @@ jobs:
4040
tags: |
4141
${{ env.IMAGE_BASE }}:base-pr-${{ github.event.pull_request.number }}
4242
43+
build_kaniko-sidecar:
44+
runs-on: ubuntu-latest
45+
needs: generate_infos
46+
steps:
47+
- name: Check out the repo
48+
uses: actions/checkout@v2
49+
50+
- name: Login to GitHub Container Registry
51+
uses: docker/login-action@v1
52+
with:
53+
registry: ghcr.io
54+
username: ${{ github.repository_owner }}
55+
password: ${{ secrets.GITHUB_TOKEN }}
56+
57+
- name: Set up QEMU
58+
uses: docker/setup-qemu-action@v1
59+
- name: Set up Docker Buildx
60+
id: buildx
61+
uses: docker/setup-buildx-action@v1
62+
4363
- name: Build github-actions-runner:kaniko-sidecar
4464
uses: docker/build-push-action@v2
4565
with:
@@ -48,24 +68,38 @@ jobs:
4868
tags: |
4969
${{ env.IMAGE_BASE }}:kaniko-sidecar-pr-${{ github.event.pull_request.number }}
5070
71+
build_flavors:
72+
runs-on: ubuntu-latest
73+
needs: [generate_infos, build_base]
74+
strategy:
75+
matrix:
76+
flavor: [ansible-k8s, fullstacked]
77+
steps:
78+
- name: Check out the repo
79+
uses: actions/checkout@v2
80+
81+
- name: Login to GitHub Container Registry
82+
uses: docker/login-action@v1
83+
with:
84+
registry: ghcr.io
85+
username: ${{ github.repository_owner }}
86+
password: ${{ secrets.GITHUB_TOKEN }}
87+
88+
- name: Set up QEMU
89+
uses: docker/setup-qemu-action@v1
90+
- name: Set up Docker Buildx
91+
id: buildx
92+
uses: docker/setup-buildx-action@v1
93+
5194
- name: link child image to current pr
5295
run: |
5396
sed -i --expression "s@FROM ${{ env.IMAGE_BASE }}.*@FROM ${{ env.IMAGE_BASE }}:base-pr-${{ github.event.pull_request.number }}@g" \
54-
images/ansible-k8s/Dockerfile \
55-
images/fullstacked/Dockerfile
56-
57-
- name: Build github-actions-runner:ansible-k8s
58-
uses: docker/build-push-action@v2
59-
with:
60-
context: ./images/ansible-k8s
61-
push: true
62-
tags: |
63-
${{ env.IMAGE_BASE }}:ansible-k8s-pr-${{ github.event.pull_request.number }}
97+
images/${{ matrix.flavor }}/Dockerfile
6498
65-
- name: Build github-actions-runner:fullstacked
99+
- name: Build github-actions-runner:${{ matrix.flavor }}
66100
uses: docker/build-push-action@v2
67101
with:
68-
context: ./images/fullstacked
102+
context: ./images/${{ matrix.flavor }}
69103
push: true
70104
tags: |
71-
${{ env.IMAGE_BASE }}:fullstacked-pr-${{ github.event.pull_request.number }}
105+
${{ env.IMAGE_BASE }}:${{ matrix.flavor }}-pr-${{ github.event.pull_request.number }}

.github/workflows/create-release.yml

Lines changed: 65 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ jobs:
1818
secrets:
1919
token: ${{ secrets.GITHUB_TOKEN }}
2020

21-
build:
21+
build_base:
2222
runs-on: ubuntu-latest
2323
needs: create_release
2424
steps:
@@ -80,6 +80,70 @@ jobs:
8080
${{ env.IMAGE_BASE }}:latest-fullstacked
8181
${{ env.IMAGE_BASE }}:${{needs.create_release.outputs.version}}-fullstacked
8282
83+
build_kaniko-sidecar:
84+
runs-on: ubuntu-latest
85+
needs: create_release
86+
steps:
87+
- name: Check out the repo
88+
uses: actions/checkout@v2
89+
90+
- name: Login to GitHub Container Registry
91+
uses: docker/login-action@v1
92+
with:
93+
registry: ghcr.io
94+
username: ${{ github.repository_owner }}
95+
password: ${{ secrets.GITHUB_TOKEN }}
96+
97+
- name: Set up QEMU
98+
uses: docker/setup-qemu-action@v1
99+
- name: Set up Docker Buildx
100+
uses: docker/setup-buildx-action@v1
101+
102+
- name: Build github-actions-runner:kaniko-sidecar
103+
uses: docker/build-push-action@v2
104+
with:
105+
context: ./images/kaniko-sidecar
106+
push: true
107+
tags: |
108+
${{ env.IMAGE_BASE }}:latest-kaniko-sidecar
109+
${{ env.IMAGE_BASE }}:${{needs.create_release.outputs.version}}-kaniko-sidecar
110+
111+
build_flavors:
112+
runs-on: ubuntu-latest
113+
needs: [create_release, build_base]
114+
strategy:
115+
matrix:
116+
flavor: [ansible-k8s, fullstacked]
117+
steps:
118+
- name: Check out the repo
119+
uses: actions/checkout@v2
120+
121+
- name: Login to GitHub Container Registry
122+
uses: docker/login-action@v1
123+
with:
124+
registry: ghcr.io
125+
username: ${{ github.repository_owner }}
126+
password: ${{ secrets.GITHUB_TOKEN }}
127+
128+
- name: Set up QEMU
129+
uses: docker/setup-qemu-action@v1
130+
- name: Set up Docker Buildx
131+
uses: docker/setup-buildx-action@v1
132+
133+
- name: link child image to current version
134+
run: |
135+
sed -i --expression "s@FROM ${{ env.IMAGE_BASE }}.*@FROM ${{ env.IMAGE_BASE }}:${{needs.create_release.outputs.version}}-base@g" \
136+
images/${{ matrix.flavor }}/Dockerfile
137+
138+
- name: Build github-actions-runner:${{ matrix.flavor }}
139+
uses: docker/build-push-action@v2
140+
with:
141+
context: ./images/${{ matrix.flavor }}
142+
push: true
143+
tags: |
144+
${{ env.IMAGE_BASE }}:latest-${{ matrix.flavor }}
145+
${{ env.IMAGE_BASE }}:${{needs.create_release.outputs.version}}-${{ matrix.flavor }}
146+
83147
publish_release:
84148
runs-on: ubuntu-latest
85149
needs: [create_release, build]

0 commit comments

Comments
 (0)