Skip to content

Commit

Permalink
feat: Sign Atlantis containers before release (bonus points: speed up…
Browse files Browse the repository at this point in the history
… x86 builds) (runatlantis#5207)

Signed-off-by: Dan Urson <[email protected]>
Signed-off-by: Rui Chen <[email protected]>
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: Rui Chen <[email protected]>
Signed-off-by: Lukas Peter Aldershaab <[email protected]>
  • Loading branch information
3 people authored and lukaspj committed Jan 8, 2025
1 parent 298da7a commit 9875d14
Showing 1 changed file with 33 additions and 4 deletions.
37 changes: 33 additions & 4 deletions .github/workflows/atlantis-image.yml
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ jobs:
strategy:
matrix:
image_type: [alpine, debian]
platform: [linux/arm64/v8, linux/amd64, linux/arm/v7]
runs-on: ubuntu-24.04
env:
# Set docker repo to either the fork or the main repo where the branch exists
Expand All @@ -69,6 +70,11 @@ jobs:
with:
dockerfile: "Dockerfile"

- name: Set up Go
uses: actions/setup-go@3041bf56c941b39c61721a86cd11f3bb1338122a # v5.2.0
with:
go-version-file: "go.mod"

- name: Set up QEMU
uses: docker/setup-qemu-action@49b3bc8e6bdd4a60e6116a5414239cba5943d3cf # v3
with:
Expand All @@ -82,6 +88,10 @@ jobs:
driver-opts: |
image=moby/buildkit:v0.14.0
- name: "Install cosign"
uses: sigstore/cosign-installer@dc72c7d5c4d10cd6bcb8cf6e3fd625a9e5e537da # v3.7.0
if: env.PUSH == 'true' && github.event_name != 'pull_request'

# release version is the name of the tag i.e. v0.10.0
# release version also has the image type appended i.e. v0.10.0-alpine
# release tag is either pre-release or latest i.e. latest
Expand Down Expand Up @@ -146,21 +156,38 @@ jobs:
ATLANTIS_VERSION=${{ env.RELEASE_VERSION }}
ATLANTIS_COMMIT=${{ fromJSON(steps.meta.outputs.json).labels['org.opencontainers.image.revision'] }}
ATLANTIS_DATE=${{ fromJSON(steps.meta.outputs.json).labels['org.opencontainers.image.created'] }}
platforms: linux/arm64/v8,linux/amd64,linux/arm/v7
platforms: ${{ matrix.platform }}
push: ${{ env.PUSH }}
tags: ${{ steps.meta.outputs.tags }}
target: ${{ matrix.image_type }}
labels: ${{ steps.meta.outputs.labels }}
outputs: type=image,name=target,annotation-index.org.opencontainers.image.description=${{ fromJSON(steps.meta.outputs.json).labels['org.opencontainers.image.description'] }}

- name: "Sign and Attest Image"
if: env.PUSH == 'true'
- name: "Create Image Attestation"
if: env.PUSH == 'true' && github.event_name != 'pull_request'
uses: actions/attest-build-provenance@7668571508540a607bdfd90a87a560489fe372eb # v2.1.0
with:
subject-digest: ${{ steps.build.outputs.digest }}
subject-name: ghcr.io/${{ github.repository }}
push-to-registry: true

- name: "Sign images with environment annotations"
# no key needed, we're using the GitHub OIDC flow
# Only run on alpine/amd64 build to avoid signing multiple times
if: env.PUSH == 'true' && github.event_name != 'pull_request' && matrix.image_type == 'alpine' && matrix.platform == 'linux/amd64'
run: |
# Sign dev tags, version tags, and latest tags
echo "${TAGS}" | xargs -I {} cosign sign \
--yes \
--recursive=true \
-a actor=${{ github.actor}} \
-a ref_name=${{ github.ref_name}} \
-a ref=${{ github.sha }} \
{}@${DIGEST}
env:
TAGS: ${{ steps.meta.outputs.tags }}
DIGEST: ${{ steps.build.outputs.digest }}

test:
needs: [changes]
if: needs.changes.outputs.should-run-build == 'true'
Expand All @@ -169,6 +196,7 @@ jobs:
strategy:
matrix:
image_type: [alpine, debian]
platform: [linux/arm64/v8, linux/amd64, linux/arm/v7]
env:
# Set docker repo to either the fork or the main repo where the branch exists
DOCKER_REPO: ghcr.io/${{ github.repository }}
Expand Down Expand Up @@ -215,4 +243,5 @@ jobs:
image_type: [alpine, debian]
runs-on: ubuntu-24.04
steps:
- run: 'echo "No build required"'
- run: 'echo "No build required"'

0 comments on commit 9875d14

Please sign in to comment.