Skip to content

Merge pull request #24 from ThomasVitale/dependabot/github_actions/gi… #66

Merge pull request #24 from ThomasVitale/dependabot/github_actions/gi…

Merge pull request #24 from ThomasVitale/dependabot/github_actions/gi… #66

Workflow file for this run

name: Commit Stage
on:
push:
branches:
- main
paths-ignore:
- '.editorconfig'
- '.gitignore'
- '.sdkmanrc'
- '*.adoc'
- '*.png'
- '*.md'
- 'docs/**'
- '.github/ISSUE_TEMPLATE/**'
- '.github/*.md'
- '.github/*.yml'
- '.github/*.yaml'
env:
REGISTRY: ghcr.io
IMAGE_NAME: thomasvitale/policy-demo
VERSION: ${{ github.sha }}
permissions:
contents: read
jobs:
build:
name: Build
runs-on: ubuntu-24.04
permissions:
contents: read
packages: write
security-events: write
steps:
- name: Check out source code
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
with:
fetch-depth: 0
- name: Set up Java
uses: actions/setup-java@8df1039502a15bceb9433410b1a100fbe190c53b # v4.5.0
with:
java-version: 23
distribution: 'graalvm'
- name: Setup Gradle
uses: gradle/actions/setup-gradle@cc4fc85e6b35bafd578d5ffbc76a5518407e1af0 # v4.2.1
- name: Compile and test
run: |
cd policies/gradle
./gradlew clean build
- name: SBOM vulnerability scanning
uses: aquasecurity/trivy-action@18f2510ee396bbf400402947b394f2dd8c87dbb0 # master
with:
scan-type: 'sbom'
scan-ref: 'policies/gradle/build/reports/application.cdx.json'
format: 'sarif'
output: 'trivy-results-build.sarif'
- name: Upload vulnerability report
uses: github/codeql-action/upload-sarif@babb554ede22fd5605947329c4d04d8e7a0b8155 # v3.27.7
if: success() || failure()
with:
sarif_file: 'trivy-results-build.sarif'
category: build
- name: Package as OCI image
run: |
cd policies/gradle
./gradlew bootBuildImage --imageName ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ env.VERSION }}
- name: Authenticate with the container registry
uses: docker/login-action@9780b0c442fbb1117ed29e0efdff1e18412f7567 # v3.3.0
with:
username: ${{ github.actor }}
password: ${{ secrets.IMAGE_PUSH_TOKEN }}
registry: ${{ env.REGISTRY }}
- name: Publish OCI image
run: |
docker tag ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ env.VERSION }} ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:latest
docker push ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ env.VERSION }}
docker push ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:latest
sign:
name: Sign
runs-on: ubuntu-24.04
needs: [ build ]
permissions:
contents: read
packages: write
id-token: write
outputs:
image-digest: ${{ steps.image-info.outputs.digest }}
image-name: ${{ steps.image-info.outputs.name }}
steps:
- name: Install Cosign
uses: sigstore/cosign-installer@dc72c7d5c4d10cd6bcb8cf6e3fd625a9e5e537da # v3.7.0
- uses: redhat-actions/podman-login@4934294ad0449894bcd1e9f191899d7292469603 # v1.7
with:
username: ${{ github.actor }}
password: ${{ secrets.IMAGE_PUSH_TOKEN }}
registry: ${{ env.REGISTRY }}
- name: Fetch OCI image
run: podman pull ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ env.VERSION }}
- name: Get OCI image digest
id: image-info
run: |
image_digest=$(podman inspect --format='{{.Digest}}' ${REGISTRY}/${IMAGE_NAME}:${VERSION})
echo $image_digest
echo "IMAGE_DIGEST=${image_digest}" >> $GITHUB_ENV
echo "digest=${image_digest}" >> $GITHUB_OUTPUT
echo "name=${REGISTRY}/${IMAGE_NAME}" >> $GITHUB_OUTPUT
- name: Sign image
run: |
cosign sign --yes "${REGISTRY}/${IMAGE_NAME}@${IMAGE_DIGEST}"
provenance:
needs: [ sign ]
permissions:
actions: read
id-token: write
packages: write
uses: slsa-framework/slsa-github-generator/.github/workflows/generator_container_slsa3.yml@v2.0.0
with:
image: ${{ needs.sign.outputs.image-name }}
digest: ${{ needs.sign.outputs.image-digest }}
registry-username: ${{ github.actor }}
secrets:
registry-password: ${{ secrets.IMAGE_PUSH_TOKEN }}