Skip to content

Commit fa19482

Browse files
refactor: Simplify wiki workflow to use GitHub's wiki directly
1 parent b0815f5 commit fa19482

1 file changed

Lines changed: 26 additions & 19 deletions

File tree

.github/workflows/update-wiki.yml

Lines changed: 26 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -30,26 +30,33 @@ jobs:
3030
markdown-link-check "$file"
3131
done
3232
33-
- name: Initialize wiki repository
34-
run: |
35-
mkdir wiki
36-
cd wiki
37-
git init
38-
git config user.name "GitHub Actions"
39-
git config user.email "actions@github.com"
40-
cp -r ../docs/wiki/*.md .
41-
git add .
42-
git commit -m "Update wiki from docs"
43-
git branch -M main
44-
45-
- name: Push to wiki
46-
uses: ad-m/github-push-action@master
33+
- name: Update wiki
34+
uses: actions/github-script@v6
4735
with:
48-
github_token: ${{ secrets.GITHUB_TOKEN }}
49-
directory: wiki
50-
repository: ShockerAttack01/MinecraftCommandGenerator.wiki
51-
branch: main
52-
force: true
36+
script: |
37+
const fs = require('fs');
38+
const path = require('path');
39+
40+
// Get all markdown files from docs/wiki
41+
const wikiDir = path.join(process.env.GITHUB_WORKSPACE, 'docs/wiki');
42+
const files = fs.readdirSync(wikiDir)
43+
.filter(file => file.endsWith('.md'))
44+
.map(file => ({
45+
name: file,
46+
content: fs.readFileSync(path.join(wikiDir, file), 'utf8')
47+
}));
48+
49+
// Update each file in the wiki
50+
for (const file of files) {
51+
await github.rest.repos.createOrUpdateFileContents({
52+
owner: context.repo.owner,
53+
repo: context.repo.repo,
54+
path: `wiki/${file.name}`,
55+
message: `Update wiki: ${file.name}`,
56+
content: Buffer.from(file.content).toString('base64'),
57+
branch: 'wiki'
58+
});
59+
}
5360
5461
- name: Create wiki issue on failure
5562
if: failure()

0 commit comments

Comments
 (0)