From d28f6afe4cbb0a1982deb4b494c46e92c8cac1a0 Mon Sep 17 00:00:00 2001 From: hubert Date: Thu, 25 Jul 2024 10:24:18 +0800 Subject: [PATCH] chore: github actions --- .github/workflows/check-pr-title.yml | 22 ++++++++++ .github/workflows/commitlint.yml | 26 ++++++++++++ .github/workflows/deploy.yml | 60 ++++++++++++++++++++++++++++ 3 files changed, 108 insertions(+) create mode 100644 .github/workflows/check-pr-title.yml create mode 100644 .github/workflows/commitlint.yml create mode 100644 .github/workflows/deploy.yml diff --git a/.github/workflows/check-pr-title.yml b/.github/workflows/check-pr-title.yml new file mode 100644 index 0000000..839c8c0 --- /dev/null +++ b/.github/workflows/check-pr-title.yml @@ -0,0 +1,22 @@ +name: Check PR title +on: + pull_request_target: + types: + - opened + - reopened + - edited + - synchronize + + +permissions: + statuses: write + +jobs: + lint: + runs-on: ubuntu-latest + steps: + - uses: aslafy-z/conventional-pr-title-action@v3 + with: + preset: "@commitlint/config-conventional@^12.1.4" + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/.github/workflows/commitlint.yml b/.github/workflows/commitlint.yml new file mode 100644 index 0000000..1c8481b --- /dev/null +++ b/.github/workflows/commitlint.yml @@ -0,0 +1,26 @@ +name: Check Commit spec + +on: + push: + branches: [master] + pull_request: + branches: [master] + + # Allows you to run this workflow manually from the Actions tab + workflow_dispatch: + + +permissions: + contents: read + pull-requests: read + +jobs: + commitlint: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + with: + fetch-depth: 0= + - uses: wagoid/commitlint-github-action@v3 + env: + NODE_PATH: ${{ github.workspace }}/node_modules diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml new file mode 100644 index 0000000..44a13c7 --- /dev/null +++ b/.github/workflows/deploy.yml @@ -0,0 +1,60 @@ +name: Deploy + +on: + # release: + # types: [published] + push: # push 到主分支自动 发布 + branches: ['master'] + paths-ignore: # 忽略一些不必要的文件 + - '.gitignore' + - 'README.md' + - '.vscode/**' + - '.devcontainer/**' + +permissions: + contents: write + +jobs: + publish: + runs-on: ubuntu-latest + environment: + name: 'production' + steps: + - name: Checkout repository + uses: actions/checkout@v3 + with: + fetch-depth: 0 + - name: Set up Node.js + uses: actions/setup-node@v4 + with: + node-version: '16.14' + - name: Cache Dependencies + uses: actions/cache@v3 + id: cache + with: + path: | + node_modules + .yarn/cache + key: ${{ runner.os }}-node-${{ hashFiles('yarn.lock') }} + restore-keys: | + ${{ runner.os }}-node- + - name: Install Dependencies + if: steps.cache.outputs.cache-hit != 'true' + run: yarn install --mode=skip-build + - name: Configure Git User + run: | + git config --global user.email "${{ github.actor }}@users.noreply.github.com" + git config --global user.name "${{github.actor}}" + git config --list + - name: Authenticate with Registry + run: | + echo "registry=https://registry.npmjs.org/" >> .npmrc + echo "//registry.npmjs.org/:_authToken=$NPM_TOKEN" >> .npmrc + npm whoami + env: + NPM_TOKEN: ${{ secrets.NPM_TOKEN }} + - name: Publish + run: | + npx lerna publish --yes + env: + GITHUB_AUTH: ${{ secrets.GITHUB_TOKEN }}