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

Adjust Docker Hub build action to include PRs #290

Merged
merged 3 commits into from
Sep 19, 2022
Merged
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
43 changes: 16 additions & 27 deletions .github/workflows/publish_to_docker_hub.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
name: "Publish to Docker Hub"

on:
pull_request:

push:
branches:
- dev
Expand All @@ -10,38 +12,24 @@ on:
- "*"

jobs:
publish_to_docker_hub:
publish:
name: Publish Images

runs-on: ubuntu-latest

steps:
- name: Checkout Code
uses: actions/checkout@v3

- name: Prepare
id: prep
run: |
DOCKER_IMAGE=bachya/ecowitt2mqtt
VERSION=noop

if [[ $GITHUB_REF == refs/tags/* ]]; then
VERSION=${GITHUB_REF#refs/tags/}
elif [[ $GITHUB_REF == refs/heads/dev ]]; then
VERSION=dev
elif [[ $GITHUB_REF == refs/heads/main ]]; then
VERSION=latest
fi

TAGS="${DOCKER_IMAGE}:${VERSION}"
if [[ $VERSION =~ ^v[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}$ ]]; then
MINOR=${VERSION%.*}
MAJOR=${MINOR%.*}
TAGS="$TAGS,${DOCKER_IMAGE}:${MINOR},${DOCKER_IMAGE}:${MAJOR},${DOCKER_IMAGE}:latest"
fi

echo ::set-output name=version::${VERSION}
echo ::set-output name=tags::${TAGS}
echo ::set-output name=created::$(date -u +'%Y-%m-%dT%H:%M:%SZ')
- name: Docker meta
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
Expand All @@ -63,6 +51,7 @@ jobs:
context: .
file: ./Dockerfile
platforms: >-
linux/amd64,linux/arm64
linux/amd64,linux/arm64/v8
push: true
tags: ${{ steps.prep.outputs.tags }}
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}