-
Notifications
You must be signed in to change notification settings - Fork 34
45 lines (42 loc) · 1.71 KB
/
build-and-push.yaml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
name: Docker Build and Push
# This workflow is triggered both on tag push event and workflow_dispatch event 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: |
milvusdb/birdwatcher
# generate Docker tags based on the following events/attributes
tags: |
# trigger only 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
# This custom tag is generated only when the workflow is triggered via 'workflow_dispatch' event.
# The format combines branch name, current date, and commit hash. Example format: 'feature-branch-20231207-ad132f5'.
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 }}