forked from ericfrederich/docker-ampache
-
Notifications
You must be signed in to change notification settings - Fork 68
54 lines (47 loc) · 1.58 KB
/
build-image-dynamic-strategy.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: Dynamic Docker Multi-Platform Build
on:
push:
branches:
- master
pull_request:
branches:
- master
jobs:
generate-matrix:
name: Generate Jobs
runs-on: ubuntu-latest
outputs:
strategy: ${{ steps.generate-jobs.outputs.strategy }}
steps:
- name: Checkout repository
uses: actions/checkout@v2
- id: generate-jobs
name: Generate Jobs
run: |
strategy_content=""
versions=$(ls -d */ | grep '^[0-9]' | sed 's#/##')
for version in $versions; do
variants=$(cd $version; ls -d */ | sed 's#/##')
for variant in $variants; do
strategy_content="$strategy_content,{\"version\":\"$version\",\"variant\":\"$variant\"}"
done
done
strategy="{\"include\":[ ${strategy_content:1} ]}"
echo "strategy=$strategy" >> "$GITHUB_OUTPUT"
jq . <<<"$strategy" # sanity check / debugging aid
build:
needs: generate-matrix
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix: ${{ fromJson(needs.generate-matrix.outputs.strategy) }}
steps:
- name: Checkout repository
uses: actions/checkout@v2
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v1
- name: Build Docker image for ${{ matrix.version }}-${{ matrix.variant }}
run: |
cd ${{ matrix.version }}/${{ matrix.variant }}
docker buildx build --platform linux/amd64,linux/arm64 -t odyssey/ampache:${{ matrix.version }}-${{ matrix.variant }} .
cd ../../