Skip to content

Bump aquasecurity/trivy-action from 0.25.0 to 0.26.0 #233

Bump aquasecurity/trivy-action from 0.25.0 to 0.26.0

Bump aquasecurity/trivy-action from 0.25.0 to 0.26.0 #233

Workflow file for this run

name: Create docker image
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
on:
push:
env:
REGISTRY: europe-north1-docker.pkg.dev/nais-io/nais/images
IMAGE: dataproduct-topics
EARTHLY_USE_INLINE_CACHE: true
EARTHLY_SAVE_INLINE_CACHE: true
EARTHLY_VERBOSE: true
EARTHLY_FULL_TARGET: true
EARTHLY_OUTPUT: true
jobs:
build:
runs-on: ubuntu-latest
permissions:
contents: read
id-token: write
steps:
- uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # ratchet:actions/checkout@v4
- id: "auth"
if: github.ref == 'refs/heads/main'
name: "Authenticate to Google Cloud"
uses: "google-github-actions/auth@8254fb75a33b976a221574d287e93919e6a36f70" # ratchet:google-github-actions/[email protected]
with:
workload_identity_provider: ${{ secrets.NAIS_IO_WORKLOAD_IDENTITY_PROVIDER }}
service_account: "[email protected]"
token_format: "access_token"
- name: Login to Google Artifact Registry
if: github.ref == 'refs/heads/main'
uses: docker/login-action@9780b0c442fbb1117ed29e0efdff1e18412f7567 # ratchet:docker/login-action@v2
with:
registry: ${{ env.REGISTRY }}
username: "oauth2accesstoken"
password: "${{ steps.auth.outputs.access_token }}"
- name: "Set image version"
id: set-image-tag
run: |
export IMAGE_TAG="$(date +%Y%m%d%H%M%S)-$(git describe --always --dirty --exclude '*')"
echo "IMAGE_TAG=${IMAGE_TAG}" >> $GITHUB_ENV
echo "image=${REGISTRY}/${IMAGE}:${IMAGE_TAG}" >> ${GITHUB_OUTPUT}
- name: Install earthly
uses: earthly/actions-setup@43211c7a0eae5344d6d79fb4aaf209c8f8866203 # ratchet:earthly/actions-setup@v1
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
- name: Install cosign
if: github.ref == 'refs/heads/main'
uses: sigstore/cosign-installer@dc72c7d5c4d10cd6bcb8cf6e3fd625a9e5e537da # ratchet:sigstore/cosign-installer@main
with:
cosign-release: 'v2.2.1'
- name: Build and possibly push
env:
EARTHLY_PUSH: "${{ github.ref == 'refs/heads/main' }}"
run: |
earthly +docker --IMAGE_TAG=${IMAGE_TAG} --IMAGE=${REGISTRY}/${IMAGE}
- name: Retrieve image digest
id: imgdigest
if: github.ref == 'refs/heads/main'
run: |
docker pull "${REGISTRY}/${IMAGE}:${IMAGE_TAG}"
echo "digest=$(docker inspect "${REGISTRY}/${IMAGE}:${IMAGE_TAG}" | jq -r '.[].RepoDigests[0]')" >> $GITHUB_OUTPUT
- name: Sign the container image
if: github.ref == 'refs/heads/main'
run: cosign sign --yes ${{ steps.imgdigest.outputs.digest }}
- name: Create SBOM
if: github.ref == 'refs/heads/main'
uses: aquasecurity/trivy-action@a20de5420d57c4102486cdd9578b45609c99d7eb # ratchet:aquasecurity/trivy-action@master
with:
scan-type: 'image'
format: 'cyclonedx'
output: 'cyclone.sbom.json'
image-ref: ${{ steps.imgdigest.outputs.digest }}
- name: Attest image
if: github.ref == 'refs/heads/main'
run: cosign attest --yes --predicate cyclone.sbom.json --type cyclonedx ${{ steps.imgdigest.outputs.digest }}
outputs:
image: "${{ steps.set-image-tag.outputs.image }}"
deploy:
name: Deploy
runs-on: ubuntu-20.04
needs: build
if: github.ref == 'refs/heads/main'
strategy:
matrix:
cluster:
- dev-gcp
- prod-gcp
steps:
- uses: "actions/checkout@v4"
- uses: nais/deploy/actions/deploy@v1
name: Deploy to ${{ matrix.cluster }}
env:
APIKEY: ${{ secrets.NAIS_DEPLOY_APIKEY }}
CLUSTER: ${{ matrix.cluster }}
RESOURCE: nais/job.yaml
VARS: nais/vars-${{ matrix.cluster }}.yaml
VAR: image=${{ needs.build.outputs.image }},gcp_sa_json_base64=${{ secrets.GCP_SA_JSON_BASE64 }}
deploy-infra:
name: Deploy infra job
runs-on: ubuntu-20.04
needs: build
if: github.ref == 'refs/heads/main'
steps:
- uses: "actions/checkout@v4"
- uses: nais/deploy/actions/deploy@v1
name: Deploy infra job to prod-gcp
env:
APIKEY: ${{ secrets.NAIS_DEPLOY_APIKEY }}
CLUSTER: prod-gcp
RESOURCE: nais/job.yaml
VARS: nais/vars-prod-gcp-infra.yaml
VAR: image=${{ needs.build.outputs.image }},gcp_sa_json_base64=${{ secrets.GCP_SA_JSON_BASE64 }}