-
Notifications
You must be signed in to change notification settings - Fork 600
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[DRAFT] Chore(Wren-ui): add github action script for CI (#72)
GitHub action to release image
- Loading branch information
1 parent
70c8141
commit 7e69acb
Showing
6 changed files
with
195 additions
and
2 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,55 @@ | ||
# create the github action to run the yarn lint when PR created or pushed to main branch | ||
# | ||
|
||
name: Wren-UI Lint | ||
|
||
on: | ||
push: | ||
paths: | ||
- 'wren-ui/**' | ||
pull_request: | ||
types: [ labeled ] | ||
|
||
permissions: | ||
contents: read | ||
|
||
concurrency: | ||
# avoid mis-canceling the ci runs while other labels are added to the PR, so we add the label name as the condition | ||
group: ${{ github.workflow }}-${{ github.event_name == 'pull_request' && github.event.label.name == 'ci/ui' && github.event.number || github.sha }} | ||
cancel-in-progress: true | ||
|
||
defaults: | ||
run: | ||
working-directory: wren-ui | ||
|
||
jobs: | ||
eslint: | ||
# run this job only if the PR is labeled with "ci/ui" | ||
if: ${{ github.event.label.name == 'ci/ui' || github.event_name == 'push'}} | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v3 | ||
- name: Set up Node.js | ||
uses: actions/setup-node@v2 | ||
with: | ||
node-version: '16' | ||
- name: Get yarn cache directory path | ||
id: yarn-cache-dir-path | ||
run: echo "::set-output name=dir::$(yarn cache dir)" | ||
- uses: actions/cache@v2 | ||
id: yarn-cache # use this to check for `cache-hit` (`steps.yarn-cache.outputs.cache-hit != 'true'`) | ||
with: | ||
path: | # should cache node_modules as well | ||
${{ steps.yarn-cache-dir-path.outputs.dir }} | ||
key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }} | ||
restore-keys: | | ||
${{ runner.os }}-yarn- | ||
- if: ${{ steps.yarn-cache.outputs.cache-hit != 'true' }} | ||
name: List the state of node modules | ||
continue-on-error: true | ||
run: yarn list | ||
- name: Install Node.js dependencies | ||
run: yarn install | ||
- name: Run lint | ||
run: yarn lint | ||
|
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,37 @@ | ||
name: Wren-UI Release stable image | ||
|
||
on: | ||
workflow_dispatch: | ||
inputs: | ||
version: | ||
description: Give a version for this release | ||
type: string | ||
required: true | ||
|
||
defaults: | ||
run: | ||
working-directory: wren-ui | ||
|
||
jobs: | ||
build-image: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v4 | ||
- name: Set up QEMU | ||
uses: docker/setup-qemu-action@v3 | ||
- name: Set up Docker Buildx | ||
uses: docker/setup-buildx-action@v3 | ||
- name: Login to GitHub Container Registry | ||
uses: docker/login-action@v3 | ||
with: | ||
registry: ghcr.io | ||
username: ${{ github.actor }} | ||
password: ${{ secrets.GITHUB_TOKEN }} | ||
- name: Build and push image | ||
run: | | ||
docker buildx build \ | ||
--platform linux/amd64,linux/arm64 \ | ||
--tag ghcr.io/canner/wren-ui:${{ github.event.inputs.version }} \ | ||
--tag ghcr.io/canner/wren-ui:latest \ | ||
--file ./Dockerfile \ | ||
--push . |
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,47 @@ | ||
name: Wren-UI Release image | ||
|
||
on: | ||
workflow_dispatch: | ||
inputs: | ||
docker_image_tag_name: | ||
description: Docker image tag name (optional, default branch name/tag name replaced with hyphens) | ||
type: string | ||
|
||
defaults: | ||
run: | ||
working-directory: wren-ui | ||
|
||
jobs: | ||
build-image: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v4 | ||
- name: Login to GitHub Container Registry | ||
uses: docker/login-action@v3 | ||
with: | ||
registry: ghcr.io | ||
username: ${{ github.actor }} | ||
password: ${{ secrets.GITHUB_TOKEN }} | ||
- name: Prepare tag name | ||
id: tag-preparation | ||
run: | | ||
if [ -n "${{ github.event.inputs.docker_image_tag_name }}" ]; then | ||
tag_name=${{ github.event.inputs.docker_image_tag_name }} | ||
else | ||
tag_name=$(echo ${{ github.ref_name }} | sed 's/[^a-zA-Z0-9]/-/g')-$(git log -1 --pretty=%h) | ||
fi | ||
echo "TAG_NAME=$tag_name" >> $GITHUB_OUTPUT | ||
- name: Set up QEMU | ||
uses: docker/setup-qemu-action@v3 | ||
- name: Set up Docker Buildx | ||
uses: docker/setup-buildx-action@v3 | ||
- name: Build and push image | ||
env: | ||
TAG_NAME: ${{ steps.tag-preparation.outputs.TAG_NAME }} | ||
run: | | ||
echo "Building image with tag:$TAG_NAME" | ||
docker buildx build \ | ||
--platform linux/amd64,linux/arm64 \ | ||
--tag ghcr.io/canner/wren-ui:$TAG_NAME \ | ||
--file ./Dockerfile \ | ||
--push . |
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,53 @@ | ||
# create the github action to run the UI tests when PR created | ||
|
||
name: Wren-UI Test | ||
|
||
on: | ||
push: | ||
paths: | ||
- 'wren-ui/**' | ||
pull_request: | ||
types: [ labeled ] | ||
|
||
permissions: | ||
contents: read | ||
|
||
concurrency: | ||
# avoid mis-canceling the ci runs while other labels are added to the PR, so we add the label name as the condition | ||
group: ${{ github.workflow }}-${{ github.event_name == 'pull_request' && github.event.label.name == 'ci/ui' && github.event.number || github.sha }} | ||
cancel-in-progress: true | ||
|
||
defaults: | ||
run: | ||
working-directory: wren-ui | ||
|
||
jobs: | ||
unit-test: | ||
# run this job only if the PR is labeled with "ci/ui" | ||
if: ${{ github.event.label.name == 'ci/ui' || github.event_name == 'push'}} | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v4 | ||
- name: Set up Node.js | ||
uses: actions/setup-node@v2 | ||
with: | ||
node-version: '16' | ||
- name: Get yarn cache directory path | ||
id: yarn-cache-dir-path | ||
run: echo "::set-output name=dir::$(yarn cache dir)" | ||
- uses: actions/cache@v2 | ||
id: yarn-cache # use this to check for `cache-hit` (`steps.yarn-cache.outputs.cache-hit != 'true'`) | ||
with: | ||
path: | # should cache node_modules as well | ||
${{ steps.yarn-cache-dir-path.outputs.dir }} | ||
key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }} | ||
restore-keys: | | ||
${{ runner.os }}-yarn- | ||
- if: ${{ steps.yarn-cache.cache-hit != 'true' }} | ||
name: List the state of node modules | ||
continue-on-error: true | ||
run: yarn list | ||
- name: Install dependencies | ||
run: yarn | ||
- name: Run tests | ||
run: yarn test |
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