forked from halo-dev/halo
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Refactor workflow Signed-off-by: John Niang <johnniang@foxmail.com> * Support docker build Signed-off-by: John Niang <johnniang@foxmail.com> * Support building and pushing Docker image Signed-off-by: John Niang <johnniang@foxmail.com> --------- Signed-off-by: John Niang <johnniang@foxmail.com>
- Loading branch information
Showing
4 changed files
with
253 additions
and
64 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
name: "Docker build" | ||
description: "Builds 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@v2 | ||
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' }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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@v3 | ||
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters