mcpField
C
configure-argocd-automerge

configure-argocd-automerge

github.com/laurigates云与 DevOps5953 次安装1 天前更新
代码仓库

关于 configure-argocd-automerge

configure-argocd-automerge 是用于配置 ArgoCD Image Updater 自动合并工作流的技能,面向维护 GitHub Actions 与部署流程的团队。它可检查现有工作流,并按需创建或更新处理相关分支的配置。

主要功能

  1. 01检查 ArgoCD 自动合并工作流
  2. 02验证权限与分支模式
  3. 03创建或更新 GitHub Actions 工作流
  4. 04支持仅检查模式
  5. 05说明 PAT 与分支保护要求

适用场景

  1. 01为 Image Updater 分支设置自动合并
  2. 02检查现有自动合并工作流是否符合要求
  3. 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 步:检测现有工作流
  1. 检查 .github/workflows/ 目录是否存在
  2. 搜索现有的 ArgoCD 自动合并工作流文件
  3. 检查任意工作流是否处理 image-updater-** 分支模式
第 2 步:检查合规性

根据以下标准验证工作流:

检查项标准严重性
工作流存在argocd-automerge.yml缺失则失败
checkout actionv6使用较旧版本则警告
权限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)
自定义
设置默认值其他选项
基础分支mainmaster、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