#!/usr/bin/env bash set -euo pipefail # ci-lint-fix.sh — Run ESLint --fix and commit changes back to Gitea. # # Used by Woodpecker CI. If ESLint auto-fixes anything, commits with # [CI SKIP] to prevent an infinite pipeline loop. # # Requires GITEA_TOKEN secret in Woodpecker. # # Customize LINT_TARGETS and REPO_URL for your project. LINT_TARGETS="." GITEA_HOST="${GITEA_HOST:-git.spektr.design}" GITEA_ORG="${GITEA_ORG:-gitea}" REPO_NAME="${CI_REPO_NAME:-$(basename "$(git rev-parse --show-toplevel)")}" echo "--- Running ESLint --fix" # shellcheck disable=SC2086 npx eslint --fix ${LINT_TARGETS} || true if [ -z "$(git diff)" ]; then echo "--- No auto-fixable issues found" exit 0 fi echo "--- ESLint auto-fixed issues, committing back..." git config user.name "Woodpecker CI" git config user.email "ci@${GITEA_HOST}" REPO_URL="https://gitea:${GITEA_TOKEN}@${GITEA_HOST}/${GITEA_ORG}/${REPO_NAME}.git" git remote set-url origin "${REPO_URL}" git add -A git commit -m "fix: auto-fix eslint issues [CI SKIP]" git push origin HEAD:main echo "--- Auto-fix committed and pushed"