Workflow file for this run
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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: | | |
# This configuration will trigger on a push tag event. It requires a Git tag that follows semantic versioning (semver) conventions. | |
# For example, if the Git tag is v1.2.3, the output will be formatted as '1.2.3'. | |
type=semver,pattern={{version}} | |
# This setting outputs the Git commit hash as a Docker tag(e.g., 'sha-ad132f5'). | |
type=sha | |
# Custom tagging is enabled for manual workflow dispatch events. The format combines branch name, current date, and commit hash. | |
# Example format: 'feature-branch-20231207-ad132f5'. | |
# This custom tag is generated only when the workflow is triggered via 'workflow_dispatch' event. | |
type=raw,value={{branch}}-{{date 'YYYYMMDD'}}-{{sha}},enable=${{ github.event == 'workflow_dispatch' }} | |
- 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 }} |