From 219d31ac5321b75c3b81f8530c9585106314b8c5 Mon Sep 17 00:00:00 2001 From: tbrink Date: Sun, 3 Dec 2023 09:01:43 +0100 Subject: [PATCH] Added tags to image build --- .github/workflows/docker-image.yml | 42 ++++++++++++++++++++++++------ README.md | 14 +++++----- 2 files changed, 42 insertions(+), 14 deletions(-) diff --git a/.github/workflows/docker-image.yml b/.github/workflows/docker-image.yml index 2fd61c7..63023aa 100644 --- a/.github/workflows/docker-image.yml +++ b/.github/workflows/docker-image.yml @@ -1,8 +1,16 @@ name: Docker Image CI on: + schedule: + - cron: "0 10 * * *" push: - branches: [ "master" ] + branches: + - "master" + tags: + - "v*.*.*" + pull_request: + branches: + - "master" jobs: build: @@ -13,7 +21,6 @@ jobs: - uses: actions/checkout@v3 - name: Set up QEMU uses: docker/setup-qemu-action@v3 - - name: Docker Setup Buildx uses: docker/setup-buildx-action@v3 with: @@ -23,9 +30,28 @@ jobs: with: registry: https://ghcr.io username: ${{ github.actor }} - password: ${{ secrets.GITHUB_TOKEN }} - - name: Get Short SHA - id: shortsha - run: echo "sha_short=$(git rev-parse --short HEAD)" >> $GITHUB_OUTPUT - - name: Build container - run: docker buildx build --push -t ghcr.io/${{github.repository}}:latest -t ghcr.io/${{github.repository}}:${{ github.sha }} -t ghcr.io/${{github.repository}}:${{ steps.shortsha.outputs.sha_short }} --platform linux/arm/v7,linux/arm64/v8 . + password: ${{ secrets.GITHUB_TOKEN }} + - name: Docker meta + id: meta + uses: docker/metadata-action@v5 + with: + # list of Docker images to use as base name for tags + images: | + ghcr.io/${{github.repository}} + # generate Docker tags based on the following events/attributes + tags: | + type=schedule,pattern=nightly + type=ref,event=branch + type=ref,event=pr + type=semver,pattern={{version}} + type=semver,pattern={{major}}.{{minor}} + type=semver,pattern={{major}} + type=sha + - name: Build and push + uses: docker/build-push-action@v5 + with: + context: . + platforms: linux/arm/v7,linux/arm64/v8 + push: ${{ github.event_name != 'pull_request' }} + tags: ${{ steps.meta.outputs.tags }} + labels: ${{ steps.meta.outputs.labels }} \ No newline at end of file diff --git a/README.md b/README.md index 139f1ec..9715116 100644 --- a/README.md +++ b/README.md @@ -241,19 +241,21 @@ I published the dashboard on [grafana.com](https://grafana.com/grafana/dashboard ### Docker -There is a Dockerfile available if you'd like to run as a docker container. +1. Use the published image -1.Building +```docker pull ghcr.io/tijmenvandenbrink/enviroplus_exporter``` + +2. Or build it yourself ```docker build -t enviroplus-exporter .``` -2.Running +Or using [BuildKit](https://docs.docker.com/develop/develop-images/build_enhancements/) you can build Raspberry Pi compatible images on an amd64. -```docker run -d enviroplus-exporter -d -p 8000:8000 --device=/dev/i2c-1 --device=/dev/gpiomem --device=/dev/ttyAMA0 enviroplus-exporter``` +```docker buildx build --platform linux/arm/v7,linux/arm64/v8 .``` -Using [BuildKit](https://docs.docker.com/develop/develop-images/build_enhancements/) you can build Raspberry Pi compatible images on an amd64. +3. Running -```docker buildx build --platform linux/arm/v7,linux/arm64/v8 .``` +```docker run -d enviroplus-exporter -d -p 8000:8000 --device=/dev/i2c-1 --device=/dev/gpiomem --device=/dev/ttyAMA0 enviroplus-exporter``` ### Kubernetes