Merge pull request #28 from leeoades/copilot/make-libraries-aot-and-t… #11
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Publish Wiki | |
| on: | |
| push: | |
| branches: [main] | |
| paths: | |
| - "docs/**" | |
| - "README.md" | |
| - "samples/**/README.md" | |
| workflow_dispatch: | |
| permissions: | |
| contents: write | |
| jobs: | |
| publish-wiki: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@v6 | |
| - name: Checkout wiki | |
| uses: actions/checkout@v6 | |
| with: | |
| repository: ${{ github.repository }}.wiki | |
| path: wiki | |
| - name: Sync docs to wiki | |
| run: | | |
| # Remove old wiki pages that came from docs (keep any manually created pages) | |
| # We track synced files so we can clean up removed docs | |
| cd wiki | |
| # Remove all .md files in wiki root that we manage | |
| # (files that exist in docs/ or were previously synced) | |
| find . -maxdepth 1 -name '*.md' ! -name '_*' -delete | |
| # Remove old samples directory if it exists (from previous wiki structure) | |
| rm -rf samples | |
| cd .. | |
| # Define reusable sed pattern for converting markdown links to wiki links | |
| WIKI_LINK_PATTERN='s/\(\[[^]]*\]\)\(([^)]*\)\.md)/\1\2)/g' | |
| # Copy main README.md as Home.md (the wiki home page) | |
| # Keep the H1 heading for Home.md and convert links: | |
| # 1. README.md -> Home | |
| # 2. docs/file.md -> file (remove docs/ prefix and .md extension) | |
| # 3. file.md -> file (remove .md extension) | |
| # 4. samples/Basic -> samples-Basic (wiki page names) | |
| # 5. samples/VendingMachine -> samples-VendingMachine (wiki page names) | |
| # 6. samples/StockPurchaser -> samples-StockPurchaser (wiki page names) | |
| sed 's|\(\[[^]]*\]\)(README\.md)|\1(Home)|g; s|docs/\([^)]*\)\.md|\1|g; '"$WIKI_LINK_PATTERN"'; s|(samples/Basic/FunctionalStateMachine.Samples)|(samples-Basic)|g; s|(samples/Basic)|(samples-Basic)|g; s|(samples/VendingMachine/VendingMachineSampleApp)|(samples-VendingMachine)|g; s|(samples/VendingMachine)|(samples-VendingMachine)|g; s|(samples/StockPurchaser/StockPurchaserSampleApp)|(samples-StockPurchaser)|g; s|(samples/StockPurchaser)|(samples-StockPurchaser)|g' README.md > wiki/Home.md | |
| # Copy docs to wiki | |
| for file in docs/*.md; do | |
| filename=$(basename "$file") | |
| # Skip index.md since README.md is now Home.md | |
| if [ "$filename" = "index.md" ]; then | |
| continue | |
| fi | |
| target="wiki/$filename" | |
| # Copy file, strip first H1 heading, and convert relative .md links to wiki links | |
| # Remove first line if it starts with "# " (H1 heading) | |
| sed '1{/^# /d;}; s/\(\[[^]]*\]\)(index\.md)/\1(Home)/g; '"$WIKI_LINK_PATTERN" "$file" > "$target" | |
| done | |
| # Copy sample READMEs to wiki root with unique names | |
| # GitHub wikis don't support subdirectories, so we use flat naming | |
| # Strip H1 headings from sample READMEs too | |
| # Basic samples | |
| if [ -f "samples/Basic/README.md" ]; then | |
| sed '1{/^# /d;}; '"$WIKI_LINK_PATTERN" samples/Basic/README.md > wiki/samples-Basic.md | |
| fi | |
| # VendingMachine sample | |
| if [ -f "samples/VendingMachine/VendingMachineSampleApp/README.md" ]; then | |
| sed '1{/^# /d;}; '"$WIKI_LINK_PATTERN" samples/VendingMachine/VendingMachineSampleApp/README.md > wiki/samples-VendingMachine.md | |
| fi | |
| # StockPurchaser sample | |
| if [ -f "samples/StockPurchaser/StockPurchaserSampleApp/README.md" ]; then | |
| sed '1{/^# /d;}; '"$WIKI_LINK_PATTERN" samples/StockPurchaser/StockPurchaserSampleApp/README.md > wiki/samples-StockPurchaser.md | |
| fi | |
| - name: Push to wiki | |
| run: | | |
| cd wiki | |
| git config user.name "github-actions[bot]" | |
| git config user.email "github-actions[bot]@users.noreply.github.com" | |
| git add -A | |
| if git diff --cached --quiet; then | |
| echo "No wiki changes to commit." | |
| else | |
| git commit -m "Sync docs to wiki from ${{ github.sha }}" | |
| git push | |
| fi |