From a194286eccb065497328860fff9069a79c8db511 Mon Sep 17 00:00:00 2001 From: SUGE2016 Date: Thu, 5 Mar 2026 14:26:43 +0800 Subject: [PATCH] Add GitHub Actions workflow for building Docker image --- .github/workflows/build-image.yml | 55 +++++++++++++++++++++++++++++++ 1 file changed, 55 insertions(+) create mode 100644 .github/workflows/build-image.yml diff --git a/.github/workflows/build-image.yml b/.github/workflows/build-image.yml new file mode 100644 index 0000000..f1ef8ba --- /dev/null +++ b/.github/workflows/build-image.yml @@ -0,0 +1,55 @@ +name: Build Docker Image + +on: + push: + branches: [master, main] + tags: ['v*'] + pull_request: + branches: [master, main] + +env: + REGISTRY: ghcr.io + +jobs: + build: + runs-on: ubuntu-latest + permissions: + contents: read + packages: write + + steps: + - name: Checkout + uses: actions/checkout@v4 + + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v3 + + - name: Log in to Container Registry + if: github.event_name != 'pull_request' + uses: docker/login-action@v3 + with: + registry: ${{ env.REGISTRY }} + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} + + - name: Extract metadata + id: meta + uses: docker/metadata-action@v5 + with: + images: ${{ env.REGISTRY }}/${{ github.repository }}/agent-task + tags: | + type=ref,event=branch + type=ref,event=tag + type=sha,prefix= + type=raw,value=latest,enable=${{ github.ref == 'refs/heads/master' || github.ref == 'refs/heads/main' }} + + - name: Build and push + uses: docker/build-push-action@v6 + with: + context: . + file: docker/agent-task/Dockerfile + push: ${{ github.event_name != 'pull_request' }} + tags: ${{ steps.meta.outputs.tags }} + labels: ${{ steps.meta.outputs.labels }} + cache-from: type=gha + cache-to: type=gha,mode=max