Skip to content

Bump aquasecurity/trivy-action from 0.14.0 to 0.15.0 #117

Bump aquasecurity/trivy-action from 0.14.0 to 0.15.0

Bump aquasecurity/trivy-action from 0.14.0 to 0.15.0 #117

Workflow file for this run

name: Build and deploy nais-verification
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
on:
push:
paths-ignore:
- hack/**
- "*.md"
env:
cache_image: ghcr.io/${{ github.repository }}/cache
GOOGLE_REGISTRY: "europe-north1-docker.pkg.dev"
jobs:
version:
name: Version
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@8f4b7f84864484a7bf31766abe9204da3cbe65b3 # ratchet:actions/checkout@v3
- name: Generate image environment variable
id: set-image-tag
run: |
version="$(date +%Y%m%d%H%M%S)-$(git describe --always --dirty --exclude '*')"
echo "version=${version}" >> $GITHUB_OUTPUT
outputs:
version: ${{ steps.set-image-tag.outputs.version }}
build:
name: Build and push
runs-on: ubuntu-latest
needs:
- version
permissions:
contents: read
packages: write
id-token: write
strategy:
matrix:
image_base:
- ghcr.io/${{ github.repository }}
- europe-north1-docker.pkg.dev/nais-io/nais/images/nais-verification # For some reason ${{ env.GOOGLE_REGISTRY }} doesn't work here
steps:
- uses: actions/checkout@8f4b7f84864484a7bf31766abe9204da3cbe65b3 # ratchet:actions/checkout@v3
- name: Install cosign
uses: sigstore/cosign-installer@1fc5bd396d372bee37d608f955b336615edf79c8 # ratchet:sigstore/cosign-installer@main
with:
cosign-release: 'v2.2.1'
- id: "auth"
if: github.ref == 'refs/heads/main'
name: "Authenticate to Google Cloud"
uses: "google-github-actions/[email protected]" # 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@343f7c4344506bcbf9b4de18042ae17996df046d # ratchet:docker/login-action@v2
with:
registry: ${{ env.GOOGLE_REGISTRY }}
username: "oauth2accesstoken"
password: "${{ steps.auth.outputs.access_token }}"
- name: Login to GitHub Packages Docker Registry
uses: docker/login-action@343f7c4344506bcbf9b4de18042ae17996df046d # ratchet:docker/login-action@v2
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: "Pull latest image so it exists locally and can be used by cache :crossed_fingers:"
run: docker pull "${{ matrix.image_base }}:latest"
continue-on-error: true
- name: Install earthly
uses: earthly/actions-setup@be3fe0c1f84e9776b5a184d21bf7a4a779ea2e6b # ratchet:earthly/actions-setup@v1
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
- name: Build and possibly push
env:
EARTHLY_PUSH: "${{ github.ref == 'refs/heads/main' }}"
EARTHLY_USE_INLINE_CACHE: true
EARTHLY_SAVE_INLINE_CACHE: true
EARTHLY_VERBOSE: true
EARTHLY_FULL_TARGET: true
EARTHLY_OUTPUT: true
run: |
earthly "--remote-cache=${cache_image}" +docker "--IMAGE_BASE=${{ matrix.image_base }}" "--VERSION=${{ needs.version.outputs.version }}"
- name: Retrieve image digest
id: imgdigest
if: github.ref == 'refs/heads/main'
run: |
docker pull "${{ matrix.image_base }}:${{ needs.version.outputs.version }}"
echo "digest=$(docker inspect ${{ matrix.image_base }}:${{ needs.version.outputs.version }} | 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@22d2755f774d925b191a185b74e782a4b0638a41 # 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 }}
chart:
permissions:
contents: 'read'
id-token: 'write'
name: Build and push chart
runs-on: ubuntu-latest
needs:
- version
steps:
- uses: actions/checkout@c85c95e3d7251135ab7dc9ce3241c5835cc595a9 # ratchet:actions/checkout@v3
- id: 'auth'
name: 'Authenticate to Google Cloud'
uses: 'google-github-actions/auth@f105ef0cdb3b102a020be1767fcc8a974898b7c6' # 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: 'Set up Cloud SDK'
uses: 'google-github-actions/setup-gcloud@e30db14379863a8c79331b04a9969f4c1e225e0b' # ratchet:google-github-actions/setup-gcloud@v1
- name: 'Log in to Google Artifact Registry'
run: |-
echo '${{ steps.auth.outputs.access_token }}' | docker login -u oauth2accesstoken --password-stdin https://${{ env.GOOGLE_REGISTRY }}
- uses: azure/setup-helm@5119fcb9089d432beecbf79bb2c7915207344b78 # ratchet:azure/setup-helm@v3
name: 'Setup Helm'
with:
version: '3.8.0'
- name: Set versions
run: |-
for chart in charts/*; do
yq e '.version = "${{ needs.version.outputs.version }}"' --inplace "${chart}/Chart.yaml"
yq e '.image.tag = "${{ needs.version.outputs.version }}"' --inplace "${chart}/values.yaml"
done
- name: Build Chart
run: |-
for chart in charts/*; do
helm package "$chart"
done
- name: Push Chart
run: |-
for chart in *.tgz; do
helm push "$chart" oci://${{ env.GOOGLE_REGISTRY }}/nais-io/nais/feature
done
rollout:
name: Rollout
if: github.actor != 'dependabot[bot]' && github.ref == 'refs/heads/main'
needs:
- version
- build
- chart
runs-on: fasit-deploy
permissions:
id-token: write
steps:
- uses: nais/fasit-deploy@badff0705af8a57bcf0ab172895273da09ae5959 # ratchet:nais/fasit-deploy@v2
with:
chart: oci://${{ env.GOOGLE_REGISTRY }}/nais-io/nais/feature/nais-verification
version: ${{ needs.version.outputs.version }}
feature_name: nais-verification