Skip to content

Commit 7457785

Browse files
Merge pull request #18 from step-security/docker-prov
Sign the docker image
2 parents e1c712d + b5cb34a commit 7457785

5 files changed

Lines changed: 67 additions & 48 deletions

File tree

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
name: Release GitHub Actions
2+
3+
on:
4+
workflow_dispatch:
5+
inputs:
6+
tag:
7+
description: "Tag for the release"
8+
required: true
9+
10+
permissions:
11+
contents: read
12+
13+
jobs:
14+
release:
15+
permissions:
16+
actions: read
17+
id-token: write
18+
contents: write
19+
uses: step-security/reusable-workflows/.github/workflows/actions_release.yaml@v1
20+
with:
21+
tag: "${{ github.event.inputs.tag }}"

.github/workflows/ci-cd.yml

Lines changed: 44 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -93,10 +93,12 @@ jobs:
9393
env:
9494
DOCKER_CLI_EXPERIMENTAL: enabled
9595
run: |
96+
exists='false'
9697
if docker manifest inspect '${{ steps.action.outputs.image }}'
9798
then
98-
echo "exists=true" >>$GITHUB_OUTPUT
99+
exists='true'
99100
fi
101+
echo "exists=$exists" >>$GITHUB_OUTPUT
100102
shell: bash
101103

102104
deploy:
@@ -108,6 +110,10 @@ jobs:
108110
runs-on: ubuntu-latest
109111
permissions:
110112
packages: write
113+
outputs:
114+
image: ${{ steps.image.outputs.image }}
115+
digest: ${{ steps.build.outputs.digest }}
116+
should_push: ${{ steps.check_conditions.outputs.should_push }}
111117
steps:
112118
- name: Docker meta
113119
id: docker-meta
@@ -137,23 +143,52 @@ jobs:
137143
username: ${{ github.actor }}
138144
password: ${{ secrets.GITHUB_TOKEN }}
139145

146+
- name: Check Conditions
147+
id: check_conditions
148+
run: |
149+
should_push_value='false'
150+
if [[ '${{ github.event_name }}' == 'push' ]]; then
151+
if [[ ${{ startsWith(github.ref, 'refs/heads/main') }} && '${{ needs.config-deploy.outputs.image-exists }}' != 'true' ]]; then
152+
should_push_value='true'
153+
fi
154+
fi
155+
echo "should_push=$should_push_value" >> "$GITHUB_OUTPUT"
156+
157+
140158
- name: Build and push Docker image
141159
uses: docker/build-push-action@v4
160+
id: build
142161
with:
143162
tags: ${{ steps.docker-meta.outputs.tags }}
144163
labels: ${{ steps.docker-meta.outputs.labels }}
145164
platforms: linux/amd64,linux/arm64
146165
pull: true
147166
# deploy image actions from commits pushed to main and
148167
# deploy Dockerfile actions from pushed version tags (no major versions)
149-
push: |
150-
${{
151-
github.event_name == 'push' && (
152-
needs.config-deploy.outputs.image != 'Dockerfile' && startsWith(github.ref, 'refs/heads/main') && needs.config-deploy.outputs.image-exists != 'true' ||
153-
needs.config-deploy.outputs.image == 'Dockerfile' && startsWith(github.ref, 'refs/tags/v') && contains(github.ref, '.')
154-
)
155-
}}
156-
168+
push: ${{ steps.check_conditions.outputs.should_push }}
169+
- name: Output image
170+
id: image
171+
run: |
172+
# NOTE: Set the image as an output because the `env` context is not
173+
# available to the inputs of a reusable workflow call.
174+
image_name="${IMAGE_REGISTRY}/${IMAGE_NAME}"
175+
echo "image=$image_name" >> "$GITHUB_OUTPUT"
176+
177+
provenance:
178+
needs: [deploy]
179+
permissions:
180+
actions: read # for detecting the Github Actions environment.
181+
id-token: write # for creating OIDC tokens for signing.
182+
packages: write # for uploading attestations.
183+
if: ${{ needs.deploy.outputs.should_push == 'true' }}
184+
uses: slsa-framework/slsa-github-generator/.github/workflows/generator_container_slsa3.yml@v1.9.0
185+
with:
186+
image: ${{ needs.deploy.outputs.image }}
187+
digest: ${{ needs.deploy.outputs.digest }}
188+
registry-username: ${{ github.actor }}
189+
secrets:
190+
registry-password: ${{ secrets.GITHUB_TOKEN }}
191+
157192
event_file:
158193
name: "Event File"
159194
runs-on: ubuntu-latest

.github/workflows/release.yml

Lines changed: 0 additions & 37 deletions
This file was deleted.

action.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,7 @@ outputs:
143143

144144
runs:
145145
using: 'docker'
146-
image: 'docker://ghcr.io/step-security/publish-unit-test-result-action:v1.0.1'
146+
image: 'docker://ghcr.io/step-security/publish-unit-test-result-action:v1.0.2'
147147

148148
branding:
149149
icon: 'check-square'

python/publish/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
UnitTestRunDeltaResults, UnitTestRunResultsOrDeltaResults, ParseError
1212

1313
# keep the version in sync with action.yml
14-
__version__ = 'v1.0.1'
14+
__version__ = 'v1.0.2'
1515

1616
logger = logging.getLogger('publish')
1717
digest_prefix = '[test-results]:data:'

0 commit comments

Comments
 (0)