diff --git a/.github/workflows/publish-docker-hub.yml b/.github/workflows/publish-docker.yml similarity index 66% rename from .github/workflows/publish-docker-hub.yml rename to .github/workflows/publish-docker.yml index a226bd1f..bb97d6f8 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,17 @@ name: Publish to Docker Hub tags: - "*" + workflow_call: + secrets: + DOCKER_HUB_PASSWORD: + required: true + DOCKER_HUB_USERNAME: + required: true + jobs: publish: + name: Publish Docker Images + runs-on: ubuntu-latest steps: @@ -21,7 +30,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 @@ -38,9 +49,16 @@ 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 + with: + registry: ghcr.io + username: ${{ github.repository_owner }} + password: ${{ secrets.GITHUB_TOKEN }} - - name: ๐Ÿ”ง Build image architectures and push to Docker Hub + - name: ๐Ÿ”ง Build and push images id: docker_build uses: docker/build-push-action@v3 with: diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 0d0b46b5..7a658513 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -146,51 +146,11 @@ 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 }} + uses: ./.github/workflows/publish-docker.yml + secrets: + DOCKER_HUB_USERNAME: ${{ secrets.DOCKER_HUB_USERNAME }} + DOCKER_HUB_PASSWORD: ${{ secrets.DOCKER_HUB_TOKEN }} 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