From d62f3fb936f840f286210acefe92917f4541b575 Mon Sep 17 00:00:00 2001 From: MaysWind Date: Sun, 21 May 2023 00:06:11 +0800 Subject: [PATCH] update github actions --- .github/workflows/docker-release.yml | 55 ++++++++++++++++----------- .github/workflows/docker-snapshot.yml | 54 +++++++++++++++----------- 2 files changed, 63 insertions(+), 46 deletions(-) diff --git a/.github/workflows/docker-release.yml b/.github/workflows/docker-release.yml index 1c09757f..6e8c9e42 100644 --- a/.github/workflows/docker-release.yml +++ b/.github/workflows/docker-release.yml @@ -9,35 +9,44 @@ jobs: build: runs-on: ubuntu-latest steps: - - - name: Checkout - uses: actions/checkout@v2 - - - name: Set up docker tag - id: vars - run: echo ::set-output name=RELEASE_TAG::${GITHUB_REF/refs\/tags\/v/} - - - name: Set up QEMU - uses: docker/setup-qemu-action@v1 - - - name: Set up Docker Buildx - uses: docker/setup-buildx-action@v1 - - - name: Login to DockerHub - uses: docker/login-action@v1 + - name: Checkout + uses: actions/checkout@v3 + + - name: Docker meta + id: meta + uses: docker/metadata-action@v4 + with: + images: | + ${{ secrets.DOCKER_USERNAME }}/ezbookkeeping + tags: | + type=semver,pattern={{version}} + type=semver,pattern={{major}}.{{minor}} + type=raw,value=latest + + - name: Set up QEMU + uses: docker/setup-qemu-action@v2 + + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v2 + + - name: Login to DockerHub + uses: docker/login-action@v2 with: username: ${{ secrets.DOCKER_USERNAME }} password: ${{ secrets.DOCKER_PASSWORD }} - - - name: Build and push - uses: docker/build-push-action@v2 + + - name: Build and push + uses: docker/build-push-action@v4 with: file: Dockerfile context: . - platforms: linux/amd64,linux/arm64/v8,linux/arm/v7,linux/arm/v6 + platforms: | + linux/amd64 + linux/arm64/v8 + linux/arm/v7 + linux/arm/v6 push: true build-args: | RELEASE_BUILD=1 - tags: | - ${{ secrets.DOCKER_USERNAME }}/ezbookkeeping:${{ steps.vars.outputs.RELEASE_TAG }} - ${{ secrets.DOCKER_USERNAME }}/ezbookkeeping:latest \ No newline at end of file + tags: ${{ steps.meta.outputs.tags }} + labels: ${{ steps.meta.outputs.labels }} \ No newline at end of file diff --git a/.github/workflows/docker-snapshot.yml b/.github/workflows/docker-snapshot.yml index abbf371e..97b6e196 100644 --- a/.github/workflows/docker-snapshot.yml +++ b/.github/workflows/docker-snapshot.yml @@ -9,33 +9,41 @@ jobs: build: runs-on: ubuntu-latest steps: - - - name: Checkout - uses: actions/checkout@v2 - - - name: Set up docker tag - id: vars - run: echo ::set-output name=BUILD_DATE::$(date '+%Y%m%d') - - - name: Set up QEMU - uses: docker/setup-qemu-action@v1 - - - name: Set up Docker Buildx - uses: docker/setup-buildx-action@v1 - - - name: Login to DockerHub - uses: docker/login-action@v1 + - name: Checkout + uses: actions/checkout@v3 + + - name: Docker meta + id: meta + uses: docker/metadata-action@v4 + with: + images: | + ${{ secrets.DOCKER_USERNAME }}/ezbookkeeping + tags: | + type=raw,value=SNAPSHOT-{{date 'YYYYMMDD'}} + type=raw,value=latest-snapshot + + - name: Set up QEMU + uses: docker/setup-qemu-action@v2 + + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v2 + + - name: Login to DockerHub + uses: docker/login-action@v2 with: username: ${{ secrets.DOCKER_USERNAME }} password: ${{ secrets.DOCKER_PASSWORD }} - - - name: Build and push - uses: docker/build-push-action@v2 + + - name: Build and push + uses: docker/build-push-action@v4 with: file: Dockerfile context: . - platforms: linux/amd64,linux/arm64/v8,linux/arm/v7,linux/arm/v6 + platforms: | + linux/amd64 + linux/arm64/v8 + linux/arm/v7 + linux/arm/v6 push: true - tags: | - ${{ secrets.DOCKER_USERNAME }}/ezbookkeeping:SNAPSHOT-${{ steps.vars.outputs.BUILD_DATE }} - ${{ secrets.DOCKER_USERNAME }}/ezbookkeeping:latest-snapshot \ No newline at end of file + tags: ${{ steps.meta.outputs.tags }} + labels: ${{ steps.meta.outputs.labels }} \ No newline at end of file