Mindmap screenshot with pageres-cli #435
Workflow file for this run
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: Generate Mindmap | |
| on: | |
| workflow_dispatch: | |
| push: | |
| branches: | |
| - "main" | |
| pull_request: | |
| paths: | |
| - ".github/workflows/generate-mindmap.yml" | |
| - "pattern-categorization/innersource-program-mind-map.md" | |
| - "pattern-categorization/package.json" | |
| - "pattern-categorization/gl/*" | |
| - "pattern-categorization/pt-br/*" | |
| - "pattern-categorization/es/*" | |
| defaults: | |
| run: | |
| working-directory: pattern-categorization | |
| jobs: | |
| generate-mindmap: | |
| runs-on: ubuntu-latest | |
| permissions: | |
| # Give the default GITHUB_TOKEN write permission to commit and push the changed files back to the repository. | |
| contents: write | |
| steps: | |
| - uses: actions/checkout@v5 | |
| with: | |
| repository: ${{ github.event.pull_request.head.repo.full_name }} | |
| ref: ${{ github.event.pull_request.head.ref }} | |
| - name: Use Node.js | |
| uses: actions/setup-node@v5 | |
| with: | |
| node-version: 20 | |
| cache: 'npm' | |
| cache-dependency-path: pattern-categorization/package-lock.json | |
| - name: Install Node.js dependencies | |
| run: npm install | |
| - name: Generate mindmap and take screenshot | |
| run: | | |
| # Disable AppArmor for unprivileged user namespaces (required for 'pageres') | |
| sudo sysctl -w kernel.apparmor_restrict_unprivileged_userns=0 | |
| # Loops over the top-level folder and all immediate sub-folders, except for "node_modules" | |
| for dir in . */; do | |
| # Skip node_modules | |
| [ "$(basename "$dir")" = "node_modules" ] && continue | |
| echo "Creating mindmap PNG for: $dir" | |
| ( | |
| # Create markmap HTML | |
| npx markmap --no-open --no-toolbar $dir/innersource-program-mind-map.md -o $dir/innersource-program-mind-map.html | |
| # Take the screenshot | |
| npx pageres $dir/innersource-program-mind-map.html --overwrite --filename=$dir/innersource-program-mind-map 2560x1600 | |
| # Reduce Screenshot Size (PNG) | |
| npx optipng $dir/innersource-program-mind-map.png | |
| ) | |
| done | |
| - name: Commit Changes | |
| uses: stefanzweifel/git-auto-commit-action@v6 | |
| with: | |
| commit_message: Re-creating markmap and screenshot |