feat: add Woodpecker CI + Gitea deployment templates
- .woodpecker.yml: full pipeline template (install → lint-fix → lint → test → deploy) - scripts/setup-project.sh: one-command VPS setup (user, dir, deploy, sudoers, systemd, nginx) - scripts/deploy.sh: deploy script template (rsync + npm ci + systemctl + health check) - scripts/ci-lint-fix.sh: ESLint auto-fix with [CI SKIP] commit-back - docs/ci-cd.md: complete CI/CD documentation and troubleshooting - .env.example: added WOODPECKER_TOKEN - DOCS.md: added CI/CD section Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -1,6 +1,69 @@
|
||||
# Woodpecker CI pipeline template.
|
||||
#
|
||||
# Runs on the local backend — image: bash specifies the shell.
|
||||
# Triggers on push to main branch.
|
||||
#
|
||||
# Flow: install → lint-fix (optional) → lint + test → deploy
|
||||
#
|
||||
# Secrets (add in Woodpecker UI → repo or global settings):
|
||||
# gitea_token — Gitea access token (for lint-fix auto-commit back)
|
||||
#
|
||||
# Deploy setup (one-time, as root on VPS):
|
||||
# 1. Create deploy script:
|
||||
# cp scripts/deploy.sh /usr/local/bin/deploy-<project-name>
|
||||
# chmod 755 /usr/local/bin/deploy-<project-name>
|
||||
# chown root:root /usr/local/bin/deploy-<project-name>
|
||||
#
|
||||
# 2. Find Woodpecker agent user:
|
||||
# ps -o user= -p $(pgrep woodpecker-agent)
|
||||
#
|
||||
# 3. Set up sudoers (replace AGENT_USER and script name):
|
||||
# echo 'AGENT_USER ALL=(root) NOPASSWD: /usr/local/bin/deploy-<project-name> *' \
|
||||
# > /etc/sudoers.d/woodpecker-deploy
|
||||
# chmod 0440 /etc/sudoers.d/woodpecker-deploy
|
||||
# visudo -cf /etc/sudoers.d/woodpecker-deploy
|
||||
|
||||
when:
|
||||
- event: push
|
||||
branch: main
|
||||
|
||||
steps:
|
||||
- name: install
|
||||
image: bash
|
||||
commands:
|
||||
- npm ci
|
||||
|
||||
# Optional: auto-fix lint issues and commit back.
|
||||
# Requires gitea_token secret. Remove this step if not needed.
|
||||
# The [CI SKIP] in commit message prevents infinite loops.
|
||||
#
|
||||
# - name: lint-fix
|
||||
# image: bash
|
||||
# environment:
|
||||
# GITEA_TOKEN:
|
||||
# from_secret: gitea_token
|
||||
# commands:
|
||||
# - bash scripts/ci-lint-fix.sh
|
||||
# depends_on: [install]
|
||||
|
||||
- name: lint
|
||||
image: bash
|
||||
commands:
|
||||
- npx eslint .
|
||||
depends_on: [install]
|
||||
|
||||
- name: test
|
||||
image: bash
|
||||
commands:
|
||||
- echo "Hello from Woodpecker CI!"
|
||||
- echo "Build successful"
|
||||
- npm test
|
||||
depends_on: [install]
|
||||
|
||||
# Uncomment when deploy script is set up on VPS:
|
||||
#
|
||||
# - name: deploy
|
||||
# image: bash
|
||||
# environment:
|
||||
# CI: "true"
|
||||
# commands:
|
||||
# - sudo /usr/local/bin/deploy-<project-name> "${CI_WORKSPACE:-.}"
|
||||
# depends_on: [lint, test]
|
||||
|
||||
Reference in New Issue
Block a user