Skip to content

Commit

Permalink
Merge pull request #7 from aneisch/sbom
Browse files Browse the repository at this point in the history
SBOM
  • Loading branch information
aneisch authored Jul 23, 2024
2 parents 81fc822 + 4794ee0 commit d045fd8
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 16 deletions.
36 changes: 21 additions & 15 deletions .github/workflows/docker-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,15 @@ jobs:
steps:
- uses: actions/checkout@v4

- name: Run Trivy in GitHub SBOM mode and submit results to Dependency Graph
uses: aquasecurity/[email protected]
with:
scan-type: 'fs'
format: 'github'
output: 'dependency-results.sbom.json'
image-ref: '.'
github-pat: ${{ secrets.GITHUB_TOKEN }}

- name: Attempt Build
run: docker build . --file Dockerfile -t $IMAGE_NAME

Expand All @@ -37,21 +46,18 @@ jobs:
- name: Log into Registry
run: echo "${{ secrets.GITHUB_TOKEN }}" | docker login ghcr.io -u ${{ github.actor }} --password-stdin

- name: Push Image
run: |
IMAGE_ID=ghcr.io/aneisch/${{ env.IMAGE_NAME }}
# Change all uppercase to lowercase
IMAGE_ID=$(echo $IMAGE_ID | tr '[A-Z]' '[a-z]')
# Strip git ref prefix from version
VERSION=$(echo "${{ github.ref }}" | sed -e 's,.*/\(.*\),\1,')
# Strip "v" prefix from tag name
[[ "${{ github.ref }}" == "refs/tags/"* ]] && VERSION=$(echo $VERSION | sed -e 's/^v//')
# Use Docker `latest` tag convention
[ "$VERSION" == "master" ] && VERSION=latest
echo IMAGE_ID=$IMAGE_ID
echo VERSION=$VERSION
docker tag $IMAGE_NAME $IMAGE_ID:$VERSION
docker push $IMAGE_ID:$VERSION
- name: Build and push container image
id: push-step
uses: docker/build-push-action@master
with:
push: true
tags: ghcr.io/aneisch/${{ env.IMAGE_NAME }}:latest

- name: Install cosign
uses: sigstore/cosign-installer@main

- name: Sign the container image
run: cosign sign --yes ghcr.io/aneisch/${{ env.IMAGE_NAME }}@${{ steps.push-step.outputs.digest }}

build_multiarch:
runs-on: ubuntu-latest
Expand Down
1 change: 0 additions & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ RUN apk add --no-cache --update curl && \
pip cache purge && \
pip uninstall -y wheel setuptools pip && \
adduser -D thermostat_api && \
apk list -I && \
apk --purge del apk-tools

USER thermostat_api
Expand Down

0 comments on commit d045fd8

Please sign in to comment.