actions/attest-build-provenance
워크플로 아티팩트에 대해 서명된 빌드 출처 증명을 생성합니다. @actions/attest 패키지를 통해 내부적으로 구동됩니다.
증명은 in-toto 형식을 사용하여 일부 주제(다이제스트와 함께 명명된 아티팩트)를 SLSA 빌드 출처 조건자에 바인딩합니다.
단기 Sigstore에서 발급한 서명 인증서를 사용하여 증명을 위한 검증 가능한 서명이 생성됩니다. GitHub Actions 워크플로를 시작하는 저장소가 공개인 경우 Sigstore의 공공재 인스턴스가 증명 서명을 생성하는 데 사용됩니다. 저장소가 비공개/내부인 경우 GitHub 비공개 Sigstore 인스턴스를 사용합니다.
증명이 생성되고 서명되면 GH 증명 API에 업로드되고 워크플로가 시작된 저장소와 연결됩니다.
GitHub CLI의 attestation
명령을 사용하여 증명을 확인할 수 있습니다.
아티팩트 증명에 대한 자세한 내용은 아티팩트 증명을 사용하여 빌드 출처 설정을 참조하세요.
증명하고 싶은 일부 아티팩트를 빌드하는 GitHub Actions 워크플로 내에서 다음을 수행합니다.
다음 권한이 설정되어 있는지 확인하세요.
permissions :
id-token : write
attestations : write
id-token
권한은 작업에 Sigstore 서명 인증서를 요청하는 데 필요한 OIDC 토큰을 생성하는 기능을 제공합니다. 증명을 유지하려면 attestations
권한이 필요합니다.
아티팩트가 빌드된 후 워크플로에 다음을 추가합니다.
- uses : actions/attest-build-provenance@v1
with :
subject-path : ' <PATH TO ARTIFACT> '
subject-path
매개변수는 증명을 생성하려는 아티팩트를 식별해야 합니다.
action.yml 참조
- uses : actions/attest-build-provenance@v1
with :
# Path to the artifact serving as the subject of the attestation. Must
# specify exactly one of "subject-path" or "subject-digest". May contain a
# glob pattern or list of paths (total subject count cannot exceed 2500).
subject-path :
# SHA256 digest of the subject for the attestation. Must be in the form
# "sha256:hex_digest" (e.g. "sha256:abc123..."). Must specify exactly one
# of "subject-path" or "subject-digest".
subject-digest :
# Subject name as it should appear in the attestation. Required unless
# "subject-path" is specified, in which case it will be inferred from the
# path.
subject-name :
# Whether to push the attestation to the image registry. Requires that the
# "subject-name" parameter specify the fully-qualified image name and that
# the "subject-digest" parameter be specified. Defaults to false.
push-to-registry :
# Whether to attach a list of generated attestations to the workflow run
# summary page. Defaults to true.
show-summary :
# The GitHub token used to make authenticated API requests. Default is
# ${{ github.token }}
github-token :
이름 | 설명 | 예 |
---|---|---|
bundle-path | 생성된 증명이 포함된 파일의 절대 경로 | /tmp/attestation.jsonl |
증명은 JSON 직렬화된 Sigstore 번들 형식으로 저장됩니다.
여러 주제가 동시에 증명되는 경우 각 증명은 별도의 줄에 있는 출력 파일에 기록됩니다(JSON Lines 형식 사용).
동시에 2500개 이상의 주제를 인증할 수 없습니다. 대상은 배치 50개로 처리됩니다. 초기 그룹 50개 이후 각 후속 배치에는 증명 API에 부담을 주지 않기 위해 기하급수적으로 증가하는 지연 시간이 발생합니다(배치당 지연 시간은 1분으로 제한됨).
기본 사용 사례의 경우 워크플로에 attest-build-provenance
작업을 추가하고 증명을 생성하려는 아티팩트에 대한 경로를 제공하기만 하면 됩니다.
name : build-attest
on :
workflow_dispatch :
jobs :
build :
permissions :
id-token : write
contents : read
attestations : write
steps :
- name : Checkout
uses : actions/checkout@v4
- name : Build artifact
run : make my-app
- name : Attest
uses : actions/attest-build-provenance@v1
with :
subject-path : ' ${{ github.workspace }}/my-app '
여러 아티팩트를 생성하는 경우 subject-path
입력에 와일드카드를 사용하여 각각에 대한 출처 증명을 생성할 수 있습니다.
- uses : actions/attest-build-provenance@v1
with :
subject-path : ' dist/**/my-bin-* '
동작 및 문서와 함께 지원되는 와일드카드를 보려면 내부적으로 파일을 검색하는 데 사용되는 @actions/glob을 참조하세요.
또는 쉼표 또는 개행으로 구분된 목록을 사용하여 여러 주제를 명시적으로 나열할 수 있습니다.
- uses : actions/attest-build-provenance@v1
with :
subject-path : ' dist/foo, dist/bar '
- uses : actions/attest-build-provenance@v1
with :
subject-path : |
dist/foo
dist/bar
컨테이너 이미지 작업 시 subject-name
및 subject-digest
입력을 사용하여 작업을 호출할 수 있습니다.
push-to-registry
옵션을 사용하여 증명을 컨테이너 레지스트리에 게시하려면 subject-name
이 정규화된 이미지 이름(예: "ghcr.io/user/app" 또는 "acme.conf")을 지정하는 것이 중요합니다. azurecr.io/user/app"). 이미지 이름의 일부로 태그를 포함하지 마십시오. 증명되는 특정 이미지는 제공된 다이제스트에 의해 식별됩니다.
증명 번들은 Cosign 번들 사양에 따라 OCI 레지스트리에 저장됩니다.
참고 : Docker Hub로 푸시할 때 이미지 이름의 레지스트리 부분으로 "index.docker.io"를 사용하십시오.
name : build-attested-image
on :
push :
branches : [main]
jobs :
build :
runs-on : ubuntu-latest
permissions :
id-token : write
packages : write
contents : read
attestations : write
env :
REGISTRY : ghcr.io
IMAGE_NAME : ${{ github.repository }}
steps :
- name : Checkout
uses : actions/checkout@v4
- name : Login to GitHub Container Registry
uses : docker/login-action@v3
with :
registry : ${{ env.REGISTRY }}
username : ${{ github.actor }}
password : ${{ secrets.GITHUB_TOKEN }}
- name : Build and push image
id : push
uses : docker/[email protected]
with :
context : .
push : true
tags : ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:latest
- name : Attest
uses : actions/attest-build-provenance@v1
id : attest
with :
subject-name : ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
subject-digest : ${{ steps.push.outputs.digest }}
push-to-registry : true