Skip to content
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

chore: encode gh actions outputs #218

Merged
merged 1 commit into from
Oct 23, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 17 additions & 12 deletions .github/workflows/release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@ on:
push:
tags:
- 'v*' # Push events to matching v*, i.e. v1.0, v20.15.10
env:
PROD_REGISTRY: registry.rancher.com/rancher

permissions:
contents: write # Allow to create a release.
Expand Down Expand Up @@ -94,15 +92,17 @@ jobs:
env:
COSIGN_EXPERIMENTAL: 1
run: |
cosign sign --yes ${{ matrix.images.image }}
image=$(echo ${{ matrix.images.image }} | base64 -d | base64 -d)
cosign sign --yes ${image}
- name: Verify pushed ghcr images
env:
COSIGN_EXPERIMENTAL: 1
run: |
cosign verify ${{ matrix.images.image }} --certificate-identity=https://github.com/rancher-sandbox/rancher-turtles/.github/workflows/release.yaml@refs/tags/${{ env.TAG }} --certificate-oidc-issuer=https://token.actions.githubusercontent.com
image=$(echo ${{ matrix.images.image }} | base64 -d | base64 -d)
cosign verify ${image} --certificate-identity=https://github.com/rancher-sandbox/rancher-turtles/.github/workflows/release.yaml@refs/tags/${{ env.TAG }} --certificate-oidc-issuer=https://token.actions.githubusercontent.com

ghcr-provenance:
needs: [build-ghcr, ghcr-sign]
needs: [ghcr-sign]
permissions:
actions: read
id-token: write
Expand All @@ -129,8 +129,8 @@ jobs:
]
uses: slsa-framework/slsa-github-generator/.github/workflows/generator_container_slsa3.yml@v1.9.0
with:
image: ${{ matrix.images.image }}
digest: ${{ matrix.images.digest }}
image: $(echo ${{ matrix.images.image }} | base64 -d | base64 -d)
digest: $(echo ${{ matrix.images.digest }} | base64 -d | base64 -d)
secrets:
registry-username: ${{ github.actor }}
registry-password: ${{ secrets.GITHUB_TOKEN }}
Expand All @@ -151,6 +151,7 @@ jobs:
s390x_digest: ${{ steps.prod-images.outputs.s390x_digest }}
env:
TAG: ${{ github.ref_name }}
PROD_REGISTRY: ${{ secrets.REGISTRY_ENDPOINT }}
PROD_USERNAME: ${{ secrets.REGISTRY_USERNAME }}
PROD_PASSWORD: ${{ secrets.REGISTRY_PASSWORD }}
PROD_ORG: rancher-sandbox
Expand Down Expand Up @@ -202,6 +203,7 @@ jobs:
]
env:
TAG: ${{ github.ref_name }}
PROD_REGISTRY: ${{ secrets.REGISTRY_ENDPOINT }}
PROD_USERNAME: ${{ secrets.REGISTRY_USERNAME }}
PROD_PASSWORD: ${{ secrets.REGISTRY_PASSWORD }}
steps:
Expand All @@ -216,15 +218,17 @@ jobs:
env:
COSIGN_EXPERIMENTAL: 1
run: |
cosign sign --yes ${{ matrix.images.image }}
image=$(echo ${{ matrix.images.image }} | base64 -d | base64 -d)
cosign sign --yes ${image}
- name: Verify pushed ghcr images
env:
COSIGN_EXPERIMENTAL: 1
run: |
cosign verify ${{ matrix.images.image }} --certificate-identity=https://github.com/rancher-sandbox/rancher-turtles/.github/workflows/release.yaml@refs/tags/${{ env.TAG }} --certificate-oidc-issuer=https://token.actions.githubusercontent.com
image=$(echo ${{ matrix.images.image }} | base64 -d | base64 -d)
cosign verify ${image} --certificate-identity=https://github.com/rancher-sandbox/rancher-turtles/.github/workflows/release.yaml@refs/tags/${{ env.TAG }} --certificate-oidc-issuer=https://token.actions.githubusercontent.com

prod-provenance:
needs: [build-prod, prod-sign]
needs: [prod-sign]
permissions:
actions: read
id-token: write
Expand All @@ -251,8 +255,8 @@ jobs:
]
uses: slsa-framework/slsa-github-generator/.github/workflows/generator_container_slsa3.yml@v1.9.0
with:
image: ${{ matrix.images.image }}
digest: ${{ matrix.images.digest }}
image: $(echo ${{ matrix.images.image }} | base64 -d | base64 -d)
digest: $(echo ${{ matrix.images.digest }} | base64 -d | base64 -d)
secrets:
registry-username: ${{ secrets.REGISTRY_USERNAME }}
registry-password: ${{ secrets.REGISTRY_PASSWORD }}
Expand All @@ -263,6 +267,7 @@ jobs:
runs-on: ubuntu-latest
env:
TAG: ${{ github.ref_name }}
PROD_REGISTRY: ${{ secrets.REGISTRY_ENDPOINT }}
PROD_ORG: rancher-sandbox
RELEASE_DIR: .cr-release-packages
CR_TOKEN: "${{ secrets.GITHUB_TOKEN }}"
Expand Down
9 changes: 6 additions & 3 deletions scripts/image-digest.sh
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,12 @@ for line in $output; do
# Run the Docker command and get the digest
digest=$(docker buildx imagetools inspect "$line" --format '{{json .}}' | jq -r .manifest.digest)

# Add image name and digest to the output
echo "${githubimageoutput[$line_count]}=$line" >> "$GITHUB_OUTPUT"
echo "${githubdigestoutput[$line_count]}=$digest" >> "$GITHUB_OUTPUT"
# Add encoded image name to the output
image_output=$(echo -n "$line" | base64 -w0 | base64 -w0)
echo "${githubimageoutput[$line_count]}=${image_output}" >> "$GITHUB_OUTPUT"
# Add encoded digest to the output
digest_output=$(echo -n "$digest" | base64 -w0 | base64 -w0)
echo "${githubdigestoutput[$line_count]}=${digest_output}" >> "$GITHUB_OUTPUT"

# Increment the line counter
line_count=$((line_count + 1))
Expand Down