From 9e8752e34f2e6fa55fd602fadb5f84545225d81d Mon Sep 17 00:00:00 2001 From: kangfenmao Date: Wed, 29 Nov 2023 19:58:28 +0800 Subject: [PATCH] ci(docker): add docker build github actions --- .github/workflows/docker-build.yaml | 40 +++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) create mode 100644 .github/workflows/docker-build.yaml diff --git a/.github/workflows/docker-build.yaml b/.github/workflows/docker-build.yaml new file mode 100644 index 0000000..8227c12 --- /dev/null +++ b/.github/workflows/docker-build.yaml @@ -0,0 +1,40 @@ +name: Build and Push Docker Image + +on: + push: + branches: + - main + tags: + - 'v*' + +jobs: + build-and-push: + runs-on: ubuntu-latest + steps: + - name: Set up QEMU + uses: docker/setup-qemu-action@v3 + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v3 + - name: Login to Docker Hub + uses: docker/login-action@v3 + with: + username: ${{ secrets.DOCKERHUB_USERNAME }} + password: ${{ secrets.DOCKERHUB_TOKEN }} + - name: Docker meta + id: meta + uses: docker/metadata-action@v5 + with: + images: kangfenmao/vortexnotes + tags: | + type=semver,pattern={{raw}} + type=raw,value=latest,enable={{is_default_branch}} + - name: Build and push + uses: docker/build-push-action@v5 + with: + context: "{{defaultContext}}" + platforms: linux/amd64,linux/arm64 + tags: ${{ steps.meta.outputs.tags }} + labels: ${{ steps.meta.outputs.labels }} + push: ${{ github.event_name != 'pull_request' }} + cache-from: type=gha,scope=cache + cache-to: type=gha,mode=max,scope=cache