Skip to content

Publish Docker image #30

Publish Docker image

Publish Docker image #30

Workflow file for this run

# Adapted from https://docs.github.com/en/actions/publishing-packages/publishing-docker-images
name: Publish Docker image
on:
workflow_dispatch:
inputs:
# https://docs.github.com/en/actions/learn-github-actions/contexts#inputs-context
tags:
description: "Please provide a git tag value, e.g. v3.2.1-manually-triggered.1"
required: true
type: string
default: "v3.2.1-manually-triggered.1"
push:
tags:
- 'v*'
jobs:
push_to_registry:
name: Push Docker image to Docker Hub
runs-on: ubuntu-latest
if: github.repository_owner == '52North'
steps:
- name: Checkout Repository
uses: actions/checkout@v3
- name: Set up Docker Buildkit env
uses: docker/setup-buildx-action@v2
- name: Extract metadata (tags, labels) for tagging Docker Image
id: meta
uses: docker/metadata-action@v4
with:
images: 52north/sos
tags: |
type=semver,pattern={{version}}
type=semver,pattern={{major}}.{{minor}}
type=semver,pattern={{major}}
type=match,pattern=v(.*),group=1,value=${{ github.event.inputs.tags }}
- name: Log in to Docker Hub
if: github.event_name != 'pull_request'
uses: docker/login-action@v2
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_TOKEN }}
- name: Build and push Docker image
uses: docker/build-push-action@v3
with:
context: .
push: ${{ github.event_name != 'pull_request' }}
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}