From 8aa7c2a353720fedf0386af77ed7818a5e872576 Mon Sep 17 00:00:00 2001 From: zhuweitung Date: Fri, 18 Oct 2024 08:53:57 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=20github=20action=20?= =?UTF-8?q?=E8=84=9A=E6=9C=AC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/build.yml | 58 +++++++++++++++++++++++++++++++++++++ 1 file changed, 58 insertions(+) create mode 100644 .github/workflows/build.yml diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml new file mode 100644 index 0000000..582a118 --- /dev/null +++ b/.github/workflows/build.yml @@ -0,0 +1,58 @@ +name: build + +on: + push: + tags: + - v* + +jobs: + docker-release: + runs-on: ubuntu-latest + strategy: + matrix: + target: + - Dockerfile: Dockerfile + steps: + - uses: actions/checkout@v3 + + - uses: actions/setup-java@v4 + with: + java-version: '17' + distribution: 'graalvm' + cache: maven + - name: Build with Maven + run: mvn -B clean package --file pom.xml + + - name: Prepare + id: prepare + run: | + TAG=${GITHUB_REF#refs/tags/} + echo ::set-output name=full_tag_name::${TAG} + echo ::set-output name=latest_tag::latest + + - name: Set up QEMU + uses: docker/setup-qemu-action@v1 + + - name: Set up Docker Buildx + id: buildx + uses: docker/setup-buildx-action@master + + - name: Login to Docker Hub + uses: docker/login-action@v1 + with: + username: ${{ secrets.DOCKERHUB_USERNAME }} + password: ${{ secrets.DOCKERHUB_TOKEN }} + + - name: Build and publish ${{ matrix.target.Dockerfile }} + uses: docker/build-push-action@v2 + with: + context: . + push: true + builder: ${{ steps.buildx.outputs.name }} + file: ${{ matrix.target.Dockerfile }} + platforms: linux/amd64,linux/arm64,linux/arm + cache-from: type=gha,scope=${{ github.workflow }} + cache-to: type=gha,mode=max,scope=${{ github.workflow }} + tags: | + zhuweitung/jd-stock:${{ steps.prepare.outputs.full_tag_name }} + zhuweitung/jd-stock:${{ steps.prepare.outputs.latest_tag }}