From f495e8d01ac0b537d6bce9672779c3a878704094 Mon Sep 17 00:00:00 2001 From: Alvin <524715@vistacollege.nl> Date: Tue, 16 Sep 2025 10:13:35 +0200 Subject: [PATCH] Refactor GitHub Actions workflow for generating contribution snake by improving step organization and replacing the push action with a custom script --- .github/workflows/snake.yml | 26 +++++++++++++++----------- 1 file changed, 15 insertions(+), 11 deletions(-) diff --git a/.github/workflows/snake.yml b/.github/workflows/snake.yml index dbf244f..daeeeed 100644 --- a/.github/workflows/snake.yml +++ b/.github/workflows/snake.yml @@ -2,28 +2,32 @@ name: Generate Contribution Snake on: schedule: - - cron: "0 0 * * *" # Runs every day at midnight - workflow_dispatch: # Allow manual runs + - cron: "0 0 * * *" # Runs daily at midnight + workflow_dispatch: jobs: build: runs-on: ubuntu-latest + permissions: + contents: write # 👈 ensures this job can push steps: - # 1. Checkout repo - name: Checkout repository uses: actions/checkout@v3 - # 2. Generate snake SVG - name: Generate Snake uses: Platane/snk/svg-only@v3 with: github_user_name: Alvin-Zilverstand outputs: dist/snake.svg - # 3. Push generated snake to output branch - - name: Push Snake to output branch - uses: EndBug/add-and-commit@v9 - with: - add: "dist/snake.svg" - new_branch: output - message: "chore: update snake animation" + - name: Commit and push snake.svg to output branch + run: | + git config user.name "github-actions[bot]" + git config user.email "41898282+github-actions[bot]@users.noreply.github.com" + git checkout --orphan output + git reset + 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