# Github action to build Docker image from dev branch (tag: dev) name: Build debian dev on: workflow_dispatch: jobs: build-dev-image: runs-on: ubuntu-latest steps: - name: Checkout repo uses: actions/checkout@v3.5.0 with: repository: 'buanet/ioBroker.docker' - name: Fetch version tag and date id: version run: | VERSION="$(cat .VERSION)" MAJORVERSION="$(cat .VERSION | cut -c 1-2 | sed -r 's#^(.{0})#\1latest-#')" DATI="$(date --rfc-3339=seconds | sed 's/ /T/')" echo "This is the Version: $VERSION" echo "version=$VERSION" >> $GITHUB_ENV echo "This is the Major Version: $MAJORVERSION" echo "majorversion=$MAJORVERSION" >> $GITHUB_ENV echo "This is the Buildnumber/Timestamp: $DATI" echo "dati=$DATI" >> $GITHUB_ENV # startup script sed -e "s/\${VERSION}/$VERSION-dev/" -e "s/\${BUILD}/$DATI/" ./debian/scripts/iobroker_startup.sh > ./debian/scripts/iobroker_startup.tmp mv -f ./debian/scripts/iobroker_startup.tmp ./debian/scripts/iobroker_startup.sh # amd64 sed -e "s/\${VERSION}/$VERSION-dev/" -e "s/\${DATI}/$DATI/" ./debian/node18/Dockerfile > ./debian/node18/Dockerfile.tmp mv -f ./debian/node18/Dockerfile.tmp ./debian/node18/Dockerfile - name: Set up QEMU uses: docker/setup-qemu-action@v2.1.0 - name: Set up Docker Buildx id: buildx uses: docker/setup-buildx-action@v2.5.0 - name: Login to DockerHub uses: docker/login-action@v2.1.0 with: username: ${{ secrets.DOCKER_USER }} password: ${{ secrets.DOCKER_PASS }} - name: Login to GitHub Container Registry uses: docker/login-action@v2.1.0 with: registry: ghcr.io username: ${{ secrets.PACKAGES_USER }} password: ${{ secrets.PACKAGES_PASS }} - name: Build and push Docker image env: DOCKER_BUILDKIT: 1 run: | # Build the Docker image for all platforms docker buildx build --push --platform linux/amd64,linux/arm64,linux/arm/v7 -t ghcr.io/buanet/iobroker:dev -f ./debian/node18/Dockerfile ./debian # Build manifest for dev-amd64 echo $(docker manifest inspect ghcr.io/buanet/iobroker:dev) | jq -r '.manifests[] | select(.platform.architecture == "amd64") | .digest' docker manifest create ghcr.io/buanet/iobroker:dev-amd64 \ ghcr.io/buanet/iobroker@$(echo $(docker manifest inspect ghcr.io/buanet/iobroker:dev) | jq -r '.manifests[] | select(.platform.architecture == "amd64") | .digest') # Push the Docker manifest to the registry docker manifest push ghcr.io/buanet/iobroker:dev-amd64 # - name: Extract metadata (tags, labels) # id: metadata # uses: docker/metadata-action@v4.3.0 # with: # images: | # buanet/iobroker # ghcr.io/buanet/iobroker # tags: | # type=raw,value=dev # labels: | # org.opencontainers.image.title=Official ioBroker Docker Image # org.opencontainers.image.description=Official Docker image for ioBroker smarthome software (https://www.iobroker.net) # org.opencontainers.image.documentation=https://github.com/buanet/ioBroker.docker#readme # org.opencontainers.image.authors=André Germann # org.opencontainers.image.url=https://github.com/buanet/ioBroker.docker # org.opencontainers.image.source=https://github.com/buanet/ioBroker.docker # org.opencontainers.image.base.name=docker.io/library/debian:bullseye-slim # org.opencontainers.image.version=${{ env.VERSION }} # org.opencontainers.image.created=${{ env.DATI }} # - name: Build and push Docker image # uses: docker/build-push-action@v4.0.0 # with: # context: ./debian # file: ./debian/node18/Dockerfile # push: true # platforms: | # linux/amd64 # linux/arm/v7 # linux/arm64/v8 # tags: ${{ steps.metadata.outputs.tags }} # labels: ${{ steps.metadata.outputs.labels }} ## 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) # cache-from: type=gha # cache-to: type=gha,mode=max - 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