Refactor GitHub Actions workflow for generating contribution snake by improving step organization and replacing the push action with a custom script

This commit is contained in:
Alvin
2025-09-16 10:13:35 +02:00
parent 09a37fd26f
commit f495e8d01a

View File

@@ -2,28 +2,32 @@ name: Generate Contribution Snake
on: on:
schedule: schedule:
- cron: "0 0 * * *" # Runs every day at midnight - cron: "0 0 * * *" # Runs daily at midnight
workflow_dispatch: # Allow manual runs workflow_dispatch:
jobs: jobs:
build: build:
runs-on: ubuntu-latest runs-on: ubuntu-latest
permissions:
contents: write # 👈 ensures this job can push
steps: steps:
# 1. Checkout repo
- name: Checkout repository - name: Checkout repository
uses: actions/checkout@v3 uses: actions/checkout@v3
# 2. Generate snake SVG
- name: Generate Snake - name: Generate Snake
uses: Platane/snk/svg-only@v3 uses: Platane/snk/svg-only@v3
with: with:
github_user_name: Alvin-Zilverstand github_user_name: Alvin-Zilverstand
outputs: dist/snake.svg outputs: dist/snake.svg
# 3. Push generated snake to output branch - name: Commit and push snake.svg to output branch
- name: Push Snake to output branch run: |
uses: EndBug/add-and-commit@v9 git config user.name "github-actions[bot]"
with: git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
add: "dist/snake.svg" git checkout --orphan output
new_branch: output git reset
message: "chore: update snake animation" mkdir -p dist
cp dist/snake.svg snake.svg
git add snake.svg
git commit -m "chore: update snake animation"
git push -f origin output