-
Notifications
You must be signed in to change notification settings - Fork 1.4k
76 lines (73 loc) · 2.42 KB
/
lint.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
name: Lint
on:
push:
branches:
- main
paths:
- ".github/workflows/lint.yml"
- "docs/**"
- "packages/**"
pull_request:
paths:
- ".github/workflows/lint.yml"
- "docs/**"
- "packages/**"
workflow_dispatch:
concurrency:
group: ${{github.workflow}}-${{github.ref}}
cancel-in-progress: true
jobs:
lint:
name: Lint
runs-on: ubuntu-latest
permissions:
contents: read
steps:
# NOTE: When running on a pull_request_target, we're checking out the repo
# twice. The first checkout is for the base branch of the PR. The second,
# for the merge commit. We do this to be able to use the `setup-env`
# action that's on the base branch.
- uses: actions/checkout@v4
with:
persist-credentials: false
- uses: actions/checkout@v4
if: github.event_name == 'pull_request_target'
with:
ref: "refs/pull/${{ github.event.number }}/merge"
persist-credentials: false
- if: github.event_name == 'pull_request_target'
name: Check out setup-env action from the base branch
run: git checkout --no-overlay $GITHUB_SHA -- .github/actions/setup-env
- uses: ./.github/actions/setup-env
- name: Install
run: pnpm install --frozen-lockfile --prefer-offline
- name: Build
run: pnpm build
- name: lint
run: pnpm lint
- name: Check dependency versions
run: node scripts/check-dependencies.js
- name: Install website
working-directory: docs/
run: pnpm install --frozen-lockfile --prefer-offline
- name: Lint website
working-directory: docs/
run: pnpm lint
comment:
needs: [lint]
if: failure() && github.event_name == 'pull_request_target' && needs.lint.result == 'failure'
name: Comment
runs-on: ubuntu-latest
permissions:
pull-requests: write
steps:
- uses: actions/github-script@v7
name: Comment on failure
with:
script: |
github.rest.issues.createComment({
issue_number: context.issue.number,
owner: context.repo.owner,
repo: context.repo.repo,
body: "Thanks for submitting this PR!\n\nUnfortunately, it has some linter errors, so we can't merge it yet. Can you please fix them?\n\nRunning pnpm lint:fix in the root of the repository may fix them automatically."
})