mirror of
https://github.com/RockChinQ/QChatGPT.git
synced 2024-11-16 03:32:33 +08:00
49 lines
1.9 KiB
YAML
49 lines
1.9 KiB
YAML
name: Build Docker Image
|
||
on:
|
||
#防止fork乱用action设置只能手动触发构建
|
||
workflow_dispatch:
|
||
## 发布release的时候会自动构建
|
||
release:
|
||
types: [published]
|
||
jobs:
|
||
publish-docker-image:
|
||
runs-on: ubuntu-latest
|
||
name: Build image
|
||
|
||
steps:
|
||
- name: Checkout
|
||
uses: actions/checkout@v2
|
||
- name: judge has env GITHUB_REF # 如果没有GITHUB_REF环境变量,则把github.ref变量赋值给GITHUB_REF
|
||
run: |
|
||
if [ -z "$GITHUB_REF" ]; then
|
||
export GITHUB_REF=${{ github.ref }}
|
||
echo $GITHUB_REF
|
||
fi
|
||
# - name: Check GITHUB_REF env
|
||
# run: echo $GITHUB_REF
|
||
# - name: Get version # 在 GitHub Actions 运行环境
|
||
# id: get_version
|
||
# if: (startsWith(env.GITHUB_REF, 'refs/tags/')||startsWith(github.ref, 'refs/tags/')) && startsWith(github.repository, 'RockChinQ/QChatGPT')
|
||
# run: export GITHUB_REF=${GITHUB_REF/refs\/tags\//}
|
||
- name: Check version
|
||
id: check_version
|
||
run: |
|
||
echo $GITHUB_REF
|
||
# 如果是tag,则去掉refs/tags/前缀
|
||
if [[ $GITHUB_REF == refs/tags/* ]]; then
|
||
echo "It's a tag"
|
||
echo $GITHUB_REF
|
||
echo $GITHUB_REF | awk -F '/' '{print $3}'
|
||
echo ::set-output name=version::$(echo $GITHUB_REF | awk -F '/' '{print $3}')
|
||
else
|
||
echo "It's not a tag"
|
||
echo $GITHUB_REF
|
||
echo ::set-output name=version::${GITHUB_REF}
|
||
fi
|
||
- name: Login to Registry
|
||
run: docker login --username=${{ secrets.DOCKER_USERNAME }} --password ${{ secrets.DOCKER_PASSWORD }}
|
||
- name: Create Buildx
|
||
run: docker buildx create --name mybuilder --use
|
||
- name: Build # image name: rockchin/qchatgpt:<VERSION>
|
||
run: docker buildx build --platform linux/arm64,linux/amd64 -t rockchin/qchatgpt:${{ steps.check_version.outputs.version }} -t rockchin/qchatgpt:latest . --push
|