-
-
Notifications
You must be signed in to change notification settings - Fork 40
169 lines (151 loc) · 5.8 KB
/
deploy.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
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
# This workflow will publish the Docker image built in a previous job on Github container registry
name: Deploy Docker image
on:
push:
tags:
- "doorbell-v*"
jobs:
# Remove the prefix `doorbell-v` from the Git tag and set it as output of this step
extract-version:
name: Extract version from tag
runs-on: ubuntu-latest
# Map a step output to a job output
outputs:
version: ${{ steps.extract_version.outputs.version }}
steps:
- name: Extract version
id: extract_version
run: |
echo ${{ github.ref_name }} | sed -nr 's/doorbell-v(.*)/version=\1/p' >> $GITHUB_OUTPUT
docker-image_amd64:
name: Docker image (amd64)
runs-on: ubuntu-latest
needs: ["extract-version"]
permissions:
packages: write
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Docker metadata
id: meta
uses: docker/metadata-action@v4
with:
# list of Docker images to use as base name for tags
images: |
ghcr.io/${{ github.repository_owner }}/hikvision-doorbell
# generate Docker tags based on the following events/attributes
tags: |
# define match group
type=match,pattern=doorbell-v(.*),group=1
# Append architecture to generated tag
# Disable latest tag
flavor: |
latest=false
suffix=-amd64
labels: |
org.opencontainers.image.title=Hikvision Doorbell
# Custom label required by Home Assistant supervisor
#https://developers.home-assistant.io/docs/add-ons/configuration?_highlight=add&_highlight=on&_highlight=label#add-on-dockerfile
io.hass.version=${{ needs.extract-version.outputs.version }}
io.hass.type=addon
io.hass.arch=amd64
- name: Login to GitHub Container Registry
uses: docker/login-action@v2
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
- name: Build and export
uses: docker/build-push-action@v4
with:
context: ./hikvision-doorbell
file: ./hikvision-doorbell/Dockerfile
build-args: |
BUILD_ARCH=amd64
push: true
platforms: linux/amd64
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
# Disable provenance, since it creates problem with docker manifests
# https://github.com/docker/build-push-action/releases/tag/v4.0.0
provenance: false
docker-image_aarch64:
name: Docker image (aarch64)
runs-on: ubuntu-latest
needs: ["extract-version"]
permissions:
packages: write
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Docker metadata
id: meta
uses: docker/metadata-action@v4
with:
# list of Docker images to use as base name for tags
images: |
ghcr.io/${{ github.repository_owner }}/hikvision-doorbell
# generate Docker tags based on the following events/attributes
tags: |
# define match group
type=match,pattern=doorbell-v(.*),group=1
# Append architecture to generated tag
# Disable latest tag
flavor: |
latest=false
suffix=-aarch64
labels: |
org.opencontainers.image.title=Hikvision Doorbell
# Custom label required by Home Assistant supervisor
#https://developers.home-assistant.io/docs/add-ons/configuration?_highlight=add&_highlight=on&_highlight=label#add-on-dockerfile
io.hass.version=${{ needs.extract-version.outputs.version }}
io.hass.type=addon
io.hass.arch=aarch64
- name: Login to GitHub Container Registry
uses: docker/login-action@v2
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
- name: Build and export
uses: docker/build-push-action@v4
with:
context: ./hikvision-doorbell
file: ./hikvision-doorbell/Dockerfile
build-args: |
BUILD_ARCH=aarch64
push: true
platforms: linux/aarch64
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
# Disable provenance, since it creates problem with docker manifests
# https://github.com/docker/build-push-action/releases/tag/v4.0.0
provenance: false
update-manifest:
name: Update Docker image manifest
runs-on: ubuntu-latest
needs: [extract-version, docker-image_amd64, docker-image_aarch64]
permissions:
packages: write
steps:
- name: Login to GitHub Container Registry
uses: docker/login-action@v2
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Update image manifest and push it
run: |
VERSION=${{ needs.extract-version.outputs.version }}
echo VERSION=$VERSION
# Create a single manifest from the two images
docker manifest create \
ghcr.io/${{ github.repository_owner }}/hikvision-doorbell:$VERSION \
--amend ghcr.io/${{ github.repository_owner }}/hikvision-doorbell:$VERSION-amd64 \
--amend ghcr.io/${{ github.repository_owner }}/hikvision-doorbell:$VERSION-aarch64
# Push the updated manifest
docker manifest push ghcr.io/${{ github.repository_owner }}/hikvision-doorbell:$VERSION