From 5b5d883eaf6c2461c1f0ef5a04ec5eb8a89ec828 Mon Sep 17 00:00:00 2001 From: Aaron Bach Date: Mon, 31 Oct 2022 10:12:50 -0600 Subject: [PATCH 1/7] Publish Docker Image to ghcr.io --- ...lish-docker-hub.yml => publish-docker.yml} | 12 +++-- .github/workflows/test.yml | 45 ++----------------- README.md | 10 ++--- 3 files changed, 17 insertions(+), 50 deletions(-) rename .github/workflows/{publish-docker-hub.yml => publish-docker.yml} (87%) diff --git a/.github/workflows/publish-docker-hub.yml b/.github/workflows/publish-docker.yml similarity index 87% rename from .github/workflows/publish-docker-hub.yml rename to .github/workflows/publish-docker.yml index a226bd1f..0869d1b6 100644 --- a/.github/workflows/publish-docker-hub.yml +++ b/.github/workflows/publish-docker.yml @@ -1,5 +1,5 @@ --- -name: Publish to Docker Hub +name: Publish Docker Images "on": push: @@ -9,8 +9,12 @@ name: Publish to Docker Hub tags: - "*" + workflow_call: + jobs: - publish: + publish-docker-hub: + name: Publish to Docker Hub + runs-on: ubuntu-latest steps: @@ -21,7 +25,9 @@ jobs: id: meta uses: docker/metadata-action@v4 with: - images: bachya/ecowitt2mqtt + images: | + bachya/ecowitt2mqtt + ghcr.io/bachya/ecowitt2mqtt tags: | type=ref,event=branch type=ref,event=pr diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 0d0b46b5..b16c08f7 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -146,51 +146,12 @@ jobs: token: ${{ secrets.CODECOV_TOKEN }} publish_docker_image: - name: Publish PR to Docker Hub + name: Publish PR Docker Images needs: coverage runs-on: ubuntu-latest steps: - - name: โคต๏ธ Check out code from GitHub - uses: actions/checkout@v3 - - - name: ๐Ÿค˜๐Ÿป Collect Docker metadata - id: meta - uses: docker/metadata-action@v4 - with: - images: bachya/ecowitt2mqtt - tags: | - type=ref,event=branch - type=ref,event=pr - type=ref,event=tag - - - name: ๐Ÿ‘ทโ€โ™‚๏ธ Set up QEMU - uses: docker/setup-qemu-action@v2 - - - name: ๐Ÿ‘ทโ€โ™‚๏ธ Set up Docker Buildx - id: buildx - uses: docker/setup-buildx-action@v2 - - - name: ๐Ÿ” Login to DockerHub - uses: docker/login-action@v2 - with: - username: ${{ secrets.DOCKER_HUB_USERNAME }} - password: ${{ secrets.DOCKER_HUB_TOKEN }} - - - name: ๐Ÿ”ง Build image architectures and push to Docker Hub - id: docker_build - uses: docker/build-push-action@v3 - with: - context: . - file: ./Dockerfile - platforms: >- - linux/386, - linux/amd64, - linux/arm/v6, - linux/arm/v7, - linux/arm64 - push: true - tags: ${{ steps.meta.outputs.tags }} - labels: ${{ steps.meta.outputs.labels }} + - name: ๐Ÿšฆ 'Run the "Publish Docker Images" workflow' + uses: ./.github/workflows/publish-docker.yml diff --git a/README.md b/README.md index 27eef031..c09dae34 100644 --- a/README.md +++ b/README.md @@ -622,9 +622,10 @@ $ systemctl enable ecowitt2mqtt ## Docker -The library is available via a Docker image -([`bachya/ecowitt2mqtt`](https://hub.docker.com/r/bachya/ecowitt2mqtt)). It is configured -by using the same environment variables listed [above](#environment-variables). +The library is available via a Docker image from both +[Docker Hub](https://hub.docker.com/r/bachya/ecowitt2mqtt) and +[ghcr.io](https://ghcr.io/bachya/ecowitt2mqtt). It is configured by using the same +environment variables listed [above](#environment-variables). Running the image is straightforward: @@ -645,8 +646,7 @@ exposed via the same port on the host. configuration file at [`docker-compose.dev.yml`](https://github.com/bachya/ecowitt2mqtt/blob/dev/docker-compose.dev.yml). Note that this is intended to be a dev environment for quickly testing the repo itself; -in production, you should refer to one of the -[Docker Hub](https://hub.docker.com/r/bachya/ecowitt2mqtt) images. +in production, you should refer to one of the published images. # Diagnostics From 686060d5a230dfbd09a03a1503a1819098a8b444 Mon Sep 17 00:00:00 2001 From: Aaron Bach Date: Mon, 31 Oct 2022 10:16:29 -0600 Subject: [PATCH 2/7] Actually log in to ghcr --- .github/workflows/publish-docker.yml | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/.github/workflows/publish-docker.yml b/.github/workflows/publish-docker.yml index 0869d1b6..b8fb607f 100644 --- a/.github/workflows/publish-docker.yml +++ b/.github/workflows/publish-docker.yml @@ -46,7 +46,14 @@ jobs: username: ${{ secrets.DOCKER_HUB_USERNAME }} password: ${{ secrets.DOCKER_HUB_TOKEN }} - - name: ๐Ÿ”ง Build image architectures and push to Docker Hub + - name: ๐Ÿ” Login to ghcr.io + uses: docker/login-action@v2 + with: + registry: ghcr.io + username: ${{ github.repository_owner }} + password: ${{ secrets.GITHUB_TOKEN }} + + - name: ๐Ÿ”ง Build and push images id: docker_build uses: docker/build-push-action@v3 with: From d71e3205354b1414e70e0de171972c33f51dd4b6 Mon Sep 17 00:00:00 2001 From: Aaron Bach Date: Mon, 31 Oct 2022 10:19:25 -0600 Subject: [PATCH 3/7] GO --- .github/workflows/test.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index b16c08f7..e4f8e32b 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -153,5 +153,8 @@ jobs: runs-on: ubuntu-latest steps: + - name: โคต๏ธ Check out code from GitHub + uses: actions/checkout@v3 + - name: ๐Ÿšฆ 'Run the "Publish Docker Images" workflow' uses: ./.github/workflows/publish-docker.yml From ff66930eb68723f1bd18ad9b383281844814ef66 Mon Sep 17 00:00:00 2001 From: Aaron Bach Date: Mon, 31 Oct 2022 10:27:53 -0600 Subject: [PATCH 4/7] FIX --- .github/workflows/test.yml | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index e4f8e32b..9e57c01f 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -152,9 +152,6 @@ jobs: runs-on: ubuntu-latest - steps: - - name: โคต๏ธ Check out code from GitHub - uses: actions/checkout@v3 - - - name: ๐Ÿšฆ 'Run the "Publish Docker Images" workflow' + jobs: + call-publish-docker-workflow: uses: ./.github/workflows/publish-docker.yml From f4ad67eec631ad128817246d2c507328a8d4a2f1 Mon Sep 17 00:00:00 2001 From: Aaron Bach Date: Mon, 31 Oct 2022 10:38:49 -0600 Subject: [PATCH 5/7] Fix --- .github/workflows/test.yml | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 9e57c01f..18a94dc1 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -150,8 +150,4 @@ jobs: needs: coverage - runs-on: ubuntu-latest - - jobs: - call-publish-docker-workflow: - uses: ./.github/workflows/publish-docker.yml + uses: ./.github/workflows/publish-docker.yml From 2e2fa64c014ade56a3808495a4f4f6b9bff16792 Mon Sep 17 00:00:00 2001 From: Aaron Bach Date: Mon, 31 Oct 2022 10:47:54 -0600 Subject: [PATCH 6/7] Again --- .github/workflows/publish-docker.yml | 7 ++++++- .github/workflows/test.yml | 3 +++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/.github/workflows/publish-docker.yml b/.github/workflows/publish-docker.yml index b8fb607f..64375940 100644 --- a/.github/workflows/publish-docker.yml +++ b/.github/workflows/publish-docker.yml @@ -10,6 +10,11 @@ name: Publish Docker Images - "*" workflow_call: + secrets: + DOCKER_HUB_PASSWORD: + required: true + DOCKER_HUB_USERNAME: + required: true jobs: publish-docker-hub: @@ -44,7 +49,7 @@ jobs: uses: docker/login-action@v2 with: username: ${{ secrets.DOCKER_HUB_USERNAME }} - password: ${{ secrets.DOCKER_HUB_TOKEN }} + password: ${{ secrets.DOCKER_HUB_PASSWORD }} - name: ๐Ÿ” Login to ghcr.io uses: docker/login-action@v2 diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 18a94dc1..7a658513 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -151,3 +151,6 @@ jobs: needs: coverage uses: ./.github/workflows/publish-docker.yml + secrets: + DOCKER_HUB_USERNAME: ${{ secrets.DOCKER_HUB_USERNAME }} + DOCKER_HUB_PASSWORD: ${{ secrets.DOCKER_HUB_TOKEN }} From 662163ffec39df06464f099e7c36a34ab05a47e3 Mon Sep 17 00:00:00 2001 From: Aaron Bach Date: Mon, 31 Oct 2022 11:44:20 -0600 Subject: [PATCH 7/7] YES --- .github/workflows/publish-docker.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/publish-docker.yml b/.github/workflows/publish-docker.yml index 64375940..bb97d6f8 100644 --- a/.github/workflows/publish-docker.yml +++ b/.github/workflows/publish-docker.yml @@ -17,8 +17,8 @@ name: Publish Docker Images required: true jobs: - publish-docker-hub: - name: Publish to Docker Hub + publish: + name: Publish Docker Images runs-on: ubuntu-latest