Skip to content

Commit 38cb337

Browse files
chore: Remove GITHUB_ENV usages (#101)
Co-authored-by: Nick <10092581+NickLarsenNZ@users.noreply.github.com>
1 parent 25622e7 commit 38cb337

7 files changed

Lines changed: 41 additions & 53 deletions

File tree

build-container-image/action.yaml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,6 @@ runs:
6363
DOCKER_BUILD_ARGUMENTS=$("$GITHUB_ACTION_PATH/../.scripts/actions/get_build_arguments.sh" "$BUILD_ARGUMENTS")
6464
6565
IMAGE_ARCH=$("$GITHUB_ACTION_PATH/../.scripts/actions/get_architecture.sh")
66-
echo "IMAGE_ARCH=${IMAGE_ARCH}" | tee -a "$GITHUB_ENV"
6766
6867
IMAGE_MANIFEST_TAG="${IMAGE_INDEX_MANIFEST_TAG}-${IMAGE_ARCH}"
6968
echo "IMAGE_MANIFEST_TAG=${IMAGE_MANIFEST_TAG}" | tee -a "$GITHUB_OUTPUT"

build-product-image/action.yaml

Lines changed: 7 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -29,12 +29,12 @@ outputs:
2929
description: |
3030
Human-readable tag (usually the version) with architecture information,
3131
for example: `3.4.1-stackable0.0.0-dev-amd64`
32-
value: ${{ steps.image_info.outputs.IMAGE_MANIFEST_TAG }}
32+
value: ${{ steps.build.outputs.IMAGE_MANIFEST_TAG }}
3333
suggested-image-index-manifest-tag:
3434
description: |
3535
Human-readable tag (usually the version) without architecture information,
3636
for example: `3.4.1-stackable0.0.0-dev`
37-
value: ${{ steps.image_info.outputs.IMAGE_INDEX_MANIFEST_TAG }}
37+
value: ${{ steps.build.outputs.IMAGE_INDEX_MANIFEST_TAG }}
3838
runs:
3939
using: composite
4040
steps:
@@ -49,6 +49,7 @@ runs:
4949
run: "$GITHUB_ACTION_PATH/../.scripts/actions/install_boil.sh"
5050

5151
- name: Building ${{ inputs.product-name }} Container Image using boil
52+
id: build
5253
env:
5354
REGISTRY_NAMESPACE: ${{ inputs.registry-namespace }}
5455
BOIL_PRODUCT_VERSION: ${{ inputs.product-version }}
@@ -59,13 +60,14 @@ runs:
5960
shell: bash
6061
run: |
6162
set -euo pipefail
63+
6264
IMAGE_ARCH=$("$GITHUB_ACTION_PATH/../.scripts/actions/get_architecture.sh")
6365
6466
# Will be either:
6567
# - 3.9.2-stackable0.0.0-dev or
6668
# - 3.9.2-stackable0.0.0-dev-pr321
6769
IMAGE_INDEX_MANIFEST_TAG="${SDP_VERSION}${EXTRA_TAG_DATA:+-$EXTRA_TAG_DATA}"
68-
echo "IMAGE_INDEX_MANIFEST_TAG=$IMAGE_INDEX_MANIFEST_TAG" | tee -a "$GITHUB_ENV"
70+
echo "IMAGE_INDEX_MANIFEST_TAG=$IMAGE_INDEX_MANIFEST_TAG" | tee -a "$GITHUB_OUTPUT"
6971
7072
# Validate that final tag is valid according to
7173
# https://github.com/distribution/reference/blob/8c942b0459dfdcc5b6685581dd0a5a470f615bff/regexp.go#L68
@@ -82,26 +84,16 @@ runs:
8284
--configuration "$BOIL_CONFIG_FILE" \
8385
--write-image-manifest-uris \
8486
--use-localhost-registry \
85-
--load \
86-
"$IMAGE_REPOSITORY=$BOIL_PRODUCT_VERSION"
87+
"$IMAGE_REPOSITORY=$BOIL_PRODUCT_VERSION" \
88+
-- --load
8789
echo "::endgroup::"
8890
89-
- name: Extract Environment Variables
90-
id: image_info
91-
shell: bash
92-
run: |
93-
set -euo pipefail
9491
echo "boil-target-tags: "$(< boil-target-tags)
9592
9693
# Extract the image manifest tag from the boil-target-tags file
9794
IMAGE_MANIFEST_TAG=$(cut -d : -f 2 < boil-target-tags)
9895
[[ -n "$IMAGE_MANIFEST_TAG" ]]
99-
[[ -n "$IMAGE_INDEX_MANIFEST_TAG" ]]
100-
101-
# Add the contents of the env variables to the GitHub output, so that it
102-
# can be used as action outputs
10396
echo "IMAGE_MANIFEST_TAG=$IMAGE_MANIFEST_TAG" | tee -a "$GITHUB_OUTPUT"
104-
echo "IMAGE_INDEX_MANIFEST_TAG=$IMAGE_INDEX_MANIFEST_TAG" | tee -a "$GITHUB_OUTPUT"
10597
10698
- name: Print out Disk Usage
10799
if: always()

publish-helm-chart/action.yaml

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,7 @@ runs:
102102
mv "$CHART_DIRECTORY/values.merged.yaml" "$CHART_DIRECTORY/values.yaml"
103103
104104
- name: Package Helm Chart
105+
id: package
105106
env:
106107
CHART_DIRECTORY: ${{ inputs.chart-directory }}
107108
CHART_VERSION: ${{ inputs.chart-version }}
@@ -114,7 +115,7 @@ runs:
114115
115116
# Create temporary directory to store the Helm Chart
116117
TEMP_CHART_DIR=$(mktemp -d)
117-
echo "TEMP_CHART_DIR=$TEMP_CHART_DIR" | tee -a "$GITHUB_ENV"
118+
echo "TEMP_CHART_DIR=$TEMP_CHART_DIR" | tee -a "$GITHUB_OUTPUT"
118119
119120
# Package the Helm Chart
120121
helm package \
@@ -124,8 +125,10 @@ runs:
124125
"$CHART_DIRECTORY"
125126
126127
- name: Publish Helm Chart
128+
id: publish
127129
if: inputs.publish-and-sign == 'true'
128130
env:
131+
TEMP_CHART_DIR: ${{ steps.package.outputs.TEMP_CHART_DIR }}
129132
CHART_REGISTRY_URI: ${{ inputs.chart-registry-uri }}
130133
CHART_REPOSITORY: ${{ inputs.chart-repository }}
131134
CHART_DIRECTORY: ${{ inputs.chart-directory }}
@@ -138,7 +141,7 @@ runs:
138141
139142
CHART_NAME=$(echo "$CHART_DIRECTORY" | awk -F/ '{print $NF}')
140143
CHART_ARTIFACT="${TEMP_CHART_DIR}/${CHART_NAME}-${CHART_VERSION}.tgz"
141-
echo "CHART_NAME=$CHART_NAME" | tee -a "$GITHUB_ENV"
144+
echo "CHART_NAME=$CHART_NAME" | tee -a "$GITHUB_OUTPUT"
142145
143146
# Capture the stdout output to extract the digest. It is sad that Helm doesn't provide
144147
# structured output, eg. in JSON. There is a 2-year old open issue about it:
@@ -153,15 +156,17 @@ runs:
153156
exit 1
154157
fi
155158
156-
echo "CHART_DIGEST=$CHART_DIGEST" | tee -a "$GITHUB_ENV"
159+
echo "CHART_DIGEST=$CHART_DIGEST" | tee -a "$GITHUB_OUTPUT"
157160
158161
- name: Sign Helm Chart
159162
if: inputs.publish-and-sign == 'true'
160163
env:
161164
RETRY_TIMEOUT: ${{ inputs.cosign-retry-timeout }}
162165
RETRY_COUNT: ${{ inputs.cosign-retries }}
163166
RETRY_ARGS: --verbose
167+
CHART_DIGEST: ${{ steps.publish.outputs.CHART_DIGEST }}
164168
CHART_REGISTRY_URI: ${{ inputs.chart-registry-uri }}
169+
CHART_NAME: ${{ steps.publish.outputs.CHART_NAME }}
165170
CHART_REPOSITORY: ${{ inputs.chart-repository }}
166171
GITHUB_DEBUG: ${{ runner.debug }}
167172
shell: bash

publish-image-index-manifest/action.yaml

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -54,14 +54,6 @@ runs:
5454
username: ${{ inputs.image-registry-username }}
5555
password: ${{ inputs.image-registry-password }}
5656

57-
- name: Extract Action Path
58-
shell: bash
59-
env:
60-
GITHUB_ACTION_PATH: ${{ github.action_path }}
61-
run: |
62-
set -euo pipefail
63-
echo "GITHUB_ACTION_PATH=$GITHUB_ACTION_PATH" | tee -a "$GITHUB_ENV"
64-
6557
- name: Create Image Index Manifest Manifest
6658
id: create-index
6759
shell: bash
@@ -76,7 +68,6 @@ runs:
7668
# Construct the image index uri, which for example contains:
7769
# oci.stackable.tech/sdp/kafka:3.4.1-stackable0.0.0-dev
7870
IMAGE_INDEX_URI="$REGISTRY_URI/$IMAGE_REPOSITORY:$IMAGE_INDEX_MANIFEST_TAG"
79-
echo "IMAGE_INDEX_URI=$IMAGE_INDEX_URI" | tee -a "$GITHUB_ENV"
8071
echo "IMAGE_INDEX_URI=$IMAGE_INDEX_URI" | tee -a "$GITHUB_OUTPUT"
8172
8273
AMEND_OPTIONS=$(
@@ -109,6 +100,7 @@ runs:
109100
RETRY_TIMEOUT: ${{ inputs.cosign-retry-timeout }}
110101
RETRY_COUNT: ${{ inputs.cosign-retries }}
111102
RETRY_ARGS: --verbose
103+
IMAGE_INDEX_URI: ${{ steps.create-index.outputs.IMAGE_INDEX_URI }}
112104
IMAGE_REPOSITORY: ${{ inputs.image-repository }}
113105
REGISTRY_URI: ${{ inputs.image-registry-uri }}
114106
run: |

publish-image/action.yaml

Lines changed: 17 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -67,15 +67,8 @@ runs:
6767
username: ${{ inputs.image-registry-username }}
6868
password: ${{ inputs.image-registry-password }}
6969

70-
- name: Extract Action Path
71-
shell: bash
72-
env:
73-
GITHUB_ACTION_PATH: ${{ github.action_path }}
74-
run: |
75-
set -euo pipefail
76-
echo "GITHUB_ACTION_PATH=$GITHUB_ACTION_PATH" | tee -a "$GITHUB_ENV"
77-
7870
- name: Re-tag container image
71+
id: re-tag
7972
shell: bash
8073
env:
8174
TARGET_IMAGE_URI: ${{ inputs.image-registry-uri }}/${{ inputs.image-repository }}:${{ inputs.image-manifest-tag }}
@@ -85,46 +78,51 @@ runs:
8578
docker tag "$SOURCE_IMAGE_URI" "$TARGET_IMAGE_URI"
8679
8780
# Output for the next step
88-
echo "IMAGE_MANIFEST_URI=$TARGET_IMAGE_URI" | tee -a "$GITHUB_ENV"
81+
echo "IMAGE_MANIFEST_URI=$TARGET_IMAGE_URI" | tee -a "$GITHUB_OUTPUT"
8982
9083
- name: Push the container image to ${{ inputs.image-registry-uri }}
84+
id: push
9185
shell: bash
86+
env:
87+
IMAGE_MANIFEST_URI: ${{ steps.re-tag.outputs.IMAGE_MANIFEST_URI }}
9288
run: |
9389
set -euo pipefail
9490
docker image push "$IMAGE_MANIFEST_URI"
9591
9692
# Output for the next step
97-
IMAGE_REPO_DIGEST=$("$GITHUB_ACTION_PATH/../.scripts/actions/get_repo_digest.sh" "$IMAGE_MANIFEST_URI")
98-
echo "IMAGE_REPO_DIGEST=$IMAGE_REPO_DIGEST" | tee -a "$GITHUB_ENV"
93+
IMAGE_REPOSITORY_DIGEST=$("$GITHUB_ACTION_PATH/../.scripts/actions/get_repo_digest.sh" "$IMAGE_MANIFEST_URI")
94+
echo "IMAGE_REPOSITORY_DIGEST=$IMAGE_REPOSITORY_DIGEST" | tee -a "$GITHUB_OUTPUT"
9995
100-
- name: Sign the container image (${{ env.IMAGE_REPO_DIGEST }})
96+
- name: Sign the container image (${{ env.IMAGE_REPOSITORY_DIGEST }})
10197
shell: bash
10298
env:
10399
RETRY_TIMEOUT: ${{ inputs.cosign-retry-timeout }}
104100
RETRY_COUNT: ${{ inputs.cosign-retries }}
105101
RETRY_ARGS: --verbose
102+
IMAGE_REPOSITORY_DIGEST: ${{ steps.push.outputs.IMAGE_REPOSITORY_DIGEST }}
106103
run: |
107104
set -euo pipefail
108105
109106
# This generates a signature and publishes it to the registry, next to
110107
# the image. This step uses the keyless signing flow with Github Actions
111108
# as the identity provider.
112-
"$GITHUB_ACTION_PATH/../.scripts/actions/retry.sh" cosign sign --yes "${IMAGE_REPO_DIGEST}"
109+
"$GITHUB_ACTION_PATH/../.scripts/actions/retry.sh" cosign sign --yes "${IMAGE_REPOSITORY_DIGEST}"
113110
114-
- name: Generate SBOM for the container image (${{ env.IMAGE_REPO_DIGEST }})
111+
- name: Generate SBOM for the container image (${{ env.IMAGE_REPOSITORY_DIGEST }})
115112
shell: bash
116113
env:
117114
RETRY_TIMEOUT: ${{ inputs.cosign-retry-timeout }}
118115
RETRY_COUNT: ${{ inputs.cosign-retries }}
119116
RETRY_ARGS: --verbose
117+
IMAGE_REPOSITORY_DIGEST: ${{ steps.push.outputs.IMAGE_REPOSITORY_DIGEST }}
120118
IMAGE_MANIFEST_TAG: ${{ inputs.image-manifest-tag }}
121119
IMAGE_REPOSITORY: ${{ inputs.image-repository }}
122120
REGISTRY_URI: ${{ inputs.image-registry-uri }}
123121
run: |
124122
set -euo pipefail
125123
126124
# Extract the digest from the image repo digest (right side of '@')
127-
DIGEST=${IMAGE_REPO_DIGEST#*@}
125+
DIGEST=${IMAGE_REPOSITORY_DIGEST#*@}
128126
129127
# URL encode the digest and image repository, needed for the purl
130128
URLENCODED_DIGEST=$(jq -rn --arg input "$DIGEST" '$input | @uri')
@@ -143,16 +141,16 @@ runs:
143141
144142
# Get metadata from the image
145143
# NOTE (@Techassi): Maybe we should run this command only once
146-
IMAGE_METADATA_DESCRIPTION=$(docker inspect --format='{{.Config.Labels.description}}' "$IMAGE_REPO_DIGEST")
147-
IMAGE_METADATA_NAME=$(docker inspect --format='{{.Config.Labels.name}}' "$IMAGE_REPO_DIGEST")
144+
IMAGE_METADATA_DESCRIPTION=$(docker inspect --format='{{.Config.Labels.description}}' "$IMAGE_REPOSITORY_DIGEST")
145+
IMAGE_METADATA_NAME=$(docker inspect --format='{{.Config.Labels.name}}' "$IMAGE_REPOSITORY_DIGEST")
148146
149147
# Generate the SBOM
150148
syft scan \
151149
--output cyclonedx-json@1.5=sbom_raw.json \
152150
--select-catalogers "-cargo-auditable-binary-cataloger,+sbom-cataloger" \
153151
--scope all-layers \
154152
--source-name "$SOURCE_NAME" \
155-
--source-version "$IMAGE_MANIFEST_TAG" "$IMAGE_REPO_DIGEST"
153+
--source-version "$IMAGE_MANIFEST_TAG" "$IMAGE_REPOSITORY_DIGEST"
156154
157155
# Merge SBOM components using https://github.com/stackabletech/mergebom
158156
curl --fail -L -o mergebom https://repo.stackable.tech/repository/packages/mergebom/stable-$(uname -m)
@@ -194,4 +192,4 @@ runs:
194192
--yes \
195193
--predicate sbom.merged.json \
196194
--type cyclonedx \
197-
"${IMAGE_REPO_DIGEST}"
195+
"${IMAGE_REPOSITORY_DIGEST}"

run-pre-commit/action.yaml

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -78,21 +78,22 @@ runs:
7878
key: pre-commit-${{ inputs.pre-commit-version }}-python${{ inputs.python-version }}-${{ hashFiles('.pre-commit-config.yaml') }}
7979

8080
- name: Format Rust Toolchain Cache Key
81+
id: rust-toolchain-cache-key
8182
if: ${{ inputs.rust }}
8283
shell: bash
8384
env:
8485
RUST_COMPONENTS: ${{ inputs.rust-components }}
8586
run: |
8687
RUST_COMPONENTS=${RUST_COMPONENTS//,/_}
87-
echo "RUST_COMPONENTS=$RUST_COMPONENTS" | tee -a "$GITHUB_ENV"
88+
echo "RUST_COMPONENTS=$RUST_COMPONENTS" | tee -a "$GITHUB_OUTPUT"
8889
8990
- name: Setup Rust Toolchain Cache
9091
id: rust-toolchain-cache
9192
if: ${{ inputs.rust }}
9293
uses: actions/cache@9255dc7a253b0ccc959486e2bca901246202afeb # v5.0.1
9394
with:
9495
path: ~/.rustup/toolchains
95-
key: rust-toolchains-${{ inputs.rust }}-components-${{ env.RUST_COMPONENTS }}
96+
key: rust-toolchains-${{ inputs.rust }}-components-${{ steps.rust-toolchain-cache-key.outputs.RUST_COMPONENTS }}
9697

9798
- name: Setup Rust Toolchain
9899
uses: dtolnay/rust-toolchain@f7ccc83f9ed1e5b9c81d8a67d7ad1a747e22a561
@@ -110,7 +111,7 @@ runs:
110111
shell: bash
111112
env:
112113
HADOLINT_VERSION: ${{ inputs.hadolint }}
113-
run: |
114+
run: | # zizmor: ignore[github-env] Using GITHUB_PATH is fine here, because we set it to a known static path.
114115
set -euo pipefail
115116
116117
LOCATION_DIR="$HOME/.local/bin"

run-prek/action.yaml

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -62,21 +62,22 @@ runs:
6262
key: prek-${{ inputs.prek-version }}-${{ hashFiles('.pre-commit-config.yaml') }}
6363

6464
- name: Format Rust Toolchain Cache Key
65+
id: rust-toolchain-cache-key
6566
if: ${{ inputs.rust }}
6667
shell: bash
6768
env:
6869
RUST_COMPONENTS: ${{ inputs.rust-components }}
6970
run: |
7071
RUST_COMPONENTS=${RUST_COMPONENTS//,/_}
71-
echo "RUST_COMPONENTS=$RUST_COMPONENTS" | tee -a "$GITHUB_ENV"
72+
echo "RUST_COMPONENTS=$RUST_COMPONENTS" | tee -a "$GITHUB_OUTPUT"
7273
7374
- name: Setup Rust Toolchain Cache
7475
id: rust-toolchain-cache
7576
if: ${{ inputs.rust }}
7677
uses: actions/cache@9255dc7a253b0ccc959486e2bca901246202afeb # v5.0.1
7778
with:
7879
path: ~/.rustup/toolchains
79-
key: rust-toolchains-${{ inputs.rust }}-components-${{ env.RUST_COMPONENTS }}
80+
key: rust-toolchains-${{ inputs.rust }}-components-${{ steps.rust-toolchain-cache-key.outputs.RUST_COMPONENTS }}
8081

8182
- name: Setup Rust Toolchain
8283
uses: dtolnay/rust-toolchain@f7ccc83f9ed1e5b9c81d8a67d7ad1a747e22a561
@@ -95,7 +96,7 @@ runs:
9596
shell: bash
9697
env:
9798
HADOLINT_VERSION: ${{ inputs.hadolint }}
98-
run: |
99+
run: | # zizmor: ignore[github-env] Using GITHUB_PATH is fine here, because the path is not user-controlled.
99100
set -euo pipefail
100101
101102
LOCATION_DIR="$HOME/.local/bin"

0 commit comments

Comments
 (0)