From e570e62bf13c8f1fb1fd05977b29af1341aa902b Mon Sep 17 00:00:00 2001 From: Zhengchen Tao Date: Tue, 28 Apr 2026 15:15:10 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=20.gitea/workflows/build-ima?= =?UTF-8?q?ge.yml?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .gitea/workflows/build-image.yml | 53 ++++++++++++++++++++++++++++++++ 1 file changed, 53 insertions(+) create mode 100644 .gitea/workflows/build-image.yml diff --git a/.gitea/workflows/build-image.yml b/.gitea/workflows/build-image.yml new file mode 100644 index 00000000..9936840a --- /dev/null +++ b/.gitea/workflows/build-image.yml @@ -0,0 +1,53 @@ +name: Build Docker Image + +on: + workflow_dispatch: + inputs: + branch: + description: '要打包的分支' + required: true + default: 'custom' + tag: + description: '镜像 tag(留空则用 commit short hash)' + required: false + default: '' + +jobs: + build: + runs-on: ubuntu-latest + steps: + - name: Checkout target branch + uses: actions/checkout@v4 + with: + ref: ${{ inputs.branch }} + fetch-depth: 0 + + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v3 + + - name: Login to Gitea Container Registry + uses: docker/login-action@v3 + with: + registry: git.zhengchentao.win + username: ${{ gitea.actor }} + password: ${{ secrets.PACKAGES_TOKEN }} + + - name: Determine image tag + id: meta + run: | + if [ -n "${{ inputs.tag }}" ]; then + IMAGE_TAG="${{ inputs.tag }}" + else + IMAGE_TAG="$(git rev-parse --short HEAD)" + fi + echo "image_tag=$IMAGE_TAG" >> $GITHUB_OUTPUT + echo "==> Image tag: $IMAGE_TAG" + + - name: Build and push + uses: docker/build-push-action@v5 + with: + context: . + push: true + tags: | + git.zhengchentao.win/dev/ezbookkeeping:${{ steps.meta.outputs.image_tag }} + git.zhengchentao.win/dev/ezbookkeeping:latest \ No newline at end of file