Skip to content

Commit

Permalink
Build the glr variant alongside standard
Browse files Browse the repository at this point in the history
  • Loading branch information
rahearn committed Dec 16, 2024
1 parent 6d3f35f commit 348741a
Show file tree
Hide file tree
Showing 2 changed files with 79 additions and 4 deletions.
79 changes: 75 additions & 4 deletions .github/workflows/docker-publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,26 +5,22 @@ on:
branches: [ "main" ]
paths-ignore:
- README.md

pull_request:
branches: [ "main" ]

env:
REGISTRY: ghcr.io
IMAGE_NAME: gsa-tts/trestle


jobs:
build:

runs-on: ubuntu-latest
permissions:
contents: read
packages: write
# This is used to complete the identity challenge
# with sigstore/fulcio when running outside of PRs.
id-token: write

steps:
- name: Checkout repository
uses: actions/checkout@v4
Expand Down Expand Up @@ -94,3 +90,78 @@ jobs:
# This step uses the identity token to provision an ephemeral certificate
# against the sigstore community Fulcio instance.
run: echo "${TAGS}" | xargs -I {} cosign sign --yes {}@${DIGEST}


build-glr:
needs: build
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
# This is used to complete the identity challenge
# with sigstore/fulcio when running outside of PRs.
id-token: write
steps:
- name: Checkout repository
uses: actions/checkout@v4

# Install the cosign tool except on PR
# https://github.com/sigstore/cosign-installer
- name: Install cosign
if: github.event_name != 'pull_request'
uses: sigstore/cosign-installer@59acb6260d9c0ba8f4a2f9d9b48431a222b68e20 #v3.5.0
with:
cosign-release: 'v2.2.4'

# Set up BuildKit Docker container builder to be able to build
# multi-platform images and export cache
# https://github.com/docker/setup-buildx-action
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@f95db51fddba0c2d1ec667646a06c2ce06100226 # v3.0.0

# Login against a Docker registry except on PR
# https://github.com/docker/login-action
- name: Log into registry ${{ env.REGISTRY }}
if: github.event_name != 'pull_request'
uses: docker/login-action@343f7c4344506bcbf9b4de18042ae17996df046d # v3.0.0
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Extract Docker metadata - glr variant
id: meta-glr
uses: docker/metadata-action@96383f45573cb7f253c731d3b3ab81c87ef81934 # v5.0.0
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
flavor: latest=false
tags: |
type=raw,value={{date 'YYYYMMDD'}}-glr,priority=840
- name: Get today's date
id: today
run: echo "date=`date +'%Y%m%d'`" >> $GITHUB_OUTPUT

- name: Build and push Docker image - glr variant
id: build-and-push-glr
uses: docker/build-push-action@0565240e2d4ab88bba5387d719585280857ece09 # v5.0.0
with:
context: .
file: Dockerfile.glr
build-args: BASE_VERSION=${{ steps.today.outputs.date }}
push: ${{ github.event_name != 'pull_request' }}
tags: ${{ steps.meta-glr.outputs.tags }}
labels: ${{ steps.meta-glr.outputs.labels }}
cache-from: type=gha
cache-to: type=gha,mode=max
platforms: linux/arm64,linux/amd64

- name: Sign the published Docker image - glr
if: ${{ github.event_name != 'pull_request' }}
env:
# https://docs.github.com/en/actions/security-guides/security-hardening-for-github-actions#using-an-intermediate-environment-variable
TAGS: ${{ steps.meta-glr.outputs.tags }}
DIGEST: ${{ steps.build-and-push-glr.outputs.digest }}
# This step uses the identity token to provision an ephemeral certificate
# against the sigstore community Fulcio instance.
run: echo "${TAGS}" | xargs -I {} cosign sign --yes {}@${DIGEST}
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,10 @@ This repository contains the source code for the `ghcr.io/gsa-tts/trestle` Docke
1. [Update non-OSCAL SSP sections](#update-non-oscal-ssp-files)
1. [Render a human-readable SSPP (TODO: within a CI workflow)](#render-ssp)

### Use in a GitLab Runner

(beta) We're working on a `-glr` variant image for use within [gitlab-runner-cloudgov](https://github.com/gsa-tts/gitlab-runner-cloudgov)

### Pull down the trestle image and initialize a compliance trestle project

Prerequisite: `$(pwd)/compliance` directory exists and is where you want to store all compliance artifacts
Expand Down

0 comments on commit 348741a

Please sign in to comment.