From 4ffbd502fee82033dbf5b4918fee0fd889762ff3 Mon Sep 17 00:00:00 2001 From: John Niang Date: Mon, 1 Nov 2021 08:56:58 +0800 Subject: [PATCH] Refactor docker release in GitHub workflow (#1510) Signed-off-by: John Niang --- .github/workflows/halo.yml | 65 +++++++++++++++++++------------------- 1 file changed, 33 insertions(+), 32 deletions(-) diff --git a/.github/workflows/halo.yml b/.github/workflows/halo.yml index 6a933981..00fc4deb 100644 --- a/.github/workflows/halo.yml +++ b/.github/workflows/halo.yml @@ -3,14 +3,14 @@ name: Halo CI on: pull_request: paths: - - '**' - - '!**.md' + - "**" + - "!**.md" push: branches: - - '**' + - "**" paths: - - '**' - - '!**.md' + - "**" + - "!**.md" release: types: # This configuration does not affect the page_build event above - created @@ -109,45 +109,46 @@ jobs: - uses: actions/checkout@v2 with: submodules: true - - name: Set up JDK 11 - uses: actions/setup-java@v2 + - name: Download halo jar + uses: actions/download-artifact@v2 with: - distribution: 'temurin' - cache: 'gradle' - java-version: 11 - - name: Get version of halo - id: get_halo_version - run: | - version=$(./gradlew -q projectVersion) - echo "Trying to build and publish halo:${version}" - echo "HALO_VERSION=${version}" >> $GITHUB_ENV + name: halo-jar + path: build/libs + - name: Docker meta for Halo + id: meta + uses: docker/metadata-action@v3 + with: + images: | + halohub/halo + ghcr.io/${{ github.repository_owner }}/halo + tags: | + type=schedule + type=ref,event=branch + type=ref,event=pr + type=semver,pattern={{ version }} + type=semver,pattern={{major}}.{{minor}} + type=sha - 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 + - name: Login to DockerHub uses: docker/login-action@v1 with: username: ${{ secrets.DOCKER_USERNAME }} password: ${{ secrets.DOCKER_TOKEN }} - - - name: Build and push with version tag - uses: docker/build-push-action@v2 + - name: Login to GHCR + uses: docker/login-action@v1 with: - context: . - file: ./Dockerfile - platforms: ${{ secrets.DOCKER_PLATFORMS }} - push: true - tags: | - ${{ secrets.DOCKER_IMAGE_NAME }}:${{ env.HALO_VERSION}} - - name: Build and push with latest tag + registry: ghcr.io + username: ${{ github.repository_owner }} + password: ${{ secrets.GHCR_TOKEN }} + - name: Build and push uses: docker/build-push-action@v2 - if: "!github.event.release.prerelease" with: context: . file: ./Dockerfile - platforms: ${{ secrets.DOCKER_PLATFORMS }} + platforms: linux/amd64,linux/arm/v7,linux/arm64 + labels: ${{ steps.meta.outputs.labels }} + tags: ${{ steps.meta.outputs.tags }} push: true - tags: | - ${{ secrets.DOCKER_IMAGE_NAME }}:latest -- GitLab