From e951132283845f4da106200f3969fa0a3af070f9 Mon Sep 17 00:00:00 2001 From: Simon Date: Thu, 26 Sep 2024 21:49:33 +0200 Subject: [PATCH] ci(workflows): added permission to write to pull requests --- .github/workflows/deploy.yml | 7 +------ .github/workflows/pull_request-opened.yml | 3 ++- .github/workflows/pull_request.yml | 20 +++++++++++++++----- .husky/commit-msg | 2 +- .husky/pre-commit | 4 ++-- package.json | 7 +++---- 6 files changed, 24 insertions(+), 19 deletions(-) diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index e26c6a6..e4c2eaf 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -18,18 +18,13 @@ jobs: version: latest run_install: true - - name: Lint code - run: | - pnpm run lint:eslint - - name: Build - run: pnpm run build + run: pnpm run tsc - name: Assets run: | cp package.json dist/package.json cp README.md dist/README.md - cp LICENSE dist/LICENSE - name: Config env: diff --git a/.github/workflows/pull_request-opened.yml b/.github/workflows/pull_request-opened.yml index e355021..edb6849 100644 --- a/.github/workflows/pull_request-opened.yml +++ b/.github/workflows/pull_request-opened.yml @@ -1,5 +1,4 @@ name: Pull request opened - on: pull_request: types: @@ -10,6 +9,8 @@ on: jobs: notify-greet: runs-on: ubuntu-latest + permissions: + pull-requests: write steps: - name: Auto assign uses: actions/github-script@v7 diff --git a/.github/workflows/pull_request.yml b/.github/workflows/pull_request.yml index 2ef76db..1625fa8 100644 --- a/.github/workflows/pull_request.yml +++ b/.github/workflows/pull_request.yml @@ -14,8 +14,15 @@ jobs: steps: - name: Checkout uses: actions/checkout@v4 + with: + fetch-depth: 0 + + - name: NodeJS install + uses: actions/setup-node@v4 + with: + node-version: "lts/*" - - name: Install + - name: pnpm install uses: pnpm/action-setup@v4 with: version: latest @@ -23,18 +30,19 @@ jobs: - name: Lint code run: | - pnpm run lint:tsc - pnpm run lint:eslint + pnpm run tsc --noEmit + pnpm run eslint . - name: Lint commits if: github.event_name == 'pull_request' run: | - commitlint --from ${{ github.event.pull_request.head.sha }}~${{ github.event.pull_request.commits }} --to ${{ github.event.pull_request.head.sha }} --verbose + pnpm run commitlint --from ${{ github.event.pull_request.base.sha }} --to ${{ github.event.pull_request.head.sha }} --verbose notify_success: runs-on: ubuntu-latest needs: style_check - + permissions: + pull-requests: write if: success() steps: - name: Comment success @@ -65,6 +73,8 @@ jobs: notify_failure: runs-on: ubuntu-latest needs: style_check + permissions: + pull-requests: write if: failure() steps: - name: Comment failure diff --git a/.husky/commit-msg b/.husky/commit-msg index 97f3064..3d136e4 100644 --- a/.husky/commit-msg +++ b/.husky/commit-msg @@ -1 +1 @@ -npm run lint:commit ${1} +npm run commitlint -- --edit $1 diff --git a/.husky/pre-commit b/.husky/pre-commit index 28e0edd..b7ad6e7 100644 --- a/.husky/pre-commit +++ b/.husky/pre-commit @@ -1,2 +1,2 @@ -npm run lint:tsc -npm run lint:eslint +npm run tsc -- --noEmit +npm run eslint -- . diff --git a/package.json b/package.json index 1af78b4..3c262e6 100644 --- a/package.json +++ b/package.json @@ -53,10 +53,9 @@ "esbuild": ">=0.20.0" }, "scripts": { - "lint:commit": "commitlint --edit", - "lint:eslint": "eslint .", - "lint:tsc": "tsc --noEmit", - "build": "tsc" + "commitlint": "commitlint", + "eslint": "eslint", + "tsc": "tsc" }, "devDependencies": { "@commitlint/cli": "^19.5.0",