Generate snake animation #44
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 snake animation | |
| on: | |
| schedule: # execute @daily midnight UTC | |
| - cron: "0 0 * * */3" | |
| workflow_dispatch: | |
| push: | |
| branches: | |
| - main | |
| jobs: | |
| generate: | |
| permissions: | |
| contents: write | |
| runs-on: ubuntu-latest | |
| timeout-minutes: 5 | |
| steps: | |
| - name: Ensure dist exists | |
| run: | | |
| mkdir -p dist | |
| - name: generate snake.svg | |
| uses: Platane/snk/svg-only@v3 | |
| with: | |
| github_user_name: ${{ github.repository_owner }} | |
| outputs: dist/snake.svg?palette=github-dark | |
| # Step 3: Generate the OSS badge inside 'dist' | |
| - name: generate OSS stats badge # https://github.com/mabd-dev/gh-oss-stats-action#inputs | |
| uses: mabd-dev/gh-oss-stats-action@v0.2.1 | |
| with: | |
| commit-badge: false | |
| github-token: ${{ secrets.GITHUB_TOKEN }} | |
| badge-output-path: 'dist/oss-badge.svg' | |
| badge-style: 'detailed' | |
| badge-theme: 'nord' | |
| badge-limit: '10' | |
| # badge-variant: 'text-based' | |
| # min-stars: '100' | |
| # exclude-orgs: 'calculatorbit,thetechbasket' | |
| - name: Fetch file | |
| run: | | |
| set -e | |
| fetch() { | |
| url="$1" | |
| output="$2" | |
| tmp="${output}.tmp" | |
| echo "Fetching: $url" | |
| if curl -fsSL --max-time 15 "$url" -o "$tmp"; then | |
| mv "$tmp" "$output" | |
| echo "Saved: $output" | |
| else | |
| echo "Skipped: $output (request failed)" | |
| rm -f "$tmp" | |
| fi | |
| } | |
| fetch "https://profile-counter.glitch.me/amitind/count.svg" "dist/count.svg" | |
| fetch "https://streak-stats.demolab.com?user=amitind&locale=en&mode=daily&theme=tokyonight&hide_border=true&border_radius=20" "dist/streak-stats.svg" | |
| - name: Verify files | |
| run: ls -la dist | |
| - name: push to the output branch | |
| uses: crazy-max/ghaction-github-pages@v3.1.0 | |
| with: | |
| target_branch: output | |
| build_dir: dist | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |