Merge branch 'main' of https://github.com/thor-op/w #4
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 wallpapers manifest | |
| on: | |
| push: | |
| branches: [main] | |
| paths: | |
| - "walls/**.jpg" | |
| - "walls/**.jpeg" | |
| - "walls/**.png" | |
| - "walls/**.webp" | |
| - "walls/**.gif" | |
| - "walls/**.bmp" | |
| permissions: | |
| contents: write | |
| jobs: | |
| generate: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@v4 | |
| with: | |
| fetch-depth: 0 # REQUIRED for git history sorting | |
| - name: Generate wallpapers.json | |
| run: | | |
| echo "Generating wallpapers manifest..." | |
| # Get all files from git history that were added to walls directory | |
| files=$(git log --name-only --pretty=format: --diff-filter=A | grep '^walls/.*\.(jpg\|jpeg\|png\|webp\|gif\|bmp)$' | sort -u | tac) | |
| # Count files | |
| if [ -n "$files" ]; then | |
| count=$(echo "$files" | wc -l) | |
| else | |
| count=0 | |
| files="" | |
| fi | |
| # Generate JSON | |
| if [ -n "$files" ]; then | |
| files_json=$(echo "$files" | jq -R . | jq -s .) | |
| else | |
| files_json="[]" | |
| fi | |
| jq -n \ | |
| --argjson count "$count" \ | |
| --arg updated "$(date -u +%Y-%m-%dT%H:%M:%SZ)" \ | |
| --argjson files "$files_json" \ | |
| '{count: $count, updated: $updated, files: $files}' \ | |
| > wallpapers.json | |
| echo "Generated wallpapers.json with $count files" | |
| - name: Commit and push manifest | |
| run: | | |
| git config user.name "github-actions" | |
| git config user.email "actions@github.com" | |
| git add wallpapers.json | |
| git commit -m "auto: update wallpapers manifest" || exit 0 | |
| git push |