fix: new chapter logo + change logo colors to follow the IT color scheme #22
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 PNGs | |
| on: | |
| pull_request: | |
| branches: | |
| - master | |
| paths: | |
| - "**.svg" | |
| jobs: | |
| convert-svg-to-png: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout Repository | |
| uses: actions/checkout@v3 | |
| - name: Install Inkscape | |
| run: | | |
| sudo apt install inkscape | |
| - name: Install Pngquant | |
| run: | | |
| sudo apt install pngquant | |
| - name: Convert SVGs to PNGs | |
| run: | | |
| git fetch origin master | |
| # Get list of changed SVG files with proper handling, replace NUL with newline | |
| changed_files=$(git diff --name-only origin/master -z -- "*.svg" | tr '\0' '\n') | |
| # If no files are different, exit early | |
| if [ -z "$changed_files" ]; then | |
| echo "No SVG files different from origin/master" | |
| exit 0 | |
| fi | |
| total_files=$(echo "$changed_files" | wc -l) | |
| progress=0 | |
| # Process each changed file directly | |
| echo "$changed_files" | while IFS= read -r relative_path; do | |
| # Decode any incorrectly encoded filenames | |
| relative_path=$(printf '%b' "$relative_path") | |
| file="./$relative_path" | |
| progress=$((progress + 1)) | |
| percentage=$((progress * 100 / total_files)) | |
| filled=$((percentage / 2)) | |
| unfilled=$((50 - filled)) | |
| printf "\rProgress: [%${filled}s%${unfilled}s] %d%%" "$(printf '#%.0s' $(seq 1 $filled))" "$(printf ' %.0s' $(seq 1 $unfilled))" "$percentage" | |
| # Ensure filename safety (replace spaces safely) | |
| png_file="${file%.svg} 4k" | |
| # Use Inkscape with properly decoded filenames | |
| inkscape "$file" --export-background-opacity=0 -h 4000 -o "$png_file.temp.png" | |
| # Ensure pngquant correctly processes the file | |
| pngquant -f --quality 100 --output "$png_file.png" -- "$png_file.temp.png" | |
| # Remove temporary PNG file | |
| rm "$png_file.temp.png" | |
| done | |
| echo | |
| - name: Commit and Push Converted PNGs | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| run: | | |
| git config --global user.name "github-actions[bot]" | |
| git config --global user.email "github-actions[bot]@users.noreply.github.com" | |
| git fetch origin "${GITHUB_HEAD_REF}" | |
| git checkout "${GITHUB_HEAD_REF}" | |
| git add . | |
| git commit -m "Generate PNGs" | |
| git push origin "${GITHUB_HEAD_REF}" |