关于 configure-argocd-automerge
configure-argocd-automerge 是用于配置 ArgoCD Image Updater 自动合并工作流的技能,面向维护 GitHub Actions 与部署流程的团队。它可检查现有工作流,并按需创建或更新处理相关分支的配置。
主要功能
- 01检查 ArgoCD 自动合并工作流
- 02验证权限与分支模式
- 03创建或更新 GitHub Actions 工作流
- 04支持仅检查模式
- 05说明 PAT 与分支保护要求
适用场景
- 01为 Image Updater 分支设置自动合并
- 02检查现有自动合并工作流是否符合要求
- 03更新工作流并核实所需权限
安装
复制下面的命令,在终端中运行。
$
npx skills add https:/ / github.com/ laurigates/ claude-plugins --skill configure-argocd-automerge安装后在 Claude Code 中输入/configure-argocd-automerge确认已加载。
详细介绍
/configure:argocd-automerge
配置 GitHub Actions 工作流,自动为 ArgoCD Image Updater 分支创建并合并 PR。
何时使用此技能
| 在以下情况下使用此技能…… | 在以下情况下采用其他方式…… |
|---|---|
| 为 ArgoCD Image Updater 分支设置自动合并 | 配置 ArgoCD 应用定义 |
检查 image-updater-** 分支是否启用了自动合并 | 管理常规 GitHub Actions 工作流(/configure:workflows) |
从头创建 argocd-automerge.yml 工作流 | 设置容器构建(/configure:container) |
| 验证自动合并工作流的 PAT 和权限 | 手动配置分支保护规则 |
| 更新现有的 ArgoCD 自动合并工作流 | 配置 Kubernetes 部署(/configure:skaffold) |
上下文
- 工作流目录:!
find . -maxdepth 1 -type d -name \'.github/workflows\' - 现有自动合并工作流:!
find . -path '*/.github/workflows/*' -maxdepth 3 \( -name '*argocd*automerge*' -o -name '*automerge*argocd*' \) - Image updater 分支:!
git branch -r --list 'origin/image-updater-*' - 自动合并工作流:!
find . -path '*/.github/workflows/*' -maxdepth 3 -name 'argocd-automerge.yml'
参数
从命令参数中解析:
--check-only:报告状态,不提供修复方案--fix:自动创建或更新工作流
执行
执行此 ArgoCD 自动合并工作流配置:
第 1 步:检测现有工作流
- 检查
.github/workflows/目录是否存在 - 搜索现有的 ArgoCD 自动合并工作流文件
- 检查任意工作流是否处理
image-updater-**分支模式
第 2 步:检查合规性
根据以下标准验证工作流:
| 检查项 | 标准 | 严重性 |
|---|---|---|
| 工作流存在 | argocd-automerge.yml | 缺失则失败 |
| checkout action | v6 | 使用较旧版本则警告 |
| 权限 | contents: write, pull-requests: write | 缺失则失败 |
| 分支模式 | image-updater-** | 不同则警告 |
| 自动合并 | squash 合并 | 信息 |
第 3 步:报告结果
打印状态报告:
ArgoCD Auto-merge Workflow Status
======================================
Workflow: .github/workflows/argocd-automerge.yml
Status:
Workflow exists [PASS|FAIL]
checkout action [version] [PASS|WARN]
Permissions [explicit|missing] [PASS|FAIL]
Branch pattern [pattern] [PASS|WARN]
Auto-merge [strategy] [PASS|INFO]
Overall: [PASS|FAIL|WARN]
如果指定了 --check-only,则在此处停止。
第 4 步:配置工作流(如有需要)
如果设置了 --fix 标志或用户确认,则使用标准模板创建或更新 .github/workflows/argocd-automerge.yml:
name: Auto-merge ArgoCD Image Updater branches
on:
push:
branches:
- 'image-updater-**'
permissions:
contents: write
pull-requests: write
jobs:
create-and-merge:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v6
- name: Create Pull Request
id: create-pr
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
PR_URL=$(gh pr create \
--base main \
--head "${{ github.ref_name }}" \
--title "chore(deps): update container image" \
--body "Automated image update by argocd-image-updater.
Branch: \`${{ github.ref_name }}\`" \
2>&1) || true
# Check if PR already exists
if echo "$PR_URL" | grep -q "already exists"; then
PR_URL=$(gh pr view "${{ github.ref_name }}" --json url -q .url)
fi
echo "pr_url=$PR_URL" >> "$GITHUB_OUTPUT"
echo "Created/found PR: $PR_URL"
- name: Approve PR
env:
GH_TOKEN: ${{ secrets.AUTO_MERGE_PAT || secrets.GITHUB_TOKEN }}
run: gh pr review --approve "${{ github.ref_name }}"
continue-on-error: true
- name: Enable auto-merge
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: gh pr merge --auto --squash "${{ github.ref_name }}"
配置说明
自我审批
GitHub 会阻止工作流使用 GITHUB_TOKEN 批准自己的 PR。可选方案:
| 方案 | 设置 | 说明 |
|---|---|---|
AUTO_MERGE_PAT | 创建具有 repo 权限范围的 PAT,并将其添加为密钥 | 推荐用于完全自动化 |
| 跳过审批 | 移除审批步骤 | 需要手动审批或绕过 CODEOWNERS |
| 机器人账号 | 使用单独机器人用户的 PAT | 企业级方案 |
分支保护
确保分支保护允许:
- 检查通过后自动合并
- 工作流绕过限制(如果使用 CODEOWNERS)
自定义
| 设置 | 默认值 | 其他选项 |
|---|---|---|
| 基础分支 | main | master、develop |
| 合并策略 | --squash | --merge、--rebase |
| PR 标题 | chore(deps): update container image | 自定义格式 |
Agent 化优化
| 上下文 | 命令 |
|---|---|
| 快速检查状态 | /configure:argocd-automerge --check-only |
| 自动创建工作流 | /configure:argocd-automerge --fix |
| 列出 image-updater 分支 | git branch -r --list 'origin/image-updater-*' |
| 验证工作流是否存在 | find .github/workflows -name '*argocd*automerge*' 2>/dev/null |
标志
| 标志 | 说明 |
|---|---|
--check-only | 报告状态,不提供修复方案 |
--fix | 自动创建或更新工作流 |
另请参阅
/configure:workflows- GitHub Actions CI/CD 工作流/configure:container- 容器基础设施ci-workflows技能 - 工作流模式
评论
支持 Markdown