-
Notifications
You must be signed in to change notification settings - Fork 1
82 lines (78 loc) · 3.1 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
name: build
on:
push:
branches:
- master
- main
pull_request:
branches:
- master
- main
env:
SECRETS_ARE_AVAILABLE: ${{ secrets.DOCKERHUB_USERNAME }}
BUILD_REPOSITORY: knicknic/wemo-auto-kotatsu
BUILD_PLATFORMS: linux/amd64,linux/arm/v6 # find a subset that will easily build
# BUILD_PLATFORMS: linux/amd64,linux/arm64,linux/ppc64le,linux/s390x,linux/386,linux/arm/v7,linux/arm/v6 # all platforms from available platforms that are also available from debian:latest
jobs:
amd64_only_build:
# create a quick build to get sane output and error messages
runs-on: ubuntu-latest
steps:
-
uses: actions/checkout@v2
-
#only installing this step because I couldn't figure out how to use build caching in docker otherwise
name: Set up Docker Buildx
id: buildx
uses: docker/setup-buildx-action@v1
with:
install: true
# above aliases `docker buildx build` as `docker build`
-
name: Build
run: |
docker build . --platform linux/amd64 --cache-from type=registry,ref=${{ env.BUILD_REPOSITORY }}:build
# DOCKER_BUILDKIT=1 docker build . --platform linux/amd64 --cache-from type=registry,ref=${{ env.BUILD_REPOSITORY }}:build
build_all_arch:
runs-on: ubuntu-latest
steps:
-
uses: actions/checkout@v2
-
name: Set up QEMU
uses: docker/setup-qemu-action@v1
-
name: Set up Docker Buildx
id: buildx
uses: docker/setup-buildx-action@v1
with:
install: true
# above aliases `docker buildx build` as `docker build`
-
name: Available platforms
run: echo ${{ steps.buildx.outputs.platforms }}
-
name: Build (run on PR from forks)
if: ${{ !env.SECRETS_ARE_AVAILABLE }}
# all platforms from available platforms that are also available from debian:latest
run: |
docker build . --platform ${{ env.BUILD_PLATFORMS }} --cache-from type=registry,ref=${{ env.BUILD_REPOSITORY }}:build
-
name: Login to Docker Hub
uses: docker/login-action@v1
if: ${{ env.SECRETS_ARE_AVAILABLE }}
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
-
name: Build and push cache (run on PR not from forks)
if: ${{ env.SECRETS_ARE_AVAILABLE && github.event_name != 'push' }}
# all platforms from available platforms that are also available from debian:latest
run: |
docker build . --platform ${{ env.BUILD_PLATFORMS }} --cache-from type=registry,ref=${{ env.BUILD_REPOSITORY }}:build --cache-to type=registry,ref=${{ env.BUILD_REPOSITORY }}:build,node=max,push=true
-
name: Build & push image & push cache
if: ${{ github.event_name == 'push' }}
# all platforms from available platforms that are also available from debian:latest
run: |
docker build . -t ${{ env.BUILD_REPOSITORY }}:test --platform ${{ env.BUILD_PLATFORMS }} --cache-from type=registry,ref=${{ env.BUILD_REPOSITORY }}:build --cache-to type=registry,ref=${{ env.BUILD_REPOSITORY }}:build,node=max,push=true --push