mirror of https://github.com/halo-dev/halo
Merge pull request #5170 from JohnNiang/refactor/workflow
Refactor workflow by not using composite actions from halo-sigs/actionspull/5176/head
commit
5f0ac9f5ca
|
@ -0,0 +1,74 @@
|
||||||
|
name: "Docker buildx and push"
|
||||||
|
description: "Buildx and push the Docker image."
|
||||||
|
|
||||||
|
inputs:
|
||||||
|
ghcr-token:
|
||||||
|
description: Token of current GitHub account in GitHub container registry.
|
||||||
|
required: false
|
||||||
|
default: ""
|
||||||
|
dockerhub-user:
|
||||||
|
description: "User name for the DockerHub account"
|
||||||
|
required: false
|
||||||
|
default: ""
|
||||||
|
dockerhub-token:
|
||||||
|
description: Token for the DockerHub account
|
||||||
|
required: false
|
||||||
|
default: ""
|
||||||
|
push:
|
||||||
|
description: Should push the docker image or not.
|
||||||
|
required: false
|
||||||
|
default: "false"
|
||||||
|
platforms:
|
||||||
|
description: Target platforms for building image
|
||||||
|
required: false
|
||||||
|
default: "linux/amd64,linux/arm/v7,linux/arm64/v8,linux/ppc64le,linux/s390x"
|
||||||
|
image-name:
|
||||||
|
description: The basic name of docker.
|
||||||
|
required: false
|
||||||
|
default: "halo"
|
||||||
|
|
||||||
|
runs:
|
||||||
|
using: "composite"
|
||||||
|
steps:
|
||||||
|
- name: Docker meta for Halo
|
||||||
|
id: meta
|
||||||
|
uses: docker/metadata-action@v5
|
||||||
|
with:
|
||||||
|
images: |
|
||||||
|
ghcr.io/${{ github.repository_owner }}/${{ inputs.image-name }}
|
||||||
|
halohub/${{ inputs.image-name }}
|
||||||
|
tags: |
|
||||||
|
type=schedule,pattern=nightly-{{date 'YYYYMMDD'}},enabled=${{ github.event_name == 'schedule' }}
|
||||||
|
type=ref,event=branch,enabled=${{ github.event_name == 'push' }}
|
||||||
|
type=ref,event=pr,enabled=${{ github.event_name == 'pull_request' }}
|
||||||
|
type=semver,pattern={{ version }}
|
||||||
|
type=semver,pattern={{major}}.{{minor}}
|
||||||
|
type=sha,enabled=${{ github.event_name == 'push' }}
|
||||||
|
flavor: |
|
||||||
|
latest=false
|
||||||
|
- name: Set up QEMU
|
||||||
|
uses: docker/setup-qemu-action@v2
|
||||||
|
- name: Set up Docker Buildx
|
||||||
|
uses: docker/setup-buildx-action@v2
|
||||||
|
- name: Login to GHCR
|
||||||
|
uses: docker/login-action@v3
|
||||||
|
if: inputs.ghcr-token != '' && github.event_name != 'pull_request'
|
||||||
|
with:
|
||||||
|
registry: ghcr.io
|
||||||
|
username: ${{ github.repository_owner }}
|
||||||
|
password: ${{ inputs.ghcr-token }}
|
||||||
|
- name: Login to DockerHub
|
||||||
|
if: inputs.dockerhub-token != '' && github.event_name != 'pull_request'
|
||||||
|
uses: docker/login-action@v2
|
||||||
|
with:
|
||||||
|
username: ${{ inputs.dockerhub-user }}
|
||||||
|
password: ${{ inputs.dockerhub-token }}
|
||||||
|
- name: Build and push
|
||||||
|
uses: docker/build-push-action@v5
|
||||||
|
with:
|
||||||
|
context: .
|
||||||
|
file: ./Dockerfile
|
||||||
|
platforms: ${{ inputs.platforms }}
|
||||||
|
labels: ${{ steps.meta.outputs.labels }}
|
||||||
|
tags: ${{ steps.meta.outputs.tags }}
|
||||||
|
push: ${{ (inputs.ghcr-token != '' || inputs.dockerhub-token != '') && inputs.push == 'true' }}
|
|
@ -0,0 +1,61 @@
|
||||||
|
name: Setup Environment
|
||||||
|
description: Setup environment to check and build Halo, including console and core projects.
|
||||||
|
|
||||||
|
inputs:
|
||||||
|
node-version:
|
||||||
|
description: Node.js version.
|
||||||
|
required: false
|
||||||
|
default: "18"
|
||||||
|
|
||||||
|
pnpm-version:
|
||||||
|
description: pnpm version.
|
||||||
|
required: false
|
||||||
|
default: "8"
|
||||||
|
|
||||||
|
java-version:
|
||||||
|
description: Java version.
|
||||||
|
required: false
|
||||||
|
default: "17"
|
||||||
|
|
||||||
|
runs:
|
||||||
|
using: "composite"
|
||||||
|
steps:
|
||||||
|
- name: Set up Node.js
|
||||||
|
uses: actions/setup-node@v3
|
||||||
|
with:
|
||||||
|
node-version: ${{ inputs.node-version }}
|
||||||
|
|
||||||
|
- uses: pnpm/action-setup@v2
|
||||||
|
name: Setup pnpm
|
||||||
|
id: pnpm-install
|
||||||
|
with:
|
||||||
|
version: ${{ inputs.pnpm-version }}
|
||||||
|
run_install: false
|
||||||
|
|
||||||
|
- name: Get pnpm store directory
|
||||||
|
id: pnpm-cache
|
||||||
|
shell: bash
|
||||||
|
run: |
|
||||||
|
echo "STORE_PATH=$(pnpm store path)" >> $GITHUB_OUTPUT
|
||||||
|
|
||||||
|
- uses: actions/cache@v3
|
||||||
|
name: Setup pnpm cache
|
||||||
|
with:
|
||||||
|
path: ${{ steps.pnpm-cache.outputs.STORE_PATH}}
|
||||||
|
key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }}
|
||||||
|
restore-keys: |
|
||||||
|
${{ runner.os }}-pnpm-store-
|
||||||
|
|
||||||
|
- name: Setup JDK
|
||||||
|
uses: actions/setup-java@v4
|
||||||
|
with:
|
||||||
|
distribution: "temurin"
|
||||||
|
cache: "gradle"
|
||||||
|
java-version: ${{ inputs.java-version }}
|
||||||
|
|
||||||
|
- name: Cache SonarCloud packages
|
||||||
|
uses: actions/cache@v3
|
||||||
|
with:
|
||||||
|
path: ~/.sonar/cache
|
||||||
|
key: ${{ runner.os }}-sonar
|
||||||
|
restore-keys: ${{ runner.os }}-sonar
|
|
@ -1,4 +1,4 @@
|
||||||
name: Halo CI
|
name: Halo Workflow
|
||||||
|
|
||||||
on:
|
on:
|
||||||
pull_request:
|
pull_request:
|
||||||
|
@ -16,80 +16,110 @@ on:
|
||||||
- "**"
|
- "**"
|
||||||
- "!**.md"
|
- "!**.md"
|
||||||
release:
|
release:
|
||||||
types: # This configuration does not affect the page_build event above
|
types:
|
||||||
- created
|
- published
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
check:
|
test:
|
||||||
|
if: github.event_name == 'pull_request' || github.event_name == 'push'
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
# Default steps
|
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v3
|
- uses: actions/checkout@v3
|
||||||
with:
|
- name: Setup Environment
|
||||||
submodules: true
|
uses: ./.github/actions/setup-env
|
||||||
- name: Set up JDK 17
|
- name: Check Halo console
|
||||||
uses: actions/setup-java@v3
|
run: make -C console check
|
||||||
with:
|
- name: Check Halo core
|
||||||
distribution: 'temurin'
|
|
||||||
cache: 'gradle'
|
|
||||||
java-version: 17
|
|
||||||
- name: Cache SonarCloud packages
|
|
||||||
uses: actions/cache@v3
|
|
||||||
with:
|
|
||||||
path: ~/.sonar/cache
|
|
||||||
key: ${{ runner.os }}-sonar
|
|
||||||
restore-keys: ${{ runner.os }}-sonar
|
|
||||||
- uses: dorny/paths-filter@v2
|
|
||||||
id: changes
|
|
||||||
with:
|
|
||||||
filters: |
|
|
||||||
console:
|
|
||||||
- 'console/**'
|
|
||||||
- name: Check halo
|
|
||||||
run: ./gradlew check
|
run: ./gradlew check
|
||||||
- name: Upload coverage reports to Codecov
|
|
||||||
uses: codecov/codecov-action@v3
|
|
||||||
- name: Analyze code
|
- name: Analyze code
|
||||||
if: ${{ github.event_name == 'push' }} # Due to inability to access secrets during PR, only the code pushed into the branch can be analyzed.
|
if: ${{ github.event_name == 'push' && env.SONAR_TOKEN != '' }} # Due to inability to access secrets during PR, only the code pushed into the branch can be analyzed.
|
||||||
env:
|
env:
|
||||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # Needed to get PR information, if any
|
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # Needed to get PR information, if any
|
||||||
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
|
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
|
||||||
run: ./gradlew sonar --info
|
run: ./gradlew sonar --info
|
||||||
- name: Setup console environment
|
build:
|
||||||
if: steps.changes.outputs.console == 'true'
|
|
||||||
uses: halo-sigs/actions/admin-env-setup@main
|
|
||||||
- name: Check console
|
|
||||||
if: steps.changes.outputs.console == 'true'
|
|
||||||
run: make -C console check
|
|
||||||
docker-build-and-push:
|
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
needs: check
|
if: always() && (needs.test.result == 'skipped' || needs.test.result == 'success')
|
||||||
|
needs: test
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v3
|
- uses: actions/checkout@v3
|
||||||
- uses: halo-sigs/actions/halo-next-docker-build@main # change the version to specific ref or release tag while the action is stable.
|
- name: Setup Environment
|
||||||
if: github.event_name != 'pull_request'
|
uses: ./.github/actions/setup-env
|
||||||
|
- name: Build Halo console
|
||||||
|
run: make -C console build
|
||||||
|
- name: Reset version of Halo
|
||||||
|
if: github.event_name == 'release'
|
||||||
|
shell: bash
|
||||||
|
run: |
|
||||||
|
# Set the version with tag name when releasing
|
||||||
|
version=${{ github.event.release.tag_name }}
|
||||||
|
version=${version#v}
|
||||||
|
sed -i "s/version=.*-SNAPSHOT$/version=$version/1" gradle.properties
|
||||||
|
- name: Build Halo core
|
||||||
|
run: ./gradlew clean && ./gradlew downloadPluginPresets && ./gradlew build -x check
|
||||||
|
- name: Upload Artifacts
|
||||||
|
uses: actions/upload-artifact@v4
|
||||||
|
with:
|
||||||
|
name: halo-artifacts
|
||||||
|
path: application/build/libs
|
||||||
|
retention-days: 1
|
||||||
|
|
||||||
|
github-release:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
if: always() && needs.build.result == 'success' && github.event_name == 'release'
|
||||||
|
needs: build
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v3
|
||||||
|
- name: Download Artifacts
|
||||||
|
uses: actions/download-artifact@v4
|
||||||
|
with:
|
||||||
|
name: halo-artifacts
|
||||||
|
path: application/build/libs
|
||||||
|
- name: Upload Artifacts
|
||||||
|
env:
|
||||||
|
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||||
|
run: gh release upload ${{ github.event.release.tag_name }} application/build/libs/*
|
||||||
|
|
||||||
|
docker-build-and-push:
|
||||||
|
if: always() && needs.build.result == 'success' && (github.event_name == 'push' || github.event_name == 'release')
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
needs: build
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v3
|
||||||
|
- name: Download Artifacts
|
||||||
|
uses: actions/download-artifact@v4
|
||||||
|
with:
|
||||||
|
name: halo-artifacts
|
||||||
|
path: application/build/libs
|
||||||
|
- name: Docker Buildx and Push
|
||||||
|
uses: ./.github/actions/docker-buildx-push
|
||||||
with:
|
with:
|
||||||
image-name: ${{ github.event_name == 'release' && 'halo' || 'halo-dev' }}
|
image-name: ${{ github.event_name == 'release' && 'halo' || 'halo-dev' }}
|
||||||
ghcr-token: ${{ secrets.GHCR_TOKEN }}
|
ghcr-token: ${{ secrets.GITHUB_TOKEN }}
|
||||||
dockerhub-user: ${{ secrets.DOCKER_USERNAME }}
|
dockerhub-user: ${{ secrets.DOCKER_USERNAME }}
|
||||||
dockerhub-token: ${{ secrets.DOCKER_TOKEN }}
|
dockerhub-token: ${{ secrets.DOCKER_TOKEN }}
|
||||||
push: ${{ github.event_name == 'push' || github.event_name == 'release' }} # we only push to GHCR if the push is to the next branch
|
push: true
|
||||||
console-ref: ${{ github.event_name == 'release' && github.ref || 'main' }}
|
|
||||||
platforms: linux/amd64,linux/arm64/v8,linux/ppc64le,linux/s390x
|
platforms: linux/amd64,linux/arm64/v8,linux/ppc64le,linux/s390x
|
||||||
- uses: halo-sigs/actions/halo-next-docker-build@main
|
|
||||||
if: github.event_name == 'pull_request'
|
e2e-test:
|
||||||
|
if: always() && needs.build.result == 'success' && (github.event_name == 'pull_request' || github.event_name == 'push')
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
needs: build
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v3
|
||||||
|
- name: Download Artifacts
|
||||||
|
uses: actions/download-artifact@v4
|
||||||
with:
|
with:
|
||||||
image-name: halo-dev
|
name: halo-artifacts
|
||||||
|
path: application/build/libs
|
||||||
|
- name: Docker Build
|
||||||
|
uses: docker/build-push-action@v5
|
||||||
|
with:
|
||||||
|
tags: ghcr.io/halo-dev/halo-dev:main
|
||||||
push: false
|
push: false
|
||||||
console-ref: false
|
context: .
|
||||||
load: true
|
|
||||||
platforms: ""
|
|
||||||
- name: E2E Testing
|
- name: E2E Testing
|
||||||
if: github.event_name == 'pull_request'
|
|
||||||
run: |
|
run: |
|
||||||
sudo curl -L https://github.com/docker/compose/releases/download/v2.23.0/docker-compose-linux-x86_64 -o /usr/local/bin/docker-compose
|
sudo curl -L https://github.com/docker/compose/releases/download/v2.23.0/docker-compose-linux-x86_64 -o /usr/local/bin/docker-compose
|
||||||
sudo chmod u+x /usr/local/bin/docker-compose
|
sudo chmod u+x /usr/local/bin/docker-compose
|
||||||
|
|
||||||
repo=$(echo ${{ github.repository_owner }} | tr '[:upper:]' '[:lower:]')
|
|
||||||
docker tag ghcr.io/${repo}/halo-dev:pr-${{ github.event.number }} ghcr.io/halo-dev/halo-dev:main
|
|
||||||
cd e2e && make all
|
cd e2e && make all
|
||||||
|
|
|
@ -1,3 +1,6 @@
|
||||||
|
import de.undercouch.gradle.tasks.download.Download
|
||||||
|
import org.gradle.crypto.checksum.Checksum
|
||||||
|
|
||||||
plugins {
|
plugins {
|
||||||
id 'org.springframework.boot' version '3.2.0'
|
id 'org.springframework.boot' version '3.2.0'
|
||||||
id 'io.spring.dependency-management' version '1.1.0'
|
id 'io.spring.dependency-management' version '1.1.0'
|
||||||
|
@ -7,12 +10,18 @@ plugins {
|
||||||
id 'jacoco'
|
id 'jacoco'
|
||||||
id "de.undercouch.download" version "5.3.1"
|
id "de.undercouch.download" version "5.3.1"
|
||||||
id "io.freefair.lombok" version "8.4"
|
id "io.freefair.lombok" version "8.4"
|
||||||
|
id 'org.gradle.crypto.checksum' version '1.4.0'
|
||||||
}
|
}
|
||||||
|
|
||||||
group = "run.halo.app"
|
group = 'run.halo.app'
|
||||||
sourceCompatibility = JavaVersion.VERSION_17
|
compileJava.options.encoding = 'UTF-8'
|
||||||
compileJava.options.encoding = "UTF-8"
|
compileTestJava.options.encoding = 'UTF-8'
|
||||||
compileTestJava.options.encoding = "UTF-8"
|
|
||||||
|
java {
|
||||||
|
toolchain {
|
||||||
|
languageVersion = JavaLanguageVersion.of(17)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
checkstyle {
|
checkstyle {
|
||||||
toolVersion = "9.3"
|
toolVersion = "9.3"
|
||||||
|
@ -35,13 +44,19 @@ configurations {
|
||||||
}
|
}
|
||||||
|
|
||||||
springBoot {
|
springBoot {
|
||||||
buildInfo()
|
buildInfo {
|
||||||
|
properties {
|
||||||
|
artifact = 'halo'
|
||||||
|
name = 'halo'
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bootJar {
|
bootJar {
|
||||||
|
archiveBaseName = 'halo'
|
||||||
manifest {
|
manifest {
|
||||||
attributes "Implementation-Title": "Halo Application",
|
attributes 'Implementation-Title': 'Halo Application',
|
||||||
"Implementation-Version": archiveVersion
|
'Implementation-Vendor': 'Halo OSS Team'
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -60,12 +75,23 @@ dependencies {
|
||||||
testImplementation 'io.projectreactor:reactor-test'
|
testImplementation 'io.projectreactor:reactor-test'
|
||||||
}
|
}
|
||||||
|
|
||||||
tasks.named('test') {
|
tasks.register('createChecksums', Checksum) {
|
||||||
|
dependsOn tasks.named('bootJar')
|
||||||
|
inputFiles.setFrom(layout.buildDirectory.files('libs'))
|
||||||
|
outputDirectory = layout.buildDirectory.dir("libs")
|
||||||
|
checksumAlgorithm = Checksum.Algorithm.SHA256
|
||||||
|
}
|
||||||
|
|
||||||
|
tasks.named('build') {
|
||||||
|
dependsOn tasks.named('createChecksums')
|
||||||
|
}
|
||||||
|
|
||||||
|
tasks.named('test', Test) {
|
||||||
useJUnitPlatform()
|
useJUnitPlatform()
|
||||||
finalizedBy jacocoTestReport
|
finalizedBy jacocoTestReport
|
||||||
}
|
}
|
||||||
|
|
||||||
tasks.named('jacocoTestReport') {
|
tasks.named('jacocoTestReport', JacocoReport) {
|
||||||
reports {
|
reports {
|
||||||
xml.required = true
|
xml.required = true
|
||||||
html.required = false
|
html.required = false
|
||||||
|
|
Loading…
Reference in New Issue