-
Notifications
You must be signed in to change notification settings - Fork 1
62 lines (59 loc) · 1.97 KB
/
docker-build-push.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
name: Docker Build and Push
on:
push:
branches:
- "main"
jobs:
generate-matrix:
runs-on: ubuntu-latest
outputs:
matrix: ${{ steps.set-matrix.outputs.matrix }}
run_docker_jobs: ${{ steps.set-run-docker-jobs.outputs.run_docker_jobs }}
steps:
- name: Checkout code
uses: actions/checkout@v3
with:
fetch-depth: ${{ github.event_name == 'pull_request' && 2 || 0 }}
- name: Set Matrix
id: set-matrix
run: |
echo "matrix=$(python3 bin/generate_matrix.py submittyrpi false ${{ github.event.before }} ${{ github.event.after }})" >> $GITHUB_OUTPUT
- name: List Matrix
run: |
echo ${{ steps.set-matrix.outputs.matrix }}
- name: Set Run Condition
id: set-run-docker-jobs
run: |
num_to_build=$(echo '${{ steps.set-matrix.outputs.matrix }}' | jq '.include | length')
if [[ "$num_to_build" -eq 0 ]]; then
echo "run_docker_jobs=false" >> $GITHUB_OUTPUT
else
echo "run_docker_jobs=true" >> $GITHUB_OUTPUT
fi
docker:
needs:
- generate-matrix
if: needs.generate-matrix.outputs.run_docker_jobs == 'true'
runs-on: ubuntu-latest
strategy:
fail-fast: true
matrix: ${{ fromJson(needs.generate-matrix.outputs.matrix) }}
steps:
- name: Check out repo
uses: actions/checkout@v3
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Docker Hub login
uses: docker/login-action@releases/v1
with:
username: ${{ secrets.DOCKER_USERNAME_SUBMITTYRPI }}
password: ${{ secrets.DOCKER_PASSWORD_SUBMITTYRPI }}
- name: Build and push docker
uses: docker/build-push-action@v4
with:
context: ${{ matrix.context }}
push: true
tags: ${{ matrix.tags }}
platforms: linux/amd64,linux/arm64