-
Notifications
You must be signed in to change notification settings - Fork 2
54 lines (48 loc) · 1.43 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
name: Build and Push Docker Images
on:
push:
branches:
- main
workflow_dispatch:
defaults:
run:
shell: "bash -Eeuo pipefail -x {0}"
jobs:
generate-jobs:
name: Generate Jobs
runs-on: ubuntu-latest
outputs:
strategy: ${{ steps.generate-jobs.outputs.strategy }}
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Generate Matrix
id: generate-jobs
run: |
strategy="$("./matrix.sh")"
echo "strategy=$strategy" >> "$GITHUB_OUTPUT"
jq . <<<"$strategy" # sanity check / debugging aid
build:
name: ${{ matrix.name }}
needs: generate-jobs
runs-on: ubuntu-latest
strategy:
matrix: ${{ fromJson(needs.generate-jobs.outputs.strategy) }}
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Login to DockerHub
uses: docker/login-action@v3
with:
username: ${{ vars.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Build and push
uses: docker/build-push-action@v5
with:
context: ${{ matrix.context }}
tags: ${{ matrix.tag }}
push: true
cache-from: type=gha,scope=${{ github.ref_name }}-${{ matrix.name }}
cache-to: type=gha,mode=max,scope=${{ github.ref_name }}-${{ matrix.name }}