Skip to content

Commit 8e50927

Browse files
kwannoelkwannoel
authored andcommitted
feat(ci): support workflow for docker image building (#21626)
1 parent f6c922b commit 8e50927

File tree

1 file changed

+57
-0
lines changed

1 file changed

+57
-0
lines changed
Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
# To test: gh workflow run 'Build Docker Image' --ref kwannoel/workflow-update-branch
2+
name: Build Docker Image
3+
on:
4+
workflow_dispatch:
5+
inputs:
6+
label:
7+
description: 'Generate image tag + build Docker image: v<X.Y.Z>--<label>--<commit_sha>--<branch>'
8+
required: true
9+
type: string
10+
default: 'unlabeled'
11+
12+
jobs:
13+
build_image:
14+
runs-on: ubuntu-latest
15+
steps:
16+
- uses: actions/checkout@v4
17+
- name: 'Generate image tag'
18+
id: get_release_branch
19+
run: |
20+
# Get current branch name
21+
BRANCH_NAME=$(git rev-parse --abbrev-ref HEAD)
22+
echo "BRANCH_NAME=$BRANCH_NAME"
23+
echo "BRANCH_NAME=$BRANCH_NAME" >> $GITHUB_ENV
24+
25+
echo "Replace / with - in branch name, for docker manifest requirement"
26+
NO_SLASH_BRANCH_NAME=${BRANCH_NAME//\//-}
27+
echo "NO_SLASH_BRANCH_NAME=$NO_SLASH_BRANCH_NAME"
28+
echo "NO_SLASH_BRANCH_NAME=$NO_SLASH_BRANCH_NAME" >> $GITHUB_ENV
29+
30+
# Get version from Cargo.toml, e.g. v2.3.0-alpha
31+
VERSION=$(grep -m 1 '^version' Cargo.toml | cut -d '"' -f 2)
32+
echo "VERSION=$VERSION"
33+
echo "VERSION=$VERSION" >> $GITHUB_ENV
34+
35+
# Get the commit SHA
36+
COMMIT_SHA=$(echo $GITHUB_SHA | cut -c1-7)
37+
echo "COMMIT_SHA=$COMMIT_SHA"
38+
echo "COMMIT_SHA=$COMMIT_SHA" >> $GITHUB_ENV
39+
40+
# Get the label from the input
41+
LABEL=${{ github.event.inputs.label }}
42+
echo "LABEL=$LABEL"
43+
echo "LABEL=$LABEL" >> $GITHUB_ENV
44+
45+
# Build the image tag
46+
IMAGE_TAG="v$VERSION--$LABEL--$COMMIT_SHA--$NO_SLASH_BRANCH_NAME"
47+
echo "IMAGE_TAG=$IMAGE_TAG"
48+
echo "IMAGE_TAG=$IMAGE_TAG" >> $GITHUB_ENV
49+
- name: 'Trigger Docker build Workflow via Buildkite'
50+
uses: buildkite/[email protected]
51+
with:
52+
buildkite_api_access_token: ${{ secrets.BUILDKITE_TOKEN }}
53+
pipeline: 'risingwavelabs/docker'
54+
branch: ${{ env.BRANCH_NAME }}
55+
commit: HEAD
56+
message: ':github: Triggering Docker build with image tag: ${{ env.IMAGE_TAG }}'
57+
build_env_vars: '{ "IMAGE_TAG": "${{ env.IMAGE_TAG }}" }'

0 commit comments

Comments
 (0)