Expand BarcodeScanner scanning workflows (#860) #9
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: Sync Wiki | |
| on: | |
| push: | |
| branches: | |
| - main | |
| paths: | |
| - 'wiki/**' | |
| permissions: | |
| contents: write | |
| jobs: | |
| sync-wiki: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@v4 | |
| - name: Generate Sidebar | |
| run: | | |
| cd wiki | |
| { | |
| echo '<!-- This file is auto-generated from the wiki/ folder structure. Do not edit manually. -->' | |
| echo '' | |
| echo '**[Home](Home)**' | |
| # Root-level pages (except Home, _Sidebar, _Footer) | |
| for f in $(find . -maxdepth 1 -name '*.md' ! -name 'Home.md' ! -name '_Sidebar.md' ! -name '_Footer.md' -exec basename {} .md \; | sort -f); do | |
| display=$(echo "$f" | sed 's/-/ /g') | |
| echo "- [$display]($f)" | |
| done | |
| # Grouped pages from subdirectories | |
| find . -mindepth 1 -maxdepth 1 -type d | sed 's|^\./||' | sort -f | while IFS= read -r dir; do | |
| echo '' | |
| echo "**$dir**" | |
| echo '' | |
| for f in $(find "$dir" -maxdepth 1 -name '*.md' -exec basename {} .md \; | sort -f); do | |
| display=$(echo "$f" | sed 's/-/ /g') | |
| echo "- [$display]($f)" | |
| done | |
| done | |
| } > _Sidebar.md | |
| - name: Sync to Wiki | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| run: | | |
| # Configure git | |
| git config --global user.name "github-actions[bot]" | |
| git config --global user.email "github-actions[bot]@users.noreply.github.com" | |
| # Clone the wiki repository | |
| wiki_url="https://x-access-token:${GITHUB_TOKEN}@github.com/${{ github.repository }}.wiki.git" | |
| git clone "$wiki_url" /tmp/wiki-repo | |
| # Remove all existing wiki content (except .git) | |
| find /tmp/wiki-repo -maxdepth 1 -not -name '.git' -not -name '.' -delete 2>/dev/null || true | |
| # Copy the generated sidebar | |
| cp wiki/_Sidebar.md /tmp/wiki-repo/ | |
| # Flatten all .md files from wiki/ (including subdirectories) to wiki repo root | |
| find wiki -name '*.md' ! -name '_Sidebar.md' -exec cp {} /tmp/wiki-repo/ \; | |
| # Push changes if there are any | |
| cd /tmp/wiki-repo | |
| git add -A | |
| if git diff --cached --quiet; then | |
| echo "No changes to sync." | |
| else | |
| git commit -m "Sync wiki from main repository ($(date -u '+%Y-%m-%d %H:%M:%S UTC'))" | |
| git push | |
| echo "Wiki synced successfully." | |
| fi |