workflow-automation
47
总安装量
48
周安装量
#4556
全站排名
安装命令
npx skills add https://github.com/supercent-io/skills-template --skill workflow-automation
Agent 安装分布
opencode
38
claude-code
33
codex
32
github-copilot
25
antigravity
22
Skill 文档
Workflow Automation
When to use this skill
- ë°ë³µ ìì : ë§¤ë² ê°ì ëª ë ¹ì´ ì¤í
- ë³µì¡í ë¹ë: ì¬ë¬ ë¨ê³ ë¹ë íë¡ì¸ì¤
- í ì¨ë³´ë©: ì¼ê´ë ê°ë° íê²½
Instructions
Step 1: npm scripts
package.json:
{
"scripts": {
"dev": "nodemon src/index.ts",
"build": "tsc && vite build",
"test": "jest --coverage",
"test:watch": "jest --watch",
"lint": "eslint src --ext .ts,.tsx",
"lint:fix": "eslint src --ext .ts,.tsx --fix",
"format": "prettier --write \"src/**/*.{ts,tsx,json}\"",
"type-check": "tsc --noEmit",
"pre-commit": "lint-staged",
"prepare": "husky install",
"clean": "rm -rf dist node_modules",
"reset": "npm run clean && npm install",
"docker:build": "docker build -t myapp .",
"docker:run": "docker run -p 3000:3000 myapp"
}
}
Step 2: Makefile
Makefile:
.PHONY: help install dev build test clean docker
.DEFAULT_GOAL := help
help: ## Show this help
@grep -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | sort | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-20s\033[0m %s\n", $$1, $$2}'
install: ## Install dependencies
npm install
dev: ## Start development server
npm run dev
build: ## Build for production
npm run build
test: ## Run all tests
npm test
lint: ## Run linter
npm run lint
lint-fix: ## Fix linting issues
npm run lint:fix
clean: ## Clean build artifacts
rm -rf dist coverage
docker-build: ## Build Docker image
docker build -t myapp:latest .
docker-run: ## Run Docker container
docker run -d -p 3000:3000 --name myapp myapp:latest
deploy: build ## Deploy to production
@echo "Deploying to production..."
./scripts/deploy.sh production
ci: lint test build ## Run CI pipeline locally
@echo "â
CI pipeline passed!"
ì¬ì©:
make help # Show all commands
make dev # Start development
make ci # Run full CI locally
Step 3: Husky + lint-staged (Git Hooks)
package.json:
{
"lint-staged": {
"*.{ts,tsx}": [
"eslint --fix",
"prettier --write"
],
"*.{json,md}": [
"prettier --write"
]
}
}
.husky/pre-commit:
#!/usr/bin/env sh
. "$(dirname -- "$0")/_/husky.sh"
echo "Running pre-commit checks..."
# Lint staged files
npx lint-staged
# Type check
npm run type-check
# Run tests related to changed files
npm test -- --onlyChanged
echo "â
Pre-commit checks passed!"
Step 4: Task Runner ì¤í¬ë¦½í¸
scripts/dev-setup.sh:
#!/bin/bash
set -e
echo "ð Setting up development environment..."
# Check prerequisites
if ! command -v node &> /dev/null; then
echo "â Node.js is not installed"
exit 1
fi
if ! command -v docker &> /dev/null; then
echo "â Docker is not installed"
exit 1
fi
# Install dependencies
echo "ð¦ Installing dependencies..."
npm install
# Copy environment file
if [ ! -f .env ]; then
echo "ð Creating .env file..."
cp .env.example .env
echo "â ï¸ Please update .env with your configuration"
fi
# Start Docker services
echo "ð³ Starting Docker services..."
docker-compose up -d
# Wait for database
echo "â³ Waiting for database..."
./scripts/wait-for-it.sh localhost:5432 --timeout=30
# Run migrations
echo "ðï¸ Running database migrations..."
npm run migrate
# Seed data (optional)
read -p "Seed database with sample data? (y/n) " -n 1 -r
echo
if [[ $REPLY =~ ^[Yy]$ ]]; then
npm run seed
fi
echo "â
Development environment ready!"
echo "Run 'make dev' to start the development server"
scripts/deploy.sh:
#!/bin/bash
set -e
ENV=$1
if [ -z "$ENV" ]; then
echo "Usage: ./deploy.sh [staging|production]"
exit 1
fi
echo "ð Deploying to $ENV..."
# Build
echo "ð¦ Building application..."
npm run build
# Run tests
echo "𧪠Running tests..."
npm test
# Deploy based on environment
if [ "$ENV" == "production" ]; then
echo "ð Deploying to production..."
# Production deployment logic
ssh production "cd /app && git pull && npm install && npm run build && pm2 restart all"
elif [ "$ENV" == "staging" ]; then
echo "𧪠Deploying to staging..."
# Staging deployment logic
ssh staging "cd /app && git pull && npm install && npm run build && pm2 restart all"
fi
echo "â
Deployment to $ENV completed!"
Step 5: GitHub Actions Workflow ìëí
.github/workflows/ci.yml:
name: CI
on:
push:
branches: [main, develop]
pull_request:
branches: [main]
jobs:
test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: '18'
cache: 'npm'
- name: Install dependencies
run: npm ci
- name: Run linter
run: npm run lint
- name: Type check
run: npm run type-check
- name: Run tests
run: npm test -- --coverage
- name: Upload coverage
uses: codecov/codecov-action@v3
Output format
project/
âââ scripts/
â âââ dev-setup.sh
â âââ deploy.sh
â âââ test.sh
â âââ cleanup.sh
âââ Makefile
âââ package.json
âââ .husky/
âââ pre-commit
âââ pre-push
Constraints
íì ê·ì¹ (MUST)
- 멱ë±ì±: ì¤í¬ë¦½í¸ ì¬ë¬ ë² ì¤íí´ë ìì
- ìë¬ ì²ë¦¬: ì¤í¨ ì ëª íí ë©ìì§
- 문ìí: ì¤í¬ë¦½í¸ ì¬ì©ë² 주ì
ê¸ì§ ì¬í (MUST NOT)
- íëì½ë©ë ë¹ë°: ì¤í¬ë¦½í¸ì ë¹ë°ë²í¸, API í¤ í¬í¨ ê¸ì§
- íê´´ì ëª ë ¹: íì¸ ìì´ rm -rf ì¤í ê¸ì§
Best practices
- Make ì¬ì©: íë«í¼ ë¬´ê´ ì¸í°íì´ì¤
- Git Hooks: ìë íì§ ê²ì¬
- CI/CD: GitHub Actionsë¡ ìëí
References
Metadata
ë²ì
- íì¬ ë²ì : 1.0.0
- ìµì¢ ì ë°ì´í¸: 2025-01-01
- í¸í íë«í¼: Claude, ChatGPT, Gemini
íê·¸
#automation #scripts #workflow #npm-scripts #Makefile #utilities