From 5953d2201db39d7abb12bed5cbdb502300f485bb Mon Sep 17 00:00:00 2001 From: John Niang Date: Tue, 12 Jul 2022 11:01:00 +0800 Subject: [PATCH] Refactor CICD for Halo next (#2236) --- .github/workflows/halo.yaml | 56 +++++++ .github/workflows/halo.yml | 158 ------------------- .github/workflows/needs-more-info-closer.yml | 29 ---- .github/workflows/on-comment.yml | 23 --- .github/workflows/on-label.yml | 42 ----- Dockerfile | 13 +- build.gradle | 1 - 7 files changed, 61 insertions(+), 261 deletions(-) create mode 100644 .github/workflows/halo.yaml delete mode 100644 .github/workflows/halo.yml delete mode 100644 .github/workflows/needs-more-info-closer.yml delete mode 100644 .github/workflows/on-comment.yml delete mode 100644 .github/workflows/on-label.yml diff --git a/.github/workflows/halo.yaml b/.github/workflows/halo.yaml new file mode 100644 index 0000000000..fd16900984 --- /dev/null +++ b/.github/workflows/halo.yaml @@ -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 diff --git a/.github/workflows/halo.yml b/.github/workflows/halo.yml deleted file mode 100644 index 335dd38ce1..0000000000 --- a/.github/workflows/halo.yml +++ /dev/null @@ -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 diff --git a/.github/workflows/needs-more-info-closer.yml b/.github/workflows/needs-more-info-closer.yml deleted file mode 100644 index 2551af1a57..0000000000 --- a/.github/workflows/needs-more-info-closer.yml +++ /dev/null @@ -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}, 如果问题不再存在,您可以帮助我们关闭此问题,或者添加更多信息。" \ No newline at end of file diff --git a/.github/workflows/on-comment.yml b/.github/workflows/on-comment.yml deleted file mode 100644 index eee399508a..0000000000 --- a/.github/workflows/on-comment.yml +++ /dev/null @@ -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 \ No newline at end of file diff --git a/.github/workflows/on-label.yml b/.github/workflows/on-label.yml deleted file mode 100644 index 02e6d84b1f..0000000000 --- a/.github/workflows/on-label.yml +++ /dev/null @@ -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 \ No newline at end of file diff --git a/Dockerfile b/Dockerfile index 55dddd80ad..cd7253431e 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,12 +1,12 @@ -FROM adoptopenjdk:11-jre-hotspot as builder +FROM eclipse-temurin:17-jre as builder WORKDIR application -ARG JAR_FILE=build/libs/*.jar +ARG JAR_FILE=build/libs/halo-*.jar COPY ${JAR_FILE} application.jar RUN java -Djarmode=layertools -jar application.jar extract ################################ -FROM adoptopenjdk:11-jre-hotspot +FROM eclipse-temurin:17-jre MAINTAINER johnniang WORKDIR application 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/application/ ./ -# JVM_XMS and JVM_XMX configs deprecated for removal in halov1.4.4 -ENV JVM_XMS="256m" \ - JVM_XMX="256m" \ - JVM_OPTS="-Xmx256m -Xms256m" \ +ENV JVM_OPTS="-Xmx256m -Xms256m" \ TZ=Asia/Shanghai RUN ln -sf /usr/share/zoneinfo/$TZ /etc/localtime \ && 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 \ No newline at end of file +ENTRYPOINT java ${JVM_OPTS} -Djava.security.egd=file:/dev/./urandom org.springframework.boot.loader.JarLauncher \ No newline at end of file diff --git a/build.gradle b/build.gradle index b209605b56..fe9399de53 100644 --- a/build.gradle +++ b/build.gradle @@ -37,7 +37,6 @@ configurations { } bootJar { - launchScript() manifest { attributes "Implementation-Title": "Halo Application", "Implementation-Version": archiveVersion