-
Notifications
You must be signed in to change notification settings - Fork 396
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[improvement][build] Support manual pushing of images through GitHub …
…Actions (#1874)
- Loading branch information
Showing
2 changed files
with
54 additions
and
0 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
name: Docker Publish | ||
|
||
on: | ||
workflow_dispatch: | ||
inputs: | ||
version: | ||
description: 'Version of the Docker image' | ||
required: true | ||
default: 'latest' | ||
|
||
jobs: | ||
build-and-publish: | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- name: Checkout repository | ||
uses: actions/checkout@v2 | ||
|
||
- name: Set up Docker Buildx | ||
uses: docker/setup-buildx-action@v1 | ||
|
||
- name: Log in to Docker Hub | ||
uses: docker/login-action@v1 | ||
with: | ||
username: ${{ secrets.DOCKER_USERNAME }} | ||
password: ${{ secrets.DOCKER_PASSWORD }} | ||
|
||
- name: Build and publish Docker image | ||
run: | | ||
VERSION=${{ github.event.inputs.version }} | ||
sh docker/docker-build.sh $VERSION | ||
sh docker/docker-publish.sh |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
#!/bin/bash | ||
# 确保脚本在出错时退出 | ||
set -e | ||
# 镜像名称 | ||
IMAGE_NAME="supersonicbi/supersonic" | ||
|
||
# 默认标签为 latest | ||
TAGS=("latest") | ||
|
||
# 如果有 Git 标签,则使用 Git 标签作为额外的镜像标签 | ||
if [ -n "$GITHUB_REF" ]; then | ||
GIT_TAG=$(echo $GITHUB_REF | sed 's/refs\/tags\///') | ||
TAGS+=("$GIT_TAG") | ||
fi | ||
|
||
# 推送 Docker 镜像 | ||
for TAG in "${TAGS[@]}"; do | ||
echo "Pushing Docker image $IMAGE_NAME:$TAG" | ||
docker push $IMAGE_NAME:$TAG | ||
done | ||
|
||
echo "Docker images pushed successfully." |