-
Notifications
You must be signed in to change notification settings - Fork 136
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: docker input for Bazel Builder and Rebuilder #2602
base: main
Are you sure you want to change the base?
Changes from all commits
72fba0c
a70c750
bb8b2eb
c516876
9f679ee
5f64a76
20e0b20
3c26e32
e6f8366
be49f2e
3a5a99f
d033ee7
ce6082d
849d25b
9a27d42
503ae6a
cde809a
a5936e9
fe3b22e
96f8cfa
46e7587
872e2a9
2eaf9ed
6441936
4a4769a
62e616c
cd75049
dd40f91
b18ec27
0c6aaa3
e34d9ec
20ec135
f6349e0
543d632
d3e2249
3abc64a
529f50f
51d14a3
b2197fb
3fdb6ba
89de881
3e2d291
a70bcc7
e69e6cb
9894083
78a55c0
15bba70
8ba63f6
fd11a62
ce9dc3b
113e734
8eb66ad
773dd37
e47447c
c940cfd
74d4190
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -35,6 +35,18 @@ on: | |
required: false | ||
type: string | ||
default: "" | ||
env-image: | ||
description: "Image for build environment to run on" | ||
required: false | ||
type: string | ||
default: "" | ||
env-image-digest: | ||
description: > | ||
TODO(#2630): Add verification method for digest. | ||
The image digest of the environment image. | ||
This must be specified in order to verify the image. | ||
required: false | ||
type: string | ||
needs-runfiles: | ||
description: > | ||
A boolean input that if true will package the artifact's runfiles along with the artifact. | ||
|
@@ -76,6 +88,32 @@ on: | |
When run on other triggers, attestations are signed and have an "intoto.sigstore" extension. | ||
value: ${{ jobs.slsa-run.outputs.attestations-download-name }} | ||
|
||
provenance-download-sha256: | ||
description: > | ||
The sha256 digest of the attestations. | ||
|
||
Users should verify the download against this digest to prevent tampering. | ||
value: ${{ jobs.slsa-run.outputs.attestations-download-sha256 }} | ||
|
||
artifacts-download-name: | ||
description: > | ||
The name of the folder containing the built artifacts. There is a random hash at the | ||
enteraga6 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
beginning of it in form <hash>-binaries to avoid collisions. | ||
value: ${{ fromJSON(jobs.slsa-run.outputs.build-artifacts-outputs).artifacts-download-name }} | ||
|
||
artifacts-download-sha256: | ||
description: "SHA256 of the uploaded tarball of built artifacts." | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. use sha256 lower case like in other description |
||
value: ${{ fromJSON(jobs.slsa-run.outputs.build-artifacts-outputs).artifacts-download-sha256 }} | ||
|
||
artifacts-actual-name: | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. let's be consistent with the name used by other builders |
||
description: > | ||
The name of the folder which contains the artifacts. | ||
|
||
After downloading artifacts-download-name and extracting | ||
the folder.tgz from inside. A folder with artifacts with | ||
this name will be extracted. | ||
value: ${{ fromJSON(jobs.slsa-run.outputs.build-artifacts-outputs).artifacts-actual-name }} | ||
|
||
jobs: | ||
slsa-setup: | ||
permissions: | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -41,6 +41,23 @@ inputs: | |
slsa-workflow-secret14: {} | ||
slsa-workflow-secret15: {} | ||
|
||
outputs: | ||
artifacts-download-name: | ||
description: "The name of binaries folder to download" | ||
# NOTE: This is an "untrusted" value returned from the build. | ||
value: "${{ steps.rng.outputs.random }}-artifacts" | ||
artifacts-download-sha256: | ||
description: "SHA256 of the uploaded tarball of artifacts." | ||
value: ${{ steps.generate-artifacts.outputs.sha256 }} | ||
artifacts-actual-name: | ||
description: > | ||
The name of the folder which contains the artifacts. | ||
|
||
After downloading artifacts-download-name and extracting | ||
the folder.tgz from inside. A folder with artifacts with | ||
this name will be extracted. | ||
value: "bazel_builder_binaries_to_upload_to_gh_7bc972367cb286b7f36ab4457f06e369" | ||
|
||
runs: | ||
using: "composite" | ||
steps: | ||
|
@@ -52,20 +69,51 @@ runs: | |
uses: bazelbuild/setup-bazelisk@95c9bf48d0c570bb3e28e57108f3450cd67c1a44 # v2.0.0 | ||
|
||
- name: Setup Java | ||
if: ${{ fromJson(inputs.slsa-workflow-inputs).includes-java }} == 'true' | ||
id: java | ||
uses: actions/setup-java@0ab4596768b603586c0de567f2430c30f5b0d2b0 # v3.13.0 | ||
with: | ||
distribution: "${{ fromJson(inputs.slsa-workflow-inputs).user-java-distribution }}" | ||
java-version: "${{ fromJson(inputs.slsa-workflow-inputs).user-java-version }}" | ||
|
||
- name: Check for Environment Image | ||
id: env-image | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. why do we need this step? Why can't we simply use |
||
shell: bash | ||
run: | | ||
if [[ -z "${{ fromJson(inputs.slsa-workflow-inputs).env-image }}" ]] | ||
then | ||
echo "No Environment Image provided. Will build without." | ||
echo "use_env_image=false" >> $GITHUB_OUTPUT | ||
else | ||
echo "Docker image provided. Running build on Docker Image." | ||
echo "use_env_image=true" >> $GITHUB_OUTPUT | ||
fi | ||
|
||
- name: Build on Environment Image | ||
if: ${{ steps.env-image.outputs.use_env_image == 'true' }} | ||
env: | ||
UNTRUSTED_TARGETS: ${{ fromJson(inputs.slsa-workflow-inputs).targets }} | ||
UNTRUSTED_FLAGS: ${{ fromJson(inputs.slsa-workflow-inputs).flags }} | ||
UNTRUSTED_NEEDS_RUNFILES: ${{ fromJson(inputs.slsa-workflow-inputs).needs-runfiles }} | ||
UNTRUSTED_INCLUDES_JAVA: ${{ fromJson(inputs.slsa-workflow-inputs).includes-java }} | ||
UNTRUSTED_ENV_IMAGE: ${{ fromJson(inputs.slsa-workflow-inputs).env-image }} | ||
shell: bash | ||
run: | | ||
set -euo pipefail | ||
docker pull $UNTRUSTED_ENV_IMAGE | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. double quote missing There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. is the pull required? Will docker pull automatically as part of |
||
curr_dir=$(basename "$(pwd)") | ||
docker run --rm --env UNTRUSTED_TARGETS=${UNTRUSTED_TARGETS} --env UNTRUSTED_FLAGS=${UNTRUSTED_FLAGS} --env UNTRUSTED_NEEDS_RUNFILES=${UNTRUSTED_NEEDS_RUNFILES} --env UNTRUSTED_INCLUDES_JAVA=${UNTRUSTED_INCLUDES_JAVA} -v $PWD/../:/src -w /src $UNTRUSTED_ENV_IMAGE /bin/sh -c "ls && tree && cd $curr_dir && ls && tree && ./../__TOOL_ACTION_DIR__/build.sh" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. double quote missing |
||
|
||
- id: build | ||
if: ${{ steps.env-image.outputs.use_env_image == 'false' }} | ||
env: | ||
TARGETS: ${{ fromJson(inputs.slsa-workflow-inputs).targets }} | ||
FLAGS: ${{ fromJson(inputs.slsa-workflow-inputs).flags }} | ||
NEEDS_RUNFILES: ${{ fromJson(inputs.slsa-workflow-inputs).needs-runfiles }} | ||
INCLUDES_JAVA: ${{ fromJson(inputs.slsa-workflow-inputs).includes-java }} | ||
UNTRUSTED_TARGETS: ${{ fromJson(inputs.slsa-workflow-inputs).targets }} | ||
UNTRUSTED_FLAGS: ${{ fromJson(inputs.slsa-workflow-inputs).flags }} | ||
UNTRUSTED_NEEDS_RUNFILES: ${{ fromJson(inputs.slsa-workflow-inputs).needs-runfiles }} | ||
UNTRUSTED_INCLUDES_JAVA: ${{ fromJson(inputs.slsa-workflow-inputs).includes-java }} | ||
shell: bash | ||
run: ./../__TOOL_ACTION_DIR__/build.sh | ||
run: | | ||
./../__TOOL_ACTION_DIR__/build.sh | ||
|
||
# rng generates a random number to avoid name collision in artifacts | ||
# when multiple workflows run concurrently. | ||
|
@@ -77,7 +125,7 @@ runs: | |
id: generate-artifacts | ||
uses: slsa-framework/slsa-github-generator/.github/actions/secure-upload-folder@main | ||
with: | ||
name: "${{ steps.rng.outputs.random }}-binaries" | ||
name: "${{ steps.rng.outputs.random }}-artifacts" | ||
path: "./bazel_builder_binaries_to_upload_to_gh_7bc972367cb286b7f36ab4457f06e369" # path-to-artifact(s) | ||
|
||
- name: Echo statement | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
let's re-use the naming from the container-based builder for consistency, unless there's a good reason not to