File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ name : Platform descriptions
2+
3+ on :
4+ push :
5+ branches : [main]
6+ paths :
7+ - .vitepress/data/addons.ts
8+ - .vitepress/data/project.ts
9+ - parts/description.md
10+ - scripts/platform.ts
11+ - scripts/publish-modrinth.ts
12+ - .github/workflows/descriptions.yml
13+ workflow_dispatch :
14+
15+ permissions :
16+ contents : read
17+
18+ jobs :
19+ descriptions :
20+ runs-on : ubuntu-latest
21+ steps :
22+ - uses : actions/checkout@v4
23+
24+ - name : Setup Node
25+ uses : actions/setup-node@v4
26+ with :
27+ node-version : 22
28+ cache : npm
29+
30+ - name : Install dependencies
31+ run : npm ci
32+
33+ - name : Generate descriptions
34+ run : |
35+ npm run -s platform modrinth > modrinth.md
36+ npm run -s platform curseforge > curseforge.md
37+
38+ # curseforge has no write API, so its description is uploaded for manual pasting
39+ - name : Upload descriptions
40+ uses : actions/upload-artifact@v4
41+ with :
42+ name : descriptions
43+ path : |
44+ modrinth.md
45+ curseforge.md
46+
47+ - name : Update Modrinth
48+ env :
49+ MODRINTH_TOKEN : ${{ secrets.MODRINTH_TOKEN }}
50+ run : npm run -s publish:modrinth
Original file line number Diff line number Diff line change @@ -3,6 +3,9 @@ export interface NavLink {
33 url : string
44}
55
6+ // modrinth project slug, used to sync the description over the API
7+ export const modrinthProject = 'plasmo-voice'
8+
69// wide banner for platform descriptions; the docs site uses /logo512.png instead
710export const logo = 'https://imgur.com/3ccgCRz.png'
811
Original file line number Diff line number Diff line change 44 "docs:dev" : " vitepress dev" ,
55 "docs:build" : " vitepress build" ,
66 "docs:preview" : " vitepress preview" ,
7- "platform" : " node --disable-warning=ExperimentalWarning --experimental-strip-types scripts/platform.ts"
7+ "platform" : " node --disable-warning=ExperimentalWarning --experimental-strip-types scripts/platform.ts" ,
8+ "publish:modrinth" : " node --disable-warning=ExperimentalWarning --experimental-strip-types scripts/publish-modrinth.ts"
89 },
910 "devDependencies" : {
1011 "@types/node" : " ^26.1.1" ,
Original file line number Diff line number Diff line change 1+ import { modrinthProject } from '../.vitepress/data/project.ts'
2+ import { renderPage } from './platform.ts'
3+
4+ const API = 'https://api.modrinth.com/v2'
5+ const USER_AGENT = 'plasmoapp/pv-docs (description sync)'
6+
7+ const dryRun = process . argv . includes ( '--dry-run' )
8+
9+ const token = process . env . MODRINTH_TOKEN
10+ if ( ! token && ! dryRun ) {
11+ console . error ( 'MODRINTH_TOKEN is not set' )
12+ process . exit ( 1 )
13+ }
14+
15+ const body = renderPage ( 'modrinth' )
16+
17+ const current = await fetch ( `${ API } /project/${ modrinthProject } ` , {
18+ headers : { 'User-Agent' : USER_AGENT } ,
19+ } )
20+ if ( ! current . ok ) {
21+ console . error ( `failed to fetch project: ${ current . status } ${ await current . text ( ) } ` )
22+ process . exit ( 1 )
23+ }
24+
25+ if ( ( await current . json ( ) ) . body . trim ( ) === body . trim ( ) ) {
26+ console . log ( 'Modrinth description already up to date, nothing to do' )
27+ process . exit ( 0 )
28+ }
29+
30+ if ( dryRun ) {
31+ console . log ( 'Modrinth description differs, would update (dry run)' )
32+ process . exit ( 0 )
33+ }
34+
35+ const res = await fetch ( `${ API } /project/${ modrinthProject } ` , {
36+ method : 'PATCH' ,
37+ headers : {
38+ Authorization : token ! ,
39+ 'Content-Type' : 'application/json' ,
40+ 'User-Agent' : USER_AGENT ,
41+ } ,
42+ body : JSON . stringify ( { body } ) ,
43+ } )
44+
45+ if ( ! res . ok ) {
46+ console . error ( `failed to update project: ${ res . status } ${ await res . text ( ) } ` )
47+ process . exit ( 1 )
48+ }
49+
50+ console . log ( 'Modrinth description updated' )
You can’t perform that action at this time.
0 commit comments