Skip to content

Commit

Permalink
feat: github actions & lints
Browse files Browse the repository at this point in the history
  • Loading branch information
greenhat616 committed Aug 26, 2023
1 parent 407c1aa commit 96f8d50
Show file tree
Hide file tree
Showing 7 changed files with 711 additions and 55 deletions.
37 changes: 37 additions & 0 deletions .github/workflows/dockerhub_latest.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
name: Deploy To Dockerhub(Latest)

on:
push:
branches: [ master ]

jobs:
latest:
runs-on: ubuntu-latest
steps:
-
name: Set up QEMU
uses: docker/setup-qemu-action@v2
-
name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
-
name: Login to Docker Hub
uses: docker/login-action@v2
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Create .env file
uses: SpicyPizza/[email protected]
with:
file_name: .env.production
envkey_HITOKOTO_COMMON_API_ENDPOINT: ${{ secrets.HITOKOTO_COMMON_API_ENDPOINT }}
envkey_HITOKOTO_REVIEWER_API_ENDPOINT: ${{ secrets.HITOKOTO_REVIEWER_API_ENDPOINT }}
envkey_HITOKOTO_SEARCH_API_ENDPOINT: ${{ secrets.HITOKOTO_SEARCH_API_ENDPOINT }}
envkey_HITOKOTO_SEARCH_API_PUBKEY: ${{ secrets.HITOKOTO_SEARCH_API_PUBKEY }}
-
name: Build and push
uses: docker/build-push-action@v4
with:
push: true
tags: hitokoto/reviewer-frontend:latest
file: ./Dockerfile
82 changes: 82 additions & 0 deletions .github/workflows/node.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
name: Node.js CI

on:
pull_request:
branches: [ next ]
push:
branches: [ next ]
jobs:
test:
name: Lint
runs-on: ubuntu-latest
strategy:
matrix:
node-version: [20.x]
steps:
- uses: actions/checkout@v3
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v3
with:
node-version: ${{ matrix.node-version }}
- uses: pnpm/action-setup@v2
with:
version: 8
- name: Get pnpm store directory
shell: bash
run: |
echo "STORE_PATH=$(pnpm store path --silent)" >> $GITHUB_ENV
- uses: actions/cache@v3
name: Setup pnpm cache
with:
path: ${{ env.STORE_PATH }}
key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }}
restore-keys: |
${{ runner.os }}-pnpm-store-
- name: Install dependencies
run: pnpm install

- name: Lint
run: pnpm lint

build:
name: Build
runs-on: ubuntu-latest
strategy:
matrix:
node-version: [20.x]
steps:
- uses: actions/checkout@v3
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v3
with:
node-version: ${{ matrix.node-version }}
- uses: pnpm/action-setup@v2
with:
version: 8
- name: Get pnpm store directory
shell: bash
run: |
echo "STORE_PATH=$(pnpm store path --silent)" >> $GITHUB_ENV
- uses: actions/cache@v3
name: Setup pnpm cache
with:
path: ${{ env.STORE_PATH }}
key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }}
restore-keys: |
${{ runner.os }}-pnpm-store-
- name: Install dependencies
run: pnpm install
- name: Create .env file
uses: SpicyPizza/[email protected]
with:
file_name: .env.production
envkey_HITOKOTO_COMMON_API_ENDPOINT: ${{ secrets.HITOKOTO_COMMON_API_ENDPOINT }}
envkey_HITOKOTO_REVIEWER_API_ENDPOINT: ${{ secrets.HITOKOTO_REVIEWER_API_ENDPOINT }}
envkey_HITOKOTO_SEARCH_API_ENDPOINT: ${{ secrets.HITOKOTO_SEARCH_API_ENDPOINT }}
envkey_HITOKOTO_SEARCH_API_PUBKEY: ${{ secrets.HITOKOTO_SEARCH_API_PUBKEY }}
- name: Build
run: pnpm build
4 changes: 4 additions & 0 deletions .husky/commit-msg
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#!/usr/bin/env sh
. "$(dirname -- "$0")/_/husky.sh"

pnpm commitlint --edit $1
4 changes: 4 additions & 0 deletions .husky/pre-commit
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#!/usr/bin/env sh
. "$(dirname -- "$0")/_/husky.sh"

pnpm lint-staged
2 changes: 1 addition & 1 deletion lint-staged.config.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
module.exports = {
'**.{ts,tsx,js,vue}': ['eslint -c .eslintrc.js'],
'*.scss': ['stylelint --config .stylelintrc.json']
'*.scss,*.vue': ['stylelint --config .stylelintrc.json']
}
5 changes: 5 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,16 @@
"generate": "nuxt generate",
"preview": "nuxt preview",
"prepare": "husky install",
"lint:js": "eslint --ext \".js,.ts,.tsx,.jsx,.vue\" --ignore-path .gitignore .",
"lint:style": "stylelint \"**/*.{vue,htm,html,css,sss,less,scss,sass}\" --config .stylelintrc.js --ignore-path .gitignore",
"lint": "pnpm lint:js && pnpm lint:style",
"postinstall": "nuxt prepare && sh -c 'if [ command -v ./node_modules/.bin/husky ]; then ./node_modules/.bin/husky install; fi;'"
},
"devDependencies": {
"@ant-design-vue/nuxt": "^1.1.1",
"@ant-design/icons-vue": "^6.1.0",
"@commitlint/cli": "^17.7.1",
"@commitlint/config-conventional": "^17.7.0",
"@iconify/json": "^2.2.106",
"@nuxt/devtools": "latest",
"@nuxtjs/eslint-module": "^4.1.0",
Expand Down
Loading

0 comments on commit 96f8d50

Please sign in to comment.