chore: maintain docs about yubikey situation #2
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: Convert images to AVIF | |
| on: | |
| push: | |
| branches-ignore: | |
| - main | |
| paths: | |
| - "static/images/**" | |
| permissions: | |
| contents: write | |
| jobs: | |
| convert: | |
| name: PNG/JPG to AVIF | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v6 | |
| - name: Install avifenc | |
| run: sudo apt-get update -y && sudo apt-get install -y libavif-apps | |
| - name: Convert and update references | |
| id: convert | |
| run: | | |
| changed=false | |
| sed_script="$(mktemp)" | |
| while IFS= read -r -d '' f; do | |
| [ -f "$f" ] || continue | |
| dir="$(dirname "$f")" | |
| name="$(basename "${f%.*}")" | |
| outfile="${dir}/${name}.avif" | |
| if avifenc -q 80 -s 6 "$f" "$outfile"; then | |
| rm "$f" | |
| # Build static-relative paths for markdown reference replacement | |
| rel_src="${f#static}" | |
| rel_dst="${outfile#static}" | |
| # Escape regex metacharacters (. [ \ * ^ $) in the source path | |
| esc_src="$(printf '%s\n' "$rel_src" | sed 's/[.[\*^$]/\\&/g')" | |
| # Accumulate substitutions; apply in one pass after the loop | |
| printf 's|%s|%s|gI\n' "$esc_src" "$rel_dst" >> "$sed_script" | |
| changed=true | |
| echo "Converted: $f" | |
| else | |
| echo "Failed to convert: $f, skipping." >&2 | |
| fi | |
| done < <(find static/images -type f \( -iname "*.png" -o -iname "*.jpg" -o -iname "*.jpeg" \) -print0) | |
| # Single pass over all markdown files with all substitutions at once | |
| if [ "$changed" = "true" ]; then | |
| find content -name "*.md" -exec sed -i -f "$sed_script" {} + | |
| fi | |
| rm -f "$sed_script" | |
| echo "changed=$changed" >> "$GITHUB_OUTPUT" | |
| - name: Commit converted images | |
| if: steps.convert.outputs.changed == 'true' | |
| run: | | |
| git config user.name "github-actions[bot]" | |
| git config user.email "github-actions[bot]@users.noreply.github.com" | |
| git add static/images/ content/ | |
| git commit -m "chore: auto-convert images to AVIF" | |
| git push |