Skip to content

Docker Build and Push #10

Docker Build and Push

Docker Build and Push #10

name: Docker Build and Push
# This workflow is triggered on pushes(only tags) to the repository.
on:
push:
tags:
- 'v*'
workflow_dispatch:
jobs:
build-and-push:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Docker meta
id: meta
uses: docker/metadata-action@v5
with:
# list of Docker images to use as base name for tags
images: |
huangliang1203/birdwatcher
# generate Docker tags based on the following events/attributes
tags: |
type=ref,event=branch,value={{branch}}-{{date 'YYYYMMDD'}}-{{sha}}
type=semver,pattern={{version}}
type=sha
- name: Login to Docker Hub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKERHUB_USER }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Build and push
uses: docker/build-push-action@v5
with:
context: .
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}