Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Publish Docker Image to ghcr.io #364

Merged
merged 7 commits into from
Oct 31, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
---
name: Publish to Docker Hub
name: Publish Docker Images

"on":
push:
Expand All @@ -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:
Expand All @@ -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
Expand All @@ -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:
Expand Down
50 changes: 5 additions & 45 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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 }}
10 changes: 5 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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:

Expand All @@ -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

Expand Down