Skip to content

Commit bb71d1b

Browse files
committed
🦸‍ Home Assistant Supervised in Docker
1 parent 8638ed8 commit bb71d1b

File tree

1 file changed

+94
-11
lines changed

1 file changed

+94
-11
lines changed

.github/workflows/build.yml

Lines changed: 94 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -7,37 +7,120 @@ on:
77
description: Version
88
required: true
99

10+
env:
11+
DOCKERHUB_REPO: ${{ github.repository_owner }}/hass-super
12+
GITHUB_CR_REPO: ghcr.io/${{ github.repository_owner }}/hass-super
13+
1014
jobs:
1115
build:
1216
runs-on: ubuntu-latest
1317
strategy:
18+
fail-fast: false
1419
matrix:
15-
platform: [linux/amd64 ,linux/arm64, linux/arm/v7]
20+
platform: [linux/amd64, linux/arm64, linux/arm/v7]
1621

1722
steps:
23+
- name: Prepare
24+
run: |
25+
platform=${{ matrix.platform }}
26+
echo "PLATFORM_PAIR=${platform//\//-}" >> $GITHUB_ENV
27+
28+
- name: Docker meta
29+
id: meta
30+
uses: docker/metadata-action@v5
31+
with:
32+
images: |
33+
${{ env.DOCKERHUB_REPO }}
34+
${{ env.GITHUB_CR_REPO }}
35+
36+
- name: Login to Docker Hub
37+
uses: docker/login-action@v3
38+
with:
39+
username: ${{ github.repository_owner }}
40+
password: ${{ secrets.DOCKERHUB_TOKEN }}
1841

19-
- name: Checkout
20-
uses: actions/checkout@v4
42+
- name: Login to GHCR
43+
uses: docker/login-action@v3
44+
with:
45+
registry: ghcr.io
46+
username: ${{ github.repository_owner }}
47+
password: ${{ secrets.GITHUB_TOKEN }}
2148

2249
- name: Set up QEMU
2350
uses: docker/setup-qemu-action@v3
2451

2552
- name: Set up Docker Buildx
2653
uses: docker/setup-buildx-action@v3
2754

28-
- name: Login to GitHub Container Registry
55+
- name: Build and push by digest
56+
id: build
57+
uses: docker/build-push-action@v6
58+
with:
59+
platforms: ${{ matrix.platform }}
60+
labels: ${{ steps.meta.outputs.labels }}
61+
outputs: type=image,"name=${{ env.DOCKERHUB_REPO }},${{ env.GHCR_REPO }}",push-by-digest=true,name-canonical=true,push=true
62+
63+
- name: Export digest
64+
run: |
65+
mkdir -p ${{ runner.temp }}/digests
66+
digest="${{ steps.build.outputs.digest }}"
67+
touch "${{ runner.temp }}/digests/${digest#sha256:}"
68+
69+
- name: Upload digest
70+
uses: actions/upload-artifact@v4
71+
with:
72+
name: digests-${{ env.PLATFORM_PAIR }}
73+
path: ${{ runner.temp }}/digests/*
74+
if-no-files-found: error
75+
retention-days: 1
76+
77+
merge:
78+
runs-on: ubuntu-latest
79+
needs:
80+
- build
81+
steps:
82+
- name: Download digests
83+
uses: actions/download-artifact@v4
84+
with:
85+
path: ${{ runner.temp }}/digests
86+
pattern: digests-*
87+
merge-multiple: true
88+
89+
- name: Login to Docker Hub
90+
uses: docker/login-action@v3
91+
with:
92+
username: ${{ github.repository_owner }}
93+
password: ${{ secrets.DOCKERHUB_TOKEN }}
94+
95+
- name: Login to GHCR
2996
uses: docker/login-action@v3
3097
with:
3198
registry: ghcr.io
3299
username: ${{ github.repository_owner }}
33100
password: ${{ secrets.GITHUB_TOKEN }}
34101

35-
- name: Build and push
36-
uses: docker/build-push-action@v5
102+
- name: Set up Docker Buildx
103+
uses: docker/setup-buildx-action@v3
104+
105+
- name: Docker meta
106+
id: meta
107+
uses: docker/metadata-action@v5
37108
with:
38-
context: .
39-
platforms: ${{ matrix.platform }}
40-
push: true
109+
images: |
110+
${{ env.DOCKERHUB_REPO }}
111+
${{ env.GITHUB_CR_REPO }}
41112
tags: |
42-
ghcr.io/${{ github.repository_owner }}/hass-super:latest
43-
ghcr.io/${{ github.repository_owner }}/hass-super:${{ github.event.inputs.version }}
113+
type=raw,value=${{ github.event.inputs.version }}
114+
115+
- name: Create manifest list and push
116+
working-directory: ${{ runner.temp }}/digests
117+
run: |
118+
docker buildx imagetools create $(jq -cr '.tags | map("-t " + .) | join(" ")' <<< "$DOCKER_METADATA_OUTPUT_JSON") \
119+
$(printf '${{ env.DOCKERHUB_REPO }}@sha256:%s ' *)
120+
docker buildx imagetools create $(jq -cr '.tags | map("-t " + .) | join(" ")' <<< "$DOCKER_METADATA_OUTPUT_JSON") \
121+
$(printf '${{ env.GITHUB_CR_REPO }}@sha256:%s ' *)
122+
123+
- name: Inspect image
124+
run: |
125+
docker buildx imagetools inspect ${{ env.DOCKERHUB_REPO }}:${{ steps.meta.outputs.version }}
126+
docker buildx imagetools inspect ${{ env.GITHUB_CR_REPO }}:${{ steps.meta.outputs.version }}

0 commit comments

Comments
 (0)