mirror of https://github.com/halo-dev/halo
Refactor docker release in GitHub workflow (#1510)
Signed-off-by: John Niang <johnniang@fastmail.com>pull/1515/head
parent
6be4051f9e
commit
4ffbd502fe
|
@ -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
|
||||
- name: Login to GHCR
|
||||
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
|
||||
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 }}:${{ 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
|
||||
|
|
Loading…
Reference in New Issue