-
Notifications
You must be signed in to change notification settings - Fork 8
fix: capture re-usable workflows as actions instead of scripts #1374
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
Open
Ron (rjaegers)
wants to merge
10
commits into
main
Choose a base branch
from
fix/package-scripts-as-actions
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 9 commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
2b31dc5
fix: resolve sonarqube security findings
rjaegers a1c077b
chore: fix sonarqube findings differently
rjaegers 61a09cd
ci: de-duplicate env
rjaegers 2975c4c
chore: forgot one wget
rjaegers 2e763b5
fix(docker:S6570): double quote to prevent globbing and word splitting
rjaegers 6934e07
fix: capture re-usable workflows as actions instead of scripts
rjaegers faba029
ci: pin actions to (temporary) sha
rjaegers 62b63aa
ci: apply fix for review comment
rjaegers 7e495c9
Merge branch 'main' into fix/package-scripts-as-actions
rjaegers 713b05a
chore: remove non-functional `--https-only`
rjaegers File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,85 @@ | ||
| --- | ||
| name: Generate tool inventory | ||
| description: >- | ||
| Derive a curated, per-flavor tool inventory from a Syft SPDX SBOM and write it | ||
| to a JSON file. | ||
|
|
||
| inputs: | ||
| sbom: | ||
| description: Path to the Syft SPDX SBOM | ||
| required: true | ||
| allowlist: | ||
| description: >- | ||
| Path to the flavor's tool allowlist JSON, relative to the caller | ||
| repository root. The file is sparse-checked-out by this action. | ||
| required: true | ||
| flavor: | ||
| description: Name of the flavor the inventory is generated for | ||
| required: true | ||
| output-file: | ||
| description: Path the generated tool inventory is written to | ||
| required: false | ||
| default: tool-inventory.json | ||
|
|
||
| outputs: | ||
| inventory-file: | ||
| description: Path to the generated tool inventory JSON file | ||
| value: ${{ inputs.output-file }} | ||
|
|
||
| runs: | ||
| using: composite | ||
| steps: | ||
| # The allowlist lives in the caller repository; check out just that file so | ||
| # the action is self-contained and callers need no separate checkout step. | ||
| - uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0 | ||
| with: | ||
| persist-credentials: false | ||
| sparse-checkout: ${{ inputs.allowlist }} | ||
| sparse-checkout-cone-mode: false | ||
| path: ${{ runner.temp }}/allowlist | ||
| - shell: bash | ||
|
rjaegers marked this conversation as resolved.
|
||
| run: | | ||
| set -Eeuo pipefail | ||
|
|
||
| # Keep only packages whose name is on the flavor allowlist and project them | ||
| # to {name, version, purl}. Versions come straight from the SBOM, so the | ||
| # inventory can never disagree with it. | ||
| inventory="$(jq -n \ | ||
| --slurpfile sbom "${SBOM}" \ | ||
| --slurpfile allow "${ALLOWLIST}" \ | ||
| --arg flavor "${FLAVOR}" ' | ||
| ($allow[0] | map(ascii_downcase)) as $names | ||
| | [ $sbom[0].packages[] | ||
| | select(.name != null) | ||
| | . as $pkg | ||
| | select($names | index($pkg.name | ascii_downcase)) | ||
| | { name: $pkg.name, | ||
| version: $pkg.versionInfo, | ||
| purl: ([ $pkg.externalRefs[]? | select(.referenceType == "purl") | .referenceLocator ] | first) } ] | ||
| | unique_by(.name | ascii_downcase) | ||
| | sort_by(.name | ascii_downcase) | ||
| | { flavor: $flavor, tools: . }')" | ||
|
|
||
| # Fail if an allowlisted tool is absent from the SBOM. This turns a version | ||
| # bump that renames a package (e.g. clang-22 -> clang-23) or a tool that | ||
| # silently dropped out of the image into a hard, actionable CI error. | ||
| missing="$(jq -rn \ | ||
| --argjson inventory "${inventory}" \ | ||
| --slurpfile allow "${ALLOWLIST}" ' | ||
| ($inventory.tools | map(.name | ascii_downcase)) as $found | ||
| | $allow[0] | ||
| | map(select((ascii_downcase) as $name | ($found | index($name)) | not)) | ||
| | .[]')" | ||
|
|
||
| if [ -n "${missing}" ]; then | ||
| echo "error: the following allowlisted tools were not found in the SBOM:" >&2 | ||
| echo "${missing}" | sed 's/^/ - /' >&2 | ||
| exit 1 | ||
| fi | ||
|
|
||
| echo "${inventory}" | tee "${OUTPUT_FILE}" | ||
| env: | ||
| SBOM: ${{ inputs.sbom }} | ||
| ALLOWLIST: ${{ runner.temp }}/allowlist/${{ inputs.allowlist }} | ||
| FLAVOR: ${{ inputs.flavor }} | ||
| OUTPUT_FILE: ${{ inputs.output-file }} | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,63 @@ | ||
| --- | ||
| name: Merge devcontainer.metadata | ||
| description: >- | ||
| Assemble the devcontainer.metadata image label for a flavor by concatenating | ||
| the base image's existing metadata array with the flavor's own metadata entry. | ||
|
|
||
| inputs: | ||
| base-image: | ||
| description: Reference of the image this flavor is built FROM (may be empty) | ||
| required: false | ||
| default: "" | ||
| devcontainer-metadata-file: | ||
| description: Path to the flavor's devcontainer-metadata.json (may be absent) | ||
| required: false | ||
| default: "" | ||
|
|
||
| outputs: | ||
| label: | ||
| description: >- | ||
| The `devcontainer.metadata=<json-array>` label value, or empty when no | ||
| metadata file is provided. | ||
| value: ${{ steps.merge.outputs.label }} | ||
|
|
||
| runs: | ||
| using: composite | ||
| steps: | ||
| - id: merge | ||
| shell: bash | ||
| run: | | ||
| set -Eeuo pipefail | ||
|
|
||
| if [ -z "${DEVCONTAINER_METADATA_FILE:-}" ] || [ ! -f "${DEVCONTAINER_METADATA_FILE}" ]; then | ||
| echo "devcontainer-metadata-file input not set or file does not exist, skipping devcontainer.metadata label" | ||
| echo "label=" >> "$GITHUB_OUTPUT" | ||
| exit 0 | ||
| fi | ||
|
|
||
| # Extract the base image's existing devcontainer.metadata array. Falls back | ||
| # to an empty array when no base image is given or it carries no such label. | ||
| base_metadata="[]" | ||
| if [ -n "${BASE_IMAGE:-}" ]; then | ||
| # `.Image` is the image config for single-platform references and a map of | ||
| # `platform -> config` for multi-platform references; the label is identical | ||
| # across platforms, so any entry works. | ||
| config="$(docker buildx imagetools inspect "${BASE_IMAGE}" --format '{{json .Image}}')" | ||
| base_metadata="$(jq -c ' | ||
| (if has("config") then . else (to_entries[0].value) end) | ||
| | (.config.Labels["devcontainer.metadata"] // "") as $raw | ||
| | if $raw == "" then [] else (try ($raw | fromjson) catch []) end | ||
| | if type == "array" then . else [] end | ||
| ' <<< "${config}")" | ||
| fi | ||
|
|
||
| # Concatenate base entries with the flavor entry and emit the label value. | ||
| # The gsub adds a space after each comma so `docker buildx build --label` | ||
| # does not misinterpret the array and produce invalid JSON (e.g. | ||
| # ["x","y"] -> ["x",y]). | ||
| merged="$(jq -cr --slurpfile flavor "${DEVCONTAINER_METADATA_FILE}" '. + $flavor | @json | gsub("\",\""; "\", \"")' <<< "${base_metadata}")" | ||
|
|
||
| echo "label=devcontainer.metadata=${merged}" >> "$GITHUB_OUTPUT" | ||
| env: | ||
| BASE_IMAGE: ${{ inputs.base-image }} | ||
| DEVCONTAINER_METADATA_FILE: ${{ inputs.devcontainer-metadata-file }} |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.