Build Debian 12 Image (beta) #6
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Github action to build Debian12 image (Tag: beta) | |
name: Build Debian 12 Image (beta) | |
on: | |
release: | |
types: [prereleased] | |
workflow_dispatch: | |
inputs: | |
chose_node_version: | |
type: choice | |
description: 'Which Node version should be used?' | |
options: | |
- 'Recommended Node version (default)' | |
- 'Experimental Node version' | |
- 'Both Node versions' | |
jobs: | |
build-with-recommended-node: | |
if: inputs.chose_node_version == 'Recommended Node version (default)' || inputs.chose_node_version == 'Both Node versions' || github.event_name == 'release' | |
name: Build with recommended Node version | |
runs-on: ubuntu-latest | |
steps: | |
- name: Fetch latest prerelease tag | |
run: echo "RELEASE_TAG=${GITHUB_REF#refs/*/}" >> $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 | |
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:beta, | |
buanet/iobroker:${{ env.version }}, | |
ghcr.io/buanet/iobroker:beta, | |
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-with-experimental-node: | |
if: inputs.chose_node_version == 'Experimental Node version' || inputs.chose_node_version == 'Both Node versions' || github.event_name == 'release' | |
name: Build with experimental Node version | |
runs-on: ubuntu-latest | |
steps: | |
- name: Fetch latest prerelease tag | |
run: echo "RELEASE_TAG=${GITHUB_REF#refs/*/}" >> $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.EXPERIMENTAL_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.EXPERIMENTAL_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 | |
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/arm64/v8 | |
# linux/arm/v7 | |
tags: | | |
buanet/iobroker:beta-node${{ vars.EXPERIMENTAL_NODE_VERSION }}, | |
buanet/iobroker:${{ env.version }}-node${{ vars.EXPERIMENTAL_NODE_VERSION }}, | |
ghcr.io/buanet/iobroker:beta-node${{ vars.EXPERIMENTAL_NODE_VERSION }}, | |
ghcr.io/buanet/iobroker:${{ env.version }}-node${{ vars.EXPERIMENTAL_NODE_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-with-recommended-node, build-with-experimental-node] | |
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 |