-
Notifications
You must be signed in to change notification settings - Fork 68
176 lines (159 loc) · 7.12 KB
/
build-debian12-latest.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
170
171
172
173
174
175
176
# Github action to build Debian12 image (Tag: latest)
name: Build Debian 12 Image (latest)
on:
release:
types: [released]
workflow_dispatch:
jobs:
build-latest-for-buanet:
name: Build latest image for buanet
runs-on: ubuntu-latest
steps:
- name: Fetch latest release tag
run: |
LATESTRELEASE="$(curl -sL https://api.github.com/repos/buanet/ioBroker.docker/releases/latest | jq -r '.tag_name')"
echo "Latest release tag : $LATESTRELEASE"
echo "RELEASE_TAG=$LATESTRELEASE" >> $GITHUB_ENV
- name: Checkout repo
uses: actions/[email protected]
with:
repository: 'buanet/ioBroker.docker'
ref: ${{ env.RELEASE_TAG }}
- name: Set job variables
run: |
VERSION="$(cat .VERSION)"
MAJORVERSION="$(cat .VERSION | cut -c 1-2 | sed -r 's#^(.{0})#\1latest-#')"
DATI="$(date --rfc-3339=seconds | sed 's/ /T/')"
# Log output and export as Github environment variable
echo "[LOG] Nodejs Version: ${{ vars.RECOMMENDED_NODE_VERSION }}"
echo "[LOG] Image Version: $VERSION"
echo "version=$VERSION" >> $GITHUB_ENV
echo "[LOG] Major Image Version: $MAJORVERSION"
echo "majorversion=$MAJORVERSION" >> $GITHUB_ENV
echo "[LOG] Buildnumber/Timestamp: $DATI"
echo "dati=$DATI" >> $GITHUB_ENV
# Set values in iobroker_startup.sh
sed -e "s/\${VERSION}/$VERSION/" -e "s/\${BUILD}/$DATI/" ./debian12/scripts/iobroker_startup.sh > ./debian12/scripts/iobroker_startup.tmp
mv -f ./debian12/scripts/iobroker_startup.tmp ./debian12/scripts/iobroker_startup.sh
# Set values in Dockerfile
sed -e "s/\${VERSION}/$VERSION/" -e "s/\${DATI}/$DATI/" -e "s/\${NODE}/${{ vars.RECOMMENDED_NODE_VERSION }}/" ./debian12/Dockerfile > ./debian12/Dockerfile.tmp
mv -f ./debian12/Dockerfile.tmp ./debian12/Dockerfile
- name: Set up QEMU
uses: docker/[email protected]
- name: Set up Docker Buildx
id: buildx
uses: docker/[email protected]
- name: Login to DockerHub (buanet)
uses: docker/[email protected]
with:
username: ${{ secrets.DOCKER_USER }}
password: ${{ secrets.DOCKER_PASS }}
- name: Login to GitHub Container Registry
uses: docker/[email protected]
with:
registry: ghcr.io
username: ${{ secrets.PACKAGES_USER }}
password: ${{ secrets.PACKAGES_PASS }}
- name: Build and push Docker image
uses: docker/[email protected]
with:
context: ./debian12
file: ./debian12/Dockerfile
push: true
platforms: |
linux/amd64
linux/arm/v7
linux/arm64/v8
tags: |
buanet/iobroker:latest,
buanet/iobroker:${{ env.majorversion }},
buanet/iobroker:${{ env.version }},
ghcr.io/buanet/iobroker:latest,
ghcr.io/buanet/iobroker:${{ env.majorversion }},
ghcr.io/buanet/iobroker:${{ env.version }}
provenance: false
outputs: type=image,name=target,annotation-index.org.opencontainers.image.description=Official Docker image for ioBroker smarthome software (https://www.iobroker.net)
build-latest-for-iobroker:
name: Build latest image for iobroker
runs-on: ubuntu-latest
steps:
- name: Fetch latest release tag
run: |
LATESTRELEASE="$(curl -sL https://api.github.com/repos/buanet/ioBroker.docker/releases/latest | jq -r '.tag_name')"
echo "Latest release tag : $LATESTRELEASE"
echo "RELEASE_TAG=$LATESTRELEASE" >> $GITHUB_ENV
- name: Checkout repo
uses: actions/[email protected]
with:
repository: 'buanet/ioBroker.docker'
ref: ${{ env.RELEASE_TAG }}
- name: Set job variables
run: |
VERSION="$(cat .VERSION)"
MAJORVERSION="$(cat .VERSION | cut -c 1-2 | sed -r 's#^(.{0})#\1latest-#')"
DATI="$(date --rfc-3339=seconds | sed 's/ /T/')"
# Log output and export as Github environment variable
echo "[LOG] Nodejs Version: ${{ vars.RECOMMENDED_NODE_VERSION }}"
echo "[LOG] Image Version: $VERSION"
echo "version=$VERSION" >> $GITHUB_ENV
echo "[LOG] Major Image Version: $MAJORVERSION"
echo "majorversion=$MAJORVERSION" >> $GITHUB_ENV
echo "[LOG] Buildnumber/Timestamp: $DATI"
echo "dati=$DATI" >> $GITHUB_ENV
# Set values in iobroker_startup.sh
sed -e "s/\${VERSION}/$VERSION/" -e "s/\${BUILD}/$DATI/" ./debian12/scripts/iobroker_startup.sh > ./debian12/scripts/iobroker_startup.tmp
mv -f ./debian12/scripts/iobroker_startup.tmp ./debian12/scripts/iobroker_startup.sh
# Set values in Dockerfile
sed -e "s/\${VERSION}/$VERSION/" -e "s/\${DATI}/$DATI/" -e "s/\${NODE}/${{ vars.RECOMMENDED_NODE_VERSION }}/" ./debian12/Dockerfile > ./debian12/Dockerfile.tmp
mv -f ./debian12/Dockerfile.tmp ./debian12/Dockerfile
- name: Set up QEMU
uses: docker/[email protected]
- name: Set up Docker Buildx
id: buildx
uses: docker/[email protected]
- name: Login to DockerHub (buanet)
uses: docker/[email protected]
with:
username: ${{ secrets.DOCKER_USER_IOB }}
password: ${{ secrets.DOCKER_PASS_IOB }}
- name: Build and push Docker image
uses: docker/[email protected]
with:
context: ./debian12
file: ./debian12/Dockerfile
push: true
platforms: |
linux/amd64
linux/arm/v7
linux/arm64/v8
tags: |
iobroker/iobroker:latest,
iobroker/iobroker:${{ env.majorversion }},
iobroker/iobroker:${{ env.version }},
provenance: false
outputs: type=image,name=target,annotation-index.org.opencontainers.image.description=Official Docker image for ioBroker smarthome software (https://www.iobroker.net)
delete-untagged-images:
if: ${{ always() }}
needs: [build-latest-for-buanet, build-latest-for-iobroker]
name: Delete untagged images from GitHub Container Registry
runs-on: ubuntu-latest
steps:
- name: Delete images
uses: actions/[email protected]
with:
github-token: ${{ secrets.PACKAGES_PASS }}
script: |
const response = await github.request("GET /users/${{ env.OWNER }}/packages/container/${{ env.PACKAGE_NAME }}/versions",
{ per_page: ${{ env.PER_PAGE }}
});
for(version of response.data) {
if (version.metadata.container.tags.length == 0) {
console.log("delete " + version.id)
const deleteResponse = await github.request("DELETE /user/packages/container/${{ env.PACKAGE_NAME }}/versions/" + version.id, { });
console.log("status " + deleteResponse.status)
}
}
env:
OWNER: buanet
PACKAGE_NAME: iobroker
PER_PAGE: 100