用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
直接命令不会经过审查 Prompt;运行前请先检查来源。
npx skills add https://github.com/ffsshhttiikk/opencode-agents-skills --skill ci-cd命令会保持在同一行。复制前请横向滚动并检查完整内容。
想先保存到本地?可下载 SkillsMP 当前能够提供的文件。
正在显示 SKILL.md
| name | ci-cd |
| description | CI/CD pipeline best practices and implementation |
| license | MIT |
| compatibility | opencode |
| metadata | {"audience":"developers","category":"devops"} |
When creating or optimizing CI/CD workflows.
name: CI/CD Pipeline
on:
push:
branches: [main, develop]
pull_request:
branches: [main]
workflow_dispatch:
env:
REGISTRY: ghcr.io
IMAGE_NAME: ${{ github.repository }}
jobs:
lint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: '3.11'
cache: 'pip'
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install -r requirements.txt
pip install black isort mypy
- name: Check formatting
run: |
black --check .
isort --check-only .
- name: Type checking
run: mypy src/
test:
runs-on: ubuntu-latest
needs: lint
strategy:
matrix:
python-version: ['3.10', '3.11', '3.12']
os: [ubuntu-latest, macos-latest]
exclude:
- python-version: '3.12'
os: 'macos-latest'
steps:
- uses: actions/checkout@v4
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
cache: 'pip'
- name: Install dependencies
run: |
pip install -r requirements.txt
pip install pytest pytest-cov
- name: Run tests
run: pytest --cov=src --cov-report=xml
- name: Upload coverage
if: matrix.os == 'ubuntu-latest' && matrix.python-version == '3.11'
uses: codecov/codecov-action@v3
with:
files: ./coverage.xml
build:
runs-on: ubuntu-latest
needs: test
if: github.event_name == 'push' && github.ref == 'refs/heads/main'
steps:
- uses: actions/checkout@v4
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Log in to Container Registry
uses: docker/login-action@v3
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Extract metadata for Docker
id: meta
uses: docker/metadata-action@v5
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
tags: |
type=ref,event=branch
type=sha
- name: Build and push Docker image
uses: docker/build-push-action@v5
with:
context: .
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
cache-from: type=gha
cache-to: type=gha,mode=max
deploy:
runs-on: ubuntu-latest
needs: build
if: github.ref == 'refs/heads/main'
steps:
- uses: actions/checkout@v4
- name: Deploy to Production
run: |
echo "Deploying to production..."
kubectl apply -f k8s/
env:
KUBECONFIG: ${{ secrets.KUBE_CONFIG }}
stages:
- lint
- test
- build
- security
- deploy
variables:
DOCKER_DRIVER: overlay2
DOCKER_TLS_CERTDIR: ""
lint:
stage: lint
image: python:3.11
script:
- pip install -r requirements.txt
- black --check .
- isort --check-only .
- mypy src/
only:
- merge_requests
- main
test:
stage: test
image: python:3.11
script:
- pip install -r requirements.txt
- pytest --cov=src
coverage:
[, , ]
[]
Pipeline Best Practices:
1. Fast feedback
Run fast tests first
Parallelize where possible
2. Isolate environments
Use containers
Don't share state
3. Fail fast
Check linting before testing
Validate before building
4. Use artifacts
Pass build outputs between jobs
Store test results
5. Secure secrets
Use encrypted secrets
Don't log sensitive data
6. Single source of truth
Pipeline as code
Version controlled
7. Atomic commits
Small, focused commits
Clear commit messages
8. Manual approvals
Require approval for production
Add gates for critical steps
9. Monitor pipelines
Track success/failure rates
Alert on regressions
10. Keep pipelines simple
Don't overcomplicate
Extract complex logic to scripts
基于 SOC 职业分类