-
-
Notifications
You must be signed in to change notification settings - Fork 23
104 lines (104 loc) · 3.94 KB
/
nightly_docker.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
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
name: Nightly Docker build
on:
workflow_dispatch: null
schedule:
- cron: '0 2 * * *'
env:
REGISTRY: ghcr.io
jobs:
matrix:
runs-on: ubuntu-latest
name: Get matrix from json
outputs:
matrix: ${{ steps.vars.outputs.matrix }}
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Set up variables
id: vars
run: echo "matrix=$(jq -c . matrix.json)" >> $GITHUB_OUTPUT
build:
runs-on: ubuntu-latest
name: Build for ${{ matrix.image_name }}
needs: [matrix]
strategy:
max-parallel: 2
matrix: ${{ fromJson(needs.matrix.outputs.matrix) }}
steps:
- name: Set up QEMU
uses: docker/[email protected]
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
- name: Cache Docker layers
uses: actions/[email protected]
with:
path: /tmp/.buildx-cache
key: ${{ runner.os }}-buildx-${{ matrix.image_name }}-nightly-${{ github.sha }}
restore-keys: |
${{ runner.os }}-buildx-${{ matrix.image_name }}-nightly-
- name: Log in to the Container registry
uses: docker/[email protected]
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Build
uses: docker/[email protected]
with:
push: false
load: true
tags: |
${{ env.REGISTRY }}/congatudo/congatudo-nightly:${{ matrix.image_name }}-latest
cache-from: type=local,src=/tmp/.buildx-cache
cache-to: type=local,dest=/tmp/.buildx-cache-new
build-args: |
"BUILD_FROM=${{ matrix.build_from }}"
"PKG_TARGET=${{ matrix.pkg_target }}"
"PKG_OPTIONS=${{ matrix.pkg_options }}"
- name: Test
shell: '/bin/bash {0}'
run: |
docker run --rm ${{ env.REGISTRY }}/congatudo/congatudo-nightly:${{ matrix.image_name }}-latest
ret=$?
if [ $ret -eq 1 ]; then
exit 0
else
exit $ret
fi
- name: Push
run: |
docker push ${{ env.REGISTRY }}/congatudo/congatudo-nightly:${{ matrix.image_name }}-latest
- name: Move cache
run: |
rm -rf /tmp/.buildx-cache
mv /tmp/.buildx-cache-new /tmp/.buildx-cache
manifest:
runs-on: ubuntu-latest
name: Create and push manifest
needs: [build]
steps:
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
- name: Log in to the Container registry
uses: docker/[email protected]
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Create manifest
run: |
# TODO: Use matrix here.
docker manifest create ${{ env.REGISTRY }}/congatudo/congatudo-nightly:alpine-latest \
--amend ${{ env.REGISTRY }}/congatudo/congatudo-nightly:alpine-armv7-latest \
--amend ${{ env.REGISTRY }}/congatudo/congatudo-nightly:alpine-aarch64-latest \
--amend ${{ env.REGISTRY }}/congatudo/congatudo-nightly:alpine-amd64-latest
docker manifest create ${{ env.REGISTRY }}/congatudo/congatudo-nightly:homeassistant-latest \
--amend ${{ env.REGISTRY }}/congatudo/congatudo-nightly:homeassistant-armhf-latest \
--amend ${{ env.REGISTRY }}/congatudo/congatudo-nightly:homeassistant-armv7-latest \
--amend ${{ env.REGISTRY }}/congatudo/congatudo-nightly:homeassistant-aarch64-latest \
--amend ${{ env.REGISTRY }}/congatudo/congatudo-nightly:homeassistant-amd64-latest
- name: Push manifest
run: |
# TODO: Use matrix here.
docker manifest push ${{ env.REGISTRY }}/congatudo/congatudo-nightly:alpine-latest
docker manifest push ${{ env.REGISTRY }}/congatudo/congatudo-nightly:homeassistant-latest