mirror of
https://github.com/RockChinQ/QChatGPT.git
synced 2024-11-15 19:22:24 +08:00
ci: 优化docker镜像构建脚本
This commit is contained in:
parent
ff9a9830f2
commit
3bfce8ab51
41
.github/workflows/build_docker_image.yml
vendored
41
.github/workflows/build_docker_image.yml
vendored
|
@ -1,4 +1,4 @@
|
|||
name: Build Image
|
||||
name: Build Docker Image
|
||||
on:
|
||||
#防止fork乱用action设置只能手动触发构建
|
||||
workflow_dispatch:
|
||||
|
@ -6,24 +6,33 @@ on:
|
|||
release:
|
||||
types: [published]
|
||||
jobs:
|
||||
build:
|
||||
publish-docker-image:
|
||||
runs-on: ubuntu-latest
|
||||
name: Build image job
|
||||
name: Build image
|
||||
|
||||
steps:
|
||||
- name: Checkout master
|
||||
uses: actions/checkout@master
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v2
|
||||
- name: judge has env GITHUB_REF # 如果没有GITHUB_REF环境变量,则把github.ref变量赋值给GITHUB_REF
|
||||
run: |
|
||||
if [ -z "$GITHUB_REF" ]; then
|
||||
echo "GITHUB_REF=${{ github.ref }}" >> $GITHUB_ENV
|
||||
fi
|
||||
- name: Check GITHUB_REF env
|
||||
run: echo $GITHUB_REF
|
||||
- name: Get version
|
||||
id: get_version
|
||||
if: startsWith(github.ref, 'refs/tags/') && startsWith(github.repository, 'RockChinQ/QChatGPT')
|
||||
if: startsWith(env.GITHUB_REF, 'refs/tags/') && startsWith(github.repository, 'RockChinQ/QChatGPT')
|
||||
run: echo ::set-output name=VERSION::${GITHUB_REF/refs\/tags\//}
|
||||
- name: Build and publish image
|
||||
uses: ilteoood/docker_buildx@master
|
||||
if: startsWith(github.ref, 'refs/tags/') && startsWith(github.repository, 'RockChinQ/QChatGPT')
|
||||
with:
|
||||
publish: true
|
||||
imageName: mikumifa/qchatgpt-docker # dockerid/imageName
|
||||
platform: linux/386,linux/arm64,linux/amd64,linux/arm/v6,linux/arm/v7 # 你准备构建的镜像平台
|
||||
tag: latest,${{ steps.get_version.outputs.VERSION }}
|
||||
dockerUser: ${{ secrets.DOCKER_USERNAME }} # docker hub userid 在setting创建secrets name=DOCKER_USERNAME value=dockerid
|
||||
dockerPassword: ${{ secrets.DOCKER_PASSWORD }} # docker hub password,在setting创建secrets name=DOCKER_PASSWORD value=dockerpassword
|
||||
- name: Build # image name: rockchin/qchatgpt:<VERSION>
|
||||
run: docker build --network=host -t rockchin/qchatgpt:${{ steps.get_version.outputs.VERSION }} -t rockchin/qchatgpt:latest .
|
||||
- name: Login to Registry
|
||||
run: docker login --username=${{ secrets.DOCKER_USERNAME }} --password ${{ secrets.DOCKER_PASSWORD }}
|
||||
|
||||
- name: Push image
|
||||
if: startsWith(env.GITHUB_REF, 'refs/tags/') && startsWith(github.repository, 'RockChinQ/QChatGPT')
|
||||
run: docker push rockchin/qchatgpt:${{ steps.get_version.outputs.VERSION }}
|
||||
|
||||
- name: Push image
|
||||
if: startsWith(env.GITHUB_REF, 'refs/tags/') && startsWith(github.repository, 'RockChinQ/QChatGPT')
|
||||
run: docker push rockchin/qchatgpt:latest
|
||||
|
|
Loading…
Reference in New Issue
Block a user