meysam81/build-docker

GitHub: meysam81/build-docker

Stars: 2 | Forks: 0

# 构建 Docker [![GitHub Release](https://img.shields.io/github/v/release/meysam81/build-docker)](https://github.com/meysam81/build-docker/releases/latest) [![Renovate](https://img.shields.io/badge/renovate-enabled-brightgreen.svg)](https://developer.mend.io/github/meysam81/build-docker) [![GitHub last commit](https://img.shields.io/github/last-commit/meysam81/build-docker)](https://github.com/meysam81/build-docker/commits/main) [![License](https://img.shields.io/github/license/meysam81/build-docker)](https://github.com/meysam81/build-docker/blob/main/LICENSE) [![GitHub issues](https://img.shields.io/github/issues/meysam81/build-docker)](https://github.com/meysam81/build-docker/issues) [![GitHub pull requests](https://img.shields.io/github/issues-pr/meysam81/build-docker)](https://github.com/meysam81/build-docker/pulls) - [Features](#features) - [Usage](#usage) - [Inputs](#inputs) - [Outputs](#outputs) - [Example](#example) 一个 GitHub composite action,用于简化 Docker 镜像的构建、推送和扫描。它将 Docker 构建、推送、元数据处理、Scout 扫描和 Kubescape 安全分析整合到一个 action 中。 ## 功能特性 - 多平台构建 (amd64/arm64) - GitHub Container Registry 集成 - Docker Hub 支持 - Docker Scout 漏洞扫描 - Kubescape 安全分析 - GitHub 缓存优化 - SARIF 报告生成 ## 用法 ``` - uses: meysam81/build-docker@v1 with: image-name: ghcr.io/${{ github.repository }} # e.g. ghrc.io/octocat/hello-world ``` ## 输入参数 | 名称 | 描述 | 必需 | 默认值 | | ------------------------ | ------------------------------------------------------------------------------------- | -------- | ------------------------- | | `image-name` | 镜像名称(包括 registry 路径) | 是 | - | | `github-token` | 用于认证的 GitHub token | 是 | `${{ github.token }}` | | `build-args` | Docker build 参数 | 否 | `""` | | `context` | 构建上下文路径 | 否 | `.` | | `dockerhub-username` | Docker Hub 用户名(启用 `scout-cves` 或 `scout-compare` 时必需) | 否 | `""` | | `dockerhub-password` | Docker Hub 密码(启用 `scout-cves` 或 `scout-compare` 时必需) | 否 | `""` | | `image-extra-tags` | 额外的镜像标签 | 否 | `""` | | `image-target` | 多阶段构建目标 | 否 | `""` | | `platforms` | 构建平台 | 否 | `linux/amd64,linux/arm64` | | `push` | 推送到 registry(需要 `packages: write`) | 否 | `true` | | `ref` | 要检出的 Git ref | 否 | `${{ github.ref }}` | | `runner` | 要使用的 GitHub runner | 否 | `ubuntu-latest` | | `scout-compare` | 启用 Docker Scout 对比 | 否 | `false` | | `scout-comment-pr` | 将 Scout 结果添加为 PR 评论(仅在 pull requests 中) | 否 | `false` | | `scout-cves` | 启用 Docker Scout CVE 扫描 | 否 | `false` | | `kubescape` | 启用 Kubescape 扫描 | 否 | `false` | | `kubescape-upload-sarif` | 将 Kubescape SARIF 结果上传到 GitHub Security(需要 `security-events: write`) | 否 | `false` | ## 输出 | 名称 | 描述 | | ---------- | -------------------------------- | | `digest` | 镜像内容寻址摘要 | | `imageid` | 构建的镜像 ID | | `metadata` | 构建结果元数据 | ## 示例 ``` name: ci on: push: branches: - main jobs: build: runs-on: ubuntu-latest steps: - uses: meysam81/build-docker@v1 with: image-name: ghcr.io/${{ github.repository }} image-extra-tags: | ghcr.io/${{ github.repository }}:${{ github.run_id }} kubescape: true kubescape-upload-sarif: true ```
标签:Amd64, Arm64, DevSecOps, Docker, Docker Hub, Docker Scout, GHCR, GitHub Action, GitHub Container Registry, Kubescape, QEMU替代, SARIF, Web截图, 上游代理, 复合Action, 多平台构建, 安全防御评估, 容器安全, 容器构建, 自动化运维, 请求拦截, 身份验证强制, 镜像推送, 镜像缓存