feat(ci): create doc PRs, maybe?
This commit is contained in:
committed by
Tobias Fried
parent
5a390a9231
commit
a4421c82b2
@@ -3,6 +3,10 @@ name: Build and deploy to preview
|
||||
on:
|
||||
push
|
||||
|
||||
concurrency:
|
||||
group: 'preview'
|
||||
cancel-in-progress: true
|
||||
|
||||
jobs:
|
||||
deploy:
|
||||
runs-on: ubuntu-latest
|
||||
@@ -13,6 +17,7 @@ jobs:
|
||||
- name: Install pnpm
|
||||
uses: pnpm/action-setup@v4
|
||||
with:
|
||||
version: 9
|
||||
run_install: false
|
||||
|
||||
- name: Install Node.js
|
||||
|
||||
5
.github/workflows/dreamhost-static.yaml
vendored
5
.github/workflows/dreamhost-static.yaml
vendored
@@ -5,6 +5,10 @@ on:
|
||||
branches:
|
||||
- master
|
||||
|
||||
concurrency:
|
||||
group: 'prod'
|
||||
cancel-in-progress: true
|
||||
|
||||
jobs:
|
||||
deploy:
|
||||
runs-on: ubuntu-latest
|
||||
@@ -15,6 +19,7 @@ jobs:
|
||||
- name: Install pnpm
|
||||
uses: pnpm/action-setup@v4
|
||||
with:
|
||||
version: 9
|
||||
run_install: false
|
||||
|
||||
- name: Install Node.js
|
||||
|
||||
88
.github/workflows/sync-docs.yaml
vendored
Normal file
88
.github/workflows/sync-docs.yaml
vendored
Normal file
@@ -0,0 +1,88 @@
|
||||
name: Sync README links section
|
||||
|
||||
on:
|
||||
push:
|
||||
paths:
|
||||
- 'README.md'
|
||||
# branches:
|
||||
# - main
|
||||
# - master
|
||||
workflow_dispatch: # Allows manual triggering
|
||||
|
||||
concurrency:
|
||||
group: 'docs'
|
||||
cancel-in-progress: true
|
||||
|
||||
env:
|
||||
# List of target repositories to sync to
|
||||
TARGET_REPOS: >-
|
||||
phosphor-icons/core
|
||||
phosphor-icons/figma
|
||||
phosphor-icons/flutter
|
||||
phosphor-icons/penpot
|
||||
phosphor-icons/phosphor-elm
|
||||
phosphor-icons/play
|
||||
phosphor-icons/react
|
||||
phosphor-icons/sketch
|
||||
phosphor-icons/swift
|
||||
phosphor-icons/theme
|
||||
phosphor-icons/unplugin
|
||||
phosphor-icons/vue
|
||||
phosphor-icons/web
|
||||
phosphor-icons/webcomponents
|
||||
|
||||
jobs:
|
||||
sync-docs:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v4
|
||||
|
||||
- name: Install pnpm
|
||||
uses: pnpm/action-setup@v4
|
||||
with:
|
||||
version: 9
|
||||
run_install: false
|
||||
|
||||
- name: Install Node.js
|
||||
uses: actions/setup-node@v4
|
||||
with:
|
||||
node-version: 20
|
||||
cache: 'pnpm'
|
||||
|
||||
- name: Sync to target repositories
|
||||
env:
|
||||
GH_TOKEN: ${{ github.token }}
|
||||
run: |
|
||||
echo "$TARGET_REPOS" | while read repo; do
|
||||
echo "Syncing to $repo"
|
||||
# Clone target repository
|
||||
gh repo clone $repo target-repo
|
||||
|
||||
# Run sync script
|
||||
pnpm run sync-docs -- "$repo"
|
||||
|
||||
# Create PR if there are changes
|
||||
cd target-repo
|
||||
if [[ -n "$(git status --porcelain)" ]]; then
|
||||
git config user.name "github-actions[bot]"
|
||||
git config user.email "github-actions[bot]@users.noreply.github.com"
|
||||
|
||||
# Create branch
|
||||
BRANCH="sync-readme-$(date +%Y%m%d-%H%M%S)"
|
||||
git checkout -b $BRANCH
|
||||
|
||||
# Commit and push changes
|
||||
git add README.md
|
||||
git commit -m "Sync README section from master repository"
|
||||
git push origin $BRANCH
|
||||
|
||||
# Create PR
|
||||
gh pr create \
|
||||
--title "Sync README section" \
|
||||
--body "Automated PR to sync README section from master repository" \
|
||||
--base main
|
||||
fi
|
||||
cd ..
|
||||
rm -rf target-repo
|
||||
done
|
||||
@@ -89,7 +89,8 @@ ReactDOM.render(<App />, document.getElementById("root"));
|
||||
> [!NOTE]
|
||||
> Due to possible namespace collisions with built-in HTML elements, compononent names in the Vue library are prefixed with `Ph`, but otherwise follow the same naming conventions. Both Pascal and kebab-case conventions can be used in templates.
|
||||
|
||||
## Our Related Projects
|
||||
<!-- BEGIN_LINKS -->
|
||||
## Our Projects
|
||||
|
||||
- [@phosphor-icons/homepage](https://github.com/phosphor-icons/homepage) ▲ Phosphor homepage and general info
|
||||
- [@phosphor-icons/core](https://github.com/phosphor-icons/core) ▲ Phosphor icon assets and catalog
|
||||
@@ -104,6 +105,7 @@ ReactDOM.render(<App />, document.getElementById("root"));
|
||||
- [@phosphor-icons/sketch](https://github.com/phosphor-icons/sketch) ▲ Phosphor icons Sketch plugin
|
||||
- [@phosphor-icons/pack](https://github.com/phosphor-icons/pack) ▲ Phosphor web font stripper to generate minimal icon bundles
|
||||
- [@phosphor-icons/theme](https://github.com/phosphor-icons/theme) ▲ A VS Code (and other IDE) theme with the Phosphor color palette
|
||||
- [@phosphor-icons/unplugin](https://github.com/phosphor-icons/theme) ▲ A framework-agnostic bundler plugin for generating Phosphor scripte sheets in web apps
|
||||
|
||||
## Community Projects
|
||||
|
||||
@@ -127,4 +129,4 @@ If you've made a port of Phosphor and you want to see it here, just open a PR [h
|
||||
## License
|
||||
|
||||
MIT © [Phosphor Icons](https://github.com/phosphor-icons)
|
||||
|
||||
<!-- END_LINKS -->
|
||||
|
||||
@@ -26,7 +26,8 @@
|
||||
"build": "tsc && vite build",
|
||||
"preview": "vite preview",
|
||||
"format": "prettier --write \"./src/**/*.{js,jsx,ts,tsx,json,vue}\"",
|
||||
"generate": "tsx scripts/generate.ts"
|
||||
"generate": "tsx scripts/generate.ts",
|
||||
"sync-docs": "tsx scripts/sync-docs.ts"
|
||||
},
|
||||
"dependencies": {
|
||||
"@phosphor-icons/core": "^2.1.1",
|
||||
|
||||
41
scripts/sync-docs.ts
Normal file
41
scripts/sync-docs.ts
Normal file
@@ -0,0 +1,41 @@
|
||||
import fs from "node:fs";
|
||||
import path from "node:path";
|
||||
|
||||
const SYNC_SECTIONS = ["LINKS"];
|
||||
|
||||
(function main() {
|
||||
const targetRepo = process.argv[process.argv.length - 1];
|
||||
if (!targetRepo) throw new Error("Target repository not provided");
|
||||
|
||||
const targetReadmePath = path.resolve(__dirname, `../../${targetRepo}/README.md`);
|
||||
if (!fs.existsSync(targetReadmePath)) throw new Error(`README.md not found in ${targetRepo}`);
|
||||
|
||||
const readmePath = path.resolve(__dirname, "../README.md");
|
||||
const readmeContent = fs.readFileSync(readmePath, "utf8");
|
||||
|
||||
for (const section of SYNC_SECTIONS) {
|
||||
const sectionContent = extractSection(readmeContent, section);
|
||||
if (!sectionContent) throw new Error(`Section ${section} not found in README.md`);
|
||||
|
||||
const targetReadmeContent = fs.readFileSync(targetReadmePath, "utf8");
|
||||
const updatedDocsContent = updateSection(targetReadmeContent, section, sectionContent);
|
||||
fs.writeFileSync(targetReadmePath, updatedDocsContent);
|
||||
}
|
||||
})();
|
||||
|
||||
function extractSection(content: string, section: string) {
|
||||
const pattern = new RegExp(
|
||||
`<!-- BEGIN_${section} -->\n([\\s\\S]*)\n<!-- END_${section} -->`,
|
||||
"g",
|
||||
);
|
||||
const match = pattern.exec(content);
|
||||
return match?.[1];
|
||||
}
|
||||
|
||||
function updateSection(content: string, section: string, newContent: string) {
|
||||
const pattern = new RegExp(
|
||||
`<!-- BEGIN_${section} -->\n([\\s\\S]*)\n<!-- END_${section} -->`,
|
||||
"g",
|
||||
);
|
||||
return content.replace(pattern, `<!-- BEGIN_${section} -->\n${newContent}\n<!-- END_${section} -->`);
|
||||
}
|
||||
Reference in New Issue
Block a user