Skip to content

Commit

Permalink
Merge pull request #218 from salasberryfin/encrypt-secret-outputs
Browse files Browse the repository at this point in the history
chore: encode gh actions outputs
  • Loading branch information
salasberryfin committed Oct 23, 2023
2 parents 15c1a00 + dde8940 commit fc55866
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 15 deletions.
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

0 comments on commit fc55866

Please sign in to comment.