From 71683eb83374a54aa00e4f773aac58b9c95c25e4 Mon Sep 17 00:00:00 2001 From: kalicyh <34980061+kaliCYH@users.noreply.github.com> Date: Tue, 18 Feb 2025 17:17:17 +0800 Subject: [PATCH] =?UTF-8?q?=F0=9F=90=8E=20ci(ci):=20=E8=87=AA=E5=8A=A8?= =?UTF-8?q?=E6=89=93=E5=8C=85docker?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/docker-image.yml | 46 ++++++++++++++++++++++++++++++ 1 file changed, 46 insertions(+) create mode 100644 .github/workflows/docker-image.yml diff --git a/.github/workflows/docker-image.yml b/.github/workflows/docker-image.yml new file mode 100644 index 000000000..b957ee2e1 --- /dev/null +++ b/.github/workflows/docker-image.yml @@ -0,0 +1,46 @@ +name: Docker Image CI + +on: + push: + tags: + - 'v*.*.*' # 只在以 v 开头的标签推送时触发,例如 v1.0.0 + +jobs: + release: + name: Release Docker image + runs-on: ubuntu-latest + permissions: + packages: write + contents: write + id-token: write + issues: write + + steps: + - name: Check out the repo + uses: actions/checkout@v4 + + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v3 + + - name: Log in to the GitHub Container Registry + uses: docker/login-action@v3 + with: + registry: ghcr.io + username: ${{ github.actor }} + password: ${{ secrets.TOKEN }} + + - name: Extract version from tag + id: get_version + run: | + echo "VERSION=${GITHUB_REF#refs/tags/}" >> $GITHUB_ENV + + - name: Build and push Docker image + id: build_push + uses: docker/build-push-action@v6 + with: + context: . + push: true + tags: | + ghcr.io/${{ github.repository }}:${{ env.VERSION }} + ghcr.io/${{ github.repository }}:latest + platforms: linux/amd64,linux/arm64