From ca11192265a6c2cbab84b0c73da16808cfc674e5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9=20Germann?= Date: Sun, 3 Sep 2023 22:27:11 +0200 Subject: [PATCH] Create build-debian12-dev.yml --- .github/workflows/build-debian12-dev.yml | 92 ++++++++++++++++++++++++ 1 file changed, 92 insertions(+) create mode 100644 .github/workflows/build-debian12-dev.yml diff --git a/.github/workflows/build-debian12-dev.yml b/.github/workflows/build-debian12-dev.yml new file mode 100644 index 0000000..3eb0015 --- /dev/null +++ b/.github/workflows/build-debian12-dev.yml @@ -0,0 +1,92 @@ +# Github action to build Debian12 image (Tag: dev) +name: Build Debian 12 Image (dev) + +on: + workflow_dispatch: + +jobs: + build-dev-image: + runs-on: ubuntu-latest + steps: + - name: Checkout repo + uses: actions/checkout@v3.6.0 + with: + repository: 'buanet/ioBroker.docker' + + - name: Set job variables + run: | + NODE="18" + 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: $NODE" + echo "node=$NODE" >> $GITHUB_ENV + 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-dev/" -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-dev/" -e "s/\${DATI}/$DATI/" -e "s/\${NODE}/$NODE/" ./debian12/Dockerfile > ./debian12/Dockerfile.tmp + mv -f ./debian12/Dockerfile.tmp ./debian12/Dockerfile + + - name: Set up QEMU + uses: docker/setup-qemu-action@v2.2.0 + + - name: Set up Docker Buildx + id: buildx + uses: docker/setup-buildx-action@v2.10.0 + + - name: Login to DockerHub + uses: docker/login-action@v2.2.0 + with: + username: ${{ secrets.DOCKER_USER }} + password: ${{ secrets.DOCKER_PASS }} + + - name: Login to GitHub Container Registry + uses: docker/login-action@v2.2.0 + with: + registry: ghcr.io + username: ${{ secrets.PACKAGES_USER }} + password: ${{ secrets.PACKAGES_PASS }} + + - name: Build and push Docker image + uses: docker/build-push-action@v4.1.1 + with: + context: ./debian12 + file: ./debian12/Dockerfile + push: true + platforms: | + linux/amd64 + linux/arm/v7 + linux/arm64/v8 + tags: | + buanet/iobroker:dev, + ghcr.io/buanet/iobroker:dev + provenance: false + outputs: type=image,name=target,annotation-index.org.opencontainers.image.description=Official Docker image for ioBroker smarthome software (https://www.iobroker.net) + + - name: Delete untagged images from GitHub Container Registry + uses: actions/github-script@v6.4.1 + 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