forked from starship/starship
-
Notifications
You must be signed in to change notification settings - Fork 0
80 lines (71 loc) · 2.54 KB
/
format-workflow.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
77
78
79
80
name: Format + Docs Workflow
on:
push:
paths: ["docs/**", "**.md", "**.toml", "**.js", "**.json", "**.ts"]
pull_request:
paths: ["docs/**", "**.md", "**.toml", "**.js", "**.json", "**.ts"]
jobs:
# Run the dprint code formatter for documentation
dprint:
name: Dprint [Docs Formatter]
runs-on: ubuntu-latest
steps:
- name: Setup | Checkout
uses: actions/checkout@v4
- name: Docs | Format
uses: dprint/[email protected]
# Validate preset files
taplo:
name: Taplo [Preset schema validation]
runs-on: ubuntu-latest
steps:
- name: Setup | Checkout
uses: actions/checkout@v4
- name: Install | Taplo
run: cargo install --debug --locked --version 0.9.0 taplo-cli
- name: Presets | Validate with schema
run: taplo lint --schema "file://${GITHUB_WORKSPACE}/.github/config-schema.json" docs/public/presets/toml/*.toml
# If this is not a Crowdin PR, block changes to translated documentation
block-crowdin:
name: Block Translated Changes
runs-on: ubuntu-latest
if: ${{ github.event_name == 'pull_request' && github.event.pull_request.head.ref != 'i18n_master' }}
steps:
- name: Setup | Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Prevent File Change
uses: actions/github-script@v7
with:
script: |
const { execSync } = require('child_process');
const pattern = /^docs\/[a-z][a-z][a-z]?-[A-Z][A-Z]?\/.*$/;
const base = context.payload.pull_request.base.sha;
const head = context.payload.pull_request.head.sha;
const result = execSync(`git diff --name-only ${base} ${head}`).toString().split('\n');
for (const file of result) {
if (pattern.test(file)) {
core.setFailed(`To avoid conflicts, changes to the translated documentation are only allowed via Crowdin at https://translate.starship.rs.`);
break;
}
}
# Vitepress build
vitepress:
name: Vitepress [Build]
runs-on: ubuntu-latest
steps:
- name: Setup | Checkout
uses: actions/checkout@v4
- name: Setup | Node
uses: actions/setup-node@v4
with:
node-version: 20
cache: 'npm'
cache-dependency-path: docs/package-lock.json
- name: Setup | Install dependencies
run: npm install
working-directory: docs
- name: Build | Build docs site
run: npm run build
working-directory: docs