mirror of https://github.com/halo-dev/halo
Refactor CICD for Halo next (#2236)
parent
c97804780b
commit
5953d2201d
|
@ -0,0 +1,56 @@
|
||||||
|
name: Halo CI
|
||||||
|
|
||||||
|
on:
|
||||||
|
pull_request:
|
||||||
|
paths:
|
||||||
|
- "**"
|
||||||
|
- "!**.md"
|
||||||
|
push:
|
||||||
|
branches:
|
||||||
|
- "**"
|
||||||
|
paths:
|
||||||
|
- "**"
|
||||||
|
- "!**.md"
|
||||||
|
release:
|
||||||
|
types: # This configuration does not affect the page_build event above
|
||||||
|
- created
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
check:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
# Default steps
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v2
|
||||||
|
with:
|
||||||
|
submodules: true
|
||||||
|
- name: Set up JDK 17
|
||||||
|
uses: actions/setup-java@v2
|
||||||
|
with:
|
||||||
|
distribution: 'temurin'
|
||||||
|
cache: 'gradle'
|
||||||
|
java-version: 17
|
||||||
|
- name: Check code style
|
||||||
|
run: ./gradlew check -x test
|
||||||
|
test:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v2
|
||||||
|
with:
|
||||||
|
submodules: true
|
||||||
|
- name: Set up JDK 17
|
||||||
|
uses: actions/setup-java@v2
|
||||||
|
with:
|
||||||
|
distribution: 'temurin'
|
||||||
|
cache: 'gradle'
|
||||||
|
java-version: 17
|
||||||
|
- name: Run tests
|
||||||
|
run: ./gradlew test
|
||||||
|
docker-build-and-push:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
needs: test
|
||||||
|
steps:
|
||||||
|
- uses: halo-sigs/actions/halo-next-docker-build@main # change the version to specific ref or release tag while the action is stable.
|
||||||
|
with:
|
||||||
|
image-name: halodev
|
||||||
|
ghcr-token: ${{ secrets.GHCR_TOKEN }}
|
||||||
|
push: ${{ github.event_name == 'push' && github.event.ref == 'refs/heads/next' }} # we only push to GHCR if the push is to the next branch
|
|
@ -1,158 +0,0 @@
|
||||||
name: Halo CI
|
|
||||||
|
|
||||||
on:
|
|
||||||
pull_request:
|
|
||||||
paths:
|
|
||||||
- "**"
|
|
||||||
- "!**.md"
|
|
||||||
push:
|
|
||||||
branches:
|
|
||||||
- "**"
|
|
||||||
paths:
|
|
||||||
- "**"
|
|
||||||
- "!**.md"
|
|
||||||
release:
|
|
||||||
types: # This configuration does not affect the page_build event above
|
|
||||||
- created
|
|
||||||
|
|
||||||
jobs:
|
|
||||||
check:
|
|
||||||
runs-on: ubuntu-latest
|
|
||||||
# Default steps
|
|
||||||
steps:
|
|
||||||
- uses: actions/checkout@v2
|
|
||||||
with:
|
|
||||||
submodules: true
|
|
||||||
- name: Set up JDK 17
|
|
||||||
uses: actions/setup-java@v2
|
|
||||||
with:
|
|
||||||
distribution: 'temurin'
|
|
||||||
cache: 'gradle'
|
|
||||||
java-version: 17
|
|
||||||
- name: Check And Test
|
|
||||||
run: ./gradlew check
|
|
||||||
build:
|
|
||||||
runs-on: ubuntu-latest
|
|
||||||
needs: check
|
|
||||||
if: github.event_name == 'release'
|
|
||||||
# Default steps
|
|
||||||
steps:
|
|
||||||
- uses: actions/checkout@v2
|
|
||||||
with:
|
|
||||||
submodules: true
|
|
||||||
- name: Set up JDK 17
|
|
||||||
uses: actions/setup-java@v2
|
|
||||||
with:
|
|
||||||
distribution: 'temurin'
|
|
||||||
cache: 'gradle'
|
|
||||||
java-version: 17
|
|
||||||
- name: Build with Gradle
|
|
||||||
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
|
|
||||||
./gradlew clean build -x test
|
|
||||||
- name: Archive halo jar
|
|
||||||
uses: actions/upload-artifact@v2
|
|
||||||
with:
|
|
||||||
name: halo-jar
|
|
||||||
path: |
|
|
||||||
build/libs
|
|
||||||
!build/libs/*-plain.jar
|
|
||||||
retention-days: 1
|
|
||||||
github-release:
|
|
||||||
runs-on: ubuntu-latest
|
|
||||||
needs: build
|
|
||||||
if: github.event_name == 'release'
|
|
||||||
steps:
|
|
||||||
- name: Download halo jar
|
|
||||||
uses: actions/download-artifact@v2
|
|
||||||
with:
|
|
||||||
name: halo-jar
|
|
||||||
path: build/libs
|
|
||||||
- name: Get Name of Artifact
|
|
||||||
id: get_artifact
|
|
||||||
run: |
|
|
||||||
ARTIFACT_PATHNAME=$(ls build/libs/*.jar | head -n 1)
|
|
||||||
ARTIFACT_NAME=$(basename ${ARTIFACT_PATHNAME})
|
|
||||||
echo "Artifact pathname: ${ARTIFACT_PATHNAME}"
|
|
||||||
echo "Artifact name: ${ARTIFACT_NAME}"
|
|
||||||
echo "ARTIFACT_PATHNAME=${ARTIFACT_PATHNAME}" >> $GITHUB_ENV
|
|
||||||
echo "ARTIFACT_NAME=${ARTIFACT_NAME}" >> $GITHUB_ENV
|
|
||||||
echo "RELEASE_ID=${{ github.event.release.id }}" >> $GITHUB_ENV
|
|
||||||
- name: Upload a Release Asset
|
|
||||||
uses: actions/github-script@v2
|
|
||||||
if: github.event_name == 'release'
|
|
||||||
with:
|
|
||||||
github-token: ${{secrets.GITHUB_TOKEN}}
|
|
||||||
script: |
|
|
||||||
console.log('environment', process.versions);
|
|
||||||
|
|
||||||
const fs = require('fs').promises;
|
|
||||||
|
|
||||||
const { repo: { owner, repo }, sha } = context;
|
|
||||||
console.log({ owner, repo, sha });
|
|
||||||
|
|
||||||
const releaseId = process.env.RELEASE_ID
|
|
||||||
const artifactPathName = process.env.ARTIFACT_PATHNAME
|
|
||||||
const artifactName = process.env.ARTIFACT_NAME
|
|
||||||
console.log('Releasing', releaseId, artifactPathName, artifactName)
|
|
||||||
|
|
||||||
await github.repos.uploadReleaseAsset({
|
|
||||||
owner, repo,
|
|
||||||
release_id: releaseId,
|
|
||||||
name: artifactName,
|
|
||||||
data: await fs.readFile(artifactPathName)
|
|
||||||
});
|
|
||||||
docker-release:
|
|
||||||
runs-on: ubuntu-latest
|
|
||||||
needs: build
|
|
||||||
if: github.event_name == 'release'
|
|
||||||
steps:
|
|
||||||
- uses: actions/checkout@v2
|
|
||||||
with:
|
|
||||||
submodules: true
|
|
||||||
- name: Download halo jar
|
|
||||||
uses: actions/download-artifact@v2
|
|
||||||
with:
|
|
||||||
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
|
|
||||||
uses: docker/login-action@v1
|
|
||||||
with:
|
|
||||||
username: ${{ secrets.DOCKER_USERNAME }}
|
|
||||||
password: ${{ secrets.DOCKER_TOKEN }}
|
|
||||||
- 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: linux/amd64,linux/arm/v7,linux/arm64
|
|
||||||
labels: ${{ steps.meta.outputs.labels }}
|
|
||||||
tags: ${{ steps.meta.outputs.tags }}
|
|
||||||
push: true
|
|
|
@ -1,29 +0,0 @@
|
||||||
name: Needs More Info Closer
|
|
||||||
on:
|
|
||||||
schedule:
|
|
||||||
- cron: 20 11 * * * # 4:20am Redmond
|
|
||||||
repository_dispatch:
|
|
||||||
types: [trigger-needs-more-info]
|
|
||||||
|
|
||||||
jobs:
|
|
||||||
main:
|
|
||||||
runs-on: ubuntu-latest
|
|
||||||
steps:
|
|
||||||
- name: Checkout Actions
|
|
||||||
uses: actions/checkout@v2
|
|
||||||
with:
|
|
||||||
repository: "microsoft/vscode-github-triage-actions"
|
|
||||||
path: ./actions
|
|
||||||
ref: stable
|
|
||||||
- name: Install Actions
|
|
||||||
run: npm install --production --prefix ./actions
|
|
||||||
- name: Run Needs More Info Closer
|
|
||||||
uses: ./actions/needs-more-info-closer
|
|
||||||
with:
|
|
||||||
token: ${{secrets.ISSUE_TRIAGE_BOT_PAT}}
|
|
||||||
label: needs more info
|
|
||||||
closeDays: 7
|
|
||||||
additionalTeam: "ruibaby|JohnNiang|guqing|LIlGG|halo-dev-bot"
|
|
||||||
closeComment: "此问题已自动关闭,因为它需要更多信息且最近没有活跃。"
|
|
||||||
pingDays: 80
|
|
||||||
pingComment: "Hey @${assignee}, 这个问题可能需要进一步关注。\n\n@${author}, 如果问题不再存在,您可以帮助我们关闭此问题,或者添加更多信息。"
|
|
|
@ -1,23 +0,0 @@
|
||||||
name: On Comment
|
|
||||||
on:
|
|
||||||
issue_comment:
|
|
||||||
types: [created]
|
|
||||||
|
|
||||||
# also make changes in ./on-label.yml
|
|
||||||
jobs:
|
|
||||||
main:
|
|
||||||
runs-on: ubuntu-latest
|
|
||||||
steps:
|
|
||||||
- name: Checkout Actions
|
|
||||||
uses: actions/checkout@v2
|
|
||||||
with:
|
|
||||||
repository: "microsoft/vscode-github-triage-actions"
|
|
||||||
path: ./actions
|
|
||||||
ref: stable
|
|
||||||
- name: Install Actions
|
|
||||||
run: npm install --production --prefix ./actions
|
|
||||||
- name: Run Commands
|
|
||||||
uses: ./actions/commands
|
|
||||||
with:
|
|
||||||
token: ${{secrets.ISSUE_TRIAGE_BOT_PAT}}
|
|
||||||
config-path: commands
|
|
|
@ -1,42 +0,0 @@
|
||||||
name: On Label
|
|
||||||
on:
|
|
||||||
issues:
|
|
||||||
types: [labeled]
|
|
||||||
|
|
||||||
jobs:
|
|
||||||
main:
|
|
||||||
runs-on: ubuntu-latest
|
|
||||||
steps:
|
|
||||||
- name: Checkout Actions
|
|
||||||
uses: actions/checkout@v2
|
|
||||||
with:
|
|
||||||
repository: "microsoft/vscode-github-triage-actions"
|
|
||||||
ref: stable
|
|
||||||
path: ./actions
|
|
||||||
- name: Install Actions
|
|
||||||
run: npm install --production --prefix ./actions
|
|
||||||
|
|
||||||
# source of truth in ./author-verified.yml
|
|
||||||
- name: Run Author Verified
|
|
||||||
if: contains(github.event.issue.labels.*.name, 'author-verification-requested')
|
|
||||||
uses: ./actions/author-verified
|
|
||||||
with:
|
|
||||||
token: ${{secrets.ISSUE_TRIAGE_BOT_PAT}}
|
|
||||||
requestVerificationComment: "该问题已在最新版本中修复!\n\n@${author},请在今天或者稍晚确认你的使用的版本是否包含该提交: ${commit},如果这件事已按预期得到解决,您可以通过评论 `/verified` 来帮助我们标记此问题。\n\n如果该问题仍然没有得到解决, 可以在评论中留下你希望得到的预期结果。"
|
|
||||||
verifiedLabel: verified
|
|
||||||
authorVerificationRequestedLabel: author-verification-requested
|
|
||||||
|
|
||||||
|
|
||||||
# also make changes in ./on-comment.yml
|
|
||||||
- name: Run Commands
|
|
||||||
uses: ./actions/commands
|
|
||||||
with:
|
|
||||||
token: ${{secrets.ISSUE_TRIAGE_BOT_PAT}}
|
|
||||||
config-path: commands
|
|
||||||
|
|
||||||
# only here.
|
|
||||||
- name: Run Subscribers
|
|
||||||
uses: ./actions/topic-subscribe
|
|
||||||
with:
|
|
||||||
token: ${{secrets.ISSUE_TRIAGE_BOT_PAT}}
|
|
||||||
config-path: subscribers
|
|
13
Dockerfile
13
Dockerfile
|
@ -1,12 +1,12 @@
|
||||||
FROM adoptopenjdk:11-jre-hotspot as builder
|
FROM eclipse-temurin:17-jre as builder
|
||||||
WORKDIR application
|
WORKDIR application
|
||||||
ARG JAR_FILE=build/libs/*.jar
|
ARG JAR_FILE=build/libs/halo-*.jar
|
||||||
COPY ${JAR_FILE} application.jar
|
COPY ${JAR_FILE} application.jar
|
||||||
RUN java -Djarmode=layertools -jar application.jar extract
|
RUN java -Djarmode=layertools -jar application.jar extract
|
||||||
|
|
||||||
################################
|
################################
|
||||||
|
|
||||||
FROM adoptopenjdk:11-jre-hotspot
|
FROM eclipse-temurin:17-jre
|
||||||
MAINTAINER johnniang <johnniang@fastmail.com>
|
MAINTAINER johnniang <johnniang@fastmail.com>
|
||||||
WORKDIR application
|
WORKDIR application
|
||||||
COPY --from=builder application/dependencies/ ./
|
COPY --from=builder application/dependencies/ ./
|
||||||
|
@ -14,13 +14,10 @@ COPY --from=builder application/spring-boot-loader/ ./
|
||||||
COPY --from=builder application/snapshot-dependencies/ ./
|
COPY --from=builder application/snapshot-dependencies/ ./
|
||||||
COPY --from=builder application/application/ ./
|
COPY --from=builder application/application/ ./
|
||||||
|
|
||||||
# JVM_XMS and JVM_XMX configs deprecated for removal in halov1.4.4
|
ENV JVM_OPTS="-Xmx256m -Xms256m" \
|
||||||
ENV JVM_XMS="256m" \
|
|
||||||
JVM_XMX="256m" \
|
|
||||||
JVM_OPTS="-Xmx256m -Xms256m" \
|
|
||||||
TZ=Asia/Shanghai
|
TZ=Asia/Shanghai
|
||||||
|
|
||||||
RUN ln -sf /usr/share/zoneinfo/$TZ /etc/localtime \
|
RUN ln -sf /usr/share/zoneinfo/$TZ /etc/localtime \
|
||||||
&& echo $TZ > /etc/timezone
|
&& echo $TZ > /etc/timezone
|
||||||
|
|
||||||
ENTRYPOINT java -Xms${JVM_XMS} -Xmx${JVM_XMX} ${JVM_OPTS} -Djava.security.egd=file:/dev/./urandom org.springframework.boot.loader.JarLauncher
|
ENTRYPOINT java ${JVM_OPTS} -Djava.security.egd=file:/dev/./urandom org.springframework.boot.loader.JarLauncher
|
|
@ -37,7 +37,6 @@ configurations {
|
||||||
}
|
}
|
||||||
|
|
||||||
bootJar {
|
bootJar {
|
||||||
launchScript()
|
|
||||||
manifest {
|
manifest {
|
||||||
attributes "Implementation-Title": "Halo Application",
|
attributes "Implementation-Title": "Halo Application",
|
||||||
"Implementation-Version": archiveVersion
|
"Implementation-Version": archiveVersion
|
||||||
|
|
Loading…
Reference in New Issue