-
Notifications
You must be signed in to change notification settings - Fork 59
73 lines (71 loc) · 2.61 KB
/
lint.yml
File metadata and controls
73 lines (71 loc) · 2.61 KB
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
name: Lint with auto fix
on:
# Trigger the workflow on push or pull request,
# but only for the main branch
push:
branches:
- main
pull_request:
branches:
- main
jobs:
run-linters:
# Skip this job on forks since it requires secrets and push permissions
if: github.event.pull_request.head.repo.full_name == github.repository
strategy:
matrix:
os: [ubuntu-latest]
node-version: [20.x]
runs-on: ${{ matrix.os }}
steps:
- name: Checkout code repository
uses: actions/checkout@v6
with:
repository: ${{ github.event.pull_request.head.repo.full_name }}
ref: ${{ github.event.pull_request.head.ref }}
token: ${{ secrets.ACCESS_PAT }}
- name: Setup pnpm
uses: pnpm/action-setup@v4
with:
run_install: |
- args: [--ignore-scripts]
- name: Cache pnpm modules
uses: actions/cache@v4
env:
cache-name: cache-pnpm-modules
with:
path: ~/.pnpm-store
key: ${{ matrix.os }}-build-${{ env.cache-name }}-${{ matrix.node-version }}-${{ hashFiles('**/pnpm-lock.yaml') }}
restore-keys: |
${{ matrix.os }}-build-${{ env.cache-name }}-${{ matrix.node-version }}-
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v6
with:
node-version: ${{ matrix.node-version }}
- name: Install pnpm modules
run: pnpm install --frozen-lockfile
- name: Run build
run: pnpm run build
env:
NX_CLOUD_ACCESS_TOKEN: ${{ secrets.NX_CLOUD_ACCESS_TOKEN }}
- name: Run lint:fix
run: pnpm run lint:fix
env:
NX_CLOUD_ACCESS_TOKEN: ${{ secrets.NX_CLOUD_ACCESS_TOKEN }}
- name: Commit lint fixes if any
run: |
git config --global user.name github-actions[bot]
git config --global user.email github-actions[bot]@users.noreply.github.com
git add pnpm-lock.yaml
if git commit -m "Linting auto fix commit" -a --no-verify; then
CHANGED_FILES=$(git diff-tree --no-commit-id --name-only -r HEAD)
if ! git push; then
echo "::error::Failed to push lint fixes to remote repository. The commit was created locally but could not be pushed."
echo "::error::Files that could not be committed: $CHANGED_FILES"
echo "Fix the eslint issues locally and push the changes."
exit 1
fi
echo "Lint fixes committed and pushed successfully"
else
echo "No lint fixes needed"
fi