Refactor docker release in GitHub workflow (#1510)

Signed-off-by: John Niang <johnniang@fastmail.com>
pull/1515/head
John Niang 2021-11-01 08:56:58 +08:00 committed by GitHub
parent 6be4051f9e
commit 4ffbd502fe
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 34 additions and 33 deletions

View File

@ -3,14 +3,14 @@ name: Halo CI
on: on:
pull_request: pull_request:
paths: paths:
- '**' - "**"
- '!**.md' - "!**.md"
push: push:
branches: branches:
- '**' - "**"
paths: paths:
- '**' - "**"
- '!**.md' - "!**.md"
release: release:
types: # This configuration does not affect the page_build event above types: # This configuration does not affect the page_build event above
- created - created
@ -109,45 +109,46 @@ jobs:
- uses: actions/checkout@v2 - uses: actions/checkout@v2
with: with:
submodules: true submodules: true
- name: Set up JDK 11 - name: Download halo jar
uses: actions/setup-java@v2 uses: actions/download-artifact@v2
with: with:
distribution: 'temurin' name: halo-jar
cache: 'gradle' path: build/libs
java-version: 11 - name: Docker meta for Halo
- name: Get version of halo id: meta
id: get_halo_version uses: docker/metadata-action@v3
run: | with:
version=$(./gradlew -q projectVersion) images: |
echo "Trying to build and publish halo:${version}" halohub/halo
echo "HALO_VERSION=${version}" >> $GITHUB_ENV 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 - name: Set up QEMU
uses: docker/setup-qemu-action@v1 uses: docker/setup-qemu-action@v1
- name: Set up Docker Buildx - name: Set up Docker Buildx
uses: docker/setup-buildx-action@v1 uses: docker/setup-buildx-action@v1
- - name: Login to DockerHub
name: Login to DockerHub
uses: docker/login-action@v1 uses: docker/login-action@v1
with: with:
username: ${{ secrets.DOCKER_USERNAME }} username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_TOKEN }} password: ${{ secrets.DOCKER_TOKEN }}
- - name: Login to GHCR
name: Build and push with version tag uses: docker/login-action@v1
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.GHCR_TOKEN }}
- name: Build and push
uses: docker/build-push-action@v2 uses: docker/build-push-action@v2
with: with:
context: . context: .
file: ./Dockerfile 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 push: true
tags: |
${{ secrets.DOCKER_IMAGE_NAME }}:${{ env.HALO_VERSION}}
- name: Build and push with latest tag
uses: docker/build-push-action@v2
if: "!github.event.release.prerelease"
with:
context: .
file: ./Dockerfile
platforms: ${{ secrets.DOCKER_PLATFORMS }}
push: true
tags: |
${{ secrets.DOCKER_IMAGE_NAME }}:latest