From 2c509c329f3cf7c6f6a9e2839c60658074391f1a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E4=BA=8C=E4=B8=AB=E8=AE=B2=E6=A2=B5?= Date: Mon, 27 Feb 2023 19:24:46 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E8=B0=83=E6=95=B4=E9=95=9C=E5=83=8F?= =?UTF-8?q?=E6=9E=84=E5=BB=BA=E7=9A=84tag,=E8=AE=A9=E6=9C=80=E6=96=B0?= =?UTF-8?q?=E4=BB=A3=E7=A0=81=E6=8C=87=E5=90=91latest,=E8=AE=A9=E6=AF=8F?= =?UTF-8?q?=E6=AC=A1=E7=89=88=E6=9C=AC=E6=8C=87=E5=90=91=E6=97=A5=E6=9C=9F?= =?UTF-8?q?=20(#144)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * feat: 调整镜像构建的tag,让最新代码指向latest,让每次版本指向日期 * feat: 触发时机为main分支push或者relases的create,镜像的tag为分支名或tag名 * fix: 修复变量引用方式 * fix: 修复变量引用方式 * fix: 使用github.ref_name 取触发action的来源 --- .github/workflows/build_docker.yml | 16 ++++++++++------ README.md | 2 +- 2 files changed, 11 insertions(+), 7 deletions(-) diff --git a/.github/workflows/build_docker.yml b/.github/workflows/build_docker.yml index c69a4d3..d4b1bb5 100644 --- a/.github/workflows/build_docker.yml +++ b/.github/workflows/build_docker.yml @@ -3,6 +3,8 @@ name: build_docker on: push: branches: [main] + release: + types: [created] # 表示在创建新的 Release 时触发 jobs: build_docker: @@ -11,11 +13,11 @@ jobs: steps: - name: Checkout uses: actions/checkout@v3 - - name: Docker meta - id: meta - uses: docker/metadata-action@v4 - with: - images: chenzhaoyu94/chatgpt-web + + - run: | + echo "本次构建的版本为:${GITHUB_REF_NAME} (但是这个变量目前上下文中无法获取到)" + echo 本次构建的版本为:${{ github.ref_name }} + env - name: Set up QEMU uses: docker/setup-qemu-action@v2 @@ -32,6 +34,8 @@ jobs: with: context: . push: true - tags: ${{ steps.meta.outputs.tags }} labels: ${{ steps.meta.outputs.labels }} platforms: linux/amd64,linux/arm64 + tags: | + ${{ secrets.DOCKERHUB_USERNAME }}/chatgpt-web:${{ github.ref_name }} + ${{ secrets.DOCKERHUB_USERNAME }}/chatgpt-web:latest diff --git a/README.md b/README.md index 6fb48c6..625c661 100644 --- a/README.md +++ b/README.md @@ -174,7 +174,7 @@ version: '3' services: app: - image: chenzhaoyu94/chatgpt-web:main + image: chenzhaoyu94/chatgpt-web # 总是使用latest,更新时重新pull该tag镜像即可 ports: - 3002:3002 environment: