forked from Nexus-Mods/Vortex
-
Notifications
You must be signed in to change notification settings - Fork 0
81 lines (78 loc) · 2.76 KB
/
Copy pathformat.yml
File metadata and controls
81 lines (78 loc) · 2.76 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
74
75
76
77
78
79
80
81
name: Format
on:
pull_request:
branches: [master]
workflow_dispatch:
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
jobs:
format:
runs-on: ubuntu-latest
permissions:
issues: write
pull-requests: write
steps:
- uses: actions/checkout@v7
- name: Install volta, Node.js
uses: volta-cli/action@v5
- uses: pnpm/action-setup@v6
with:
cache: true
- name: Fix pnpm node-gyp permissions
run: find "$PNPM_HOME" -path '*/node-gyp/gyp/gyp_main.py' -exec chmod +x {} \;
# NOTE(erri120): fontconfig required by font-scanner required by theme-switcher
- name: Install fontconfig
run: sudo apt-get update && sudo apt-get install -y libfontconfig1-dev
- run: pnpm install
env:
VORTEX_ELECTRON_REBUILD: "skip"
- name: Check formatting
run: pnpm run format:check
- name: Comment on PR
if: failure() && github.event_name == 'pull_request'
uses: actions/github-script@v9
with:
script: |
const BOT_MARKER = '<!-- ci-format-check -->';
const { data: comments } = await github.rest.issues.listComments({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: context.issue.number,
});
const existing = comments.find(c => c.body.includes(BOT_MARKER));
const runUrl = `${context.serverUrl}/${context.repo.owner}/${context.repo.repo}/actions/runs/${context.runId}`;
const body = [
BOT_MARKER,
'## ❌ Code is not formatted',
'',
'To fix this:',
'',
'1. **Set up the pre-commit hook** (prevents future issues):',
' ```shell',
' pnpm run prepare',
' ```',
' This auto-formats staged files on every commit. (You will never see this error again)',
'',
'2. **Format all files manually**:',
' ```shell',
' pnpm run format',
' ```',
'',
`Then commit the formatting changes. [View logs](${runUrl})`,
].join('\n');
if (existing) {
await github.rest.issues.updateComment({
owner: context.repo.owner,
repo: context.repo.repo,
comment_id: existing.id,
body: body,
});
} else {
await github.rest.issues.createComment({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: context.issue.number,
body: body,
});
}