Skip to content

Commit

Permalink
Add Docker Build and Push Workflow for Tagged Commits (#221)
Browse files Browse the repository at this point in the history
This commit introduces a new GitHub Actions workflow designed to
automate the Docker image building and pushing process for the
MilvusDB/Birdwatcher project. The workflow triggers on new tags
(formatted as 'v*') pushed to the repository and includes the following
key steps:

1. Checkout the source code.
2. Generate Docker metadata including tags based on semantic versioning,
and commit SHA.
3. Login to Docker Hub using secured credentials.
4. Build the Docker image from the current directory context and push it
to Docker Hub, using the generated tags and labels.

This automation ensures that every tagged commit is accompanied by a
corresponding Docker image, simplifying deployment and testing
processes.

Signed-off-by: Sammy Huang <[email protected]>
  • Loading branch information
yellow-shine authored Dec 1, 2023
1 parent 0b09362 commit 74ba0aa
Showing 1 changed file with 38 additions and 0 deletions.
38 changes: 38 additions & 0 deletions .github/workflows/build-and-push.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
name: Docker Build and Push

# This workflow is triggered on pushes(only tags) to the repository.
on:
push:
tags:
- 'v*'

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: |
type=ref,event=branch
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 }}

0 comments on commit 74ba0aa

Please sign in to comment.