Skip to content

Commit

Permalink
Merge pull request #61 from betadots/updates
Browse files Browse the repository at this point in the history
feat: Update CI, add jq
  • Loading branch information
bastelfreak authored Aug 23, 2024
2 parents 44ddca9 + 89fdfb0 commit 5148897
Show file tree
Hide file tree
Showing 2 changed files with 52 additions and 10 deletions.
61 changes: 51 additions & 10 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,40 +2,81 @@
name: QA🚦

on:
pull_request: {}
push:
pull_request:
branches:
- main
workflow_dispatch:

jobs:
setup-matrix:
runs-on: ubuntu-latest
outputs:
matrix: ${{ steps.set-matrix.outputs.matrix }}
steps:
- name: Source checkout
uses: actions/checkout@v4

- id: set-matrix
run: echo "matrix=$(jq -c . build_versions.json)" >> $GITHUB_OUTPUT

build_test_container:
name: 'Build test container'
runs-on: ubuntu-latest
permissions:
actions: read
contents: read
security-events: write
pull-requests: write
needs: setup-matrix
strategy:
matrix: ${{ fromJson(needs.setup-matrix.outputs.matrix) }}
steps:
- name: Checkout repository
uses: actions/checkout@v4

- name: Build Docker image
uses: docker/build-push-action@v6
with:
tags: 'ci/pdc:${{ github.sha }}'
tags: 'ci/pdc:${{ matrix.puppet_release }}'
push: false
build-args: |
PUPPET_RELEASE=${{ matrix.puppet_release }}
PUPPET_VERSION=${{ matrix.puppet_version }}
TERRAFORM_VERSION=${{ matrix.terraform_version }}
PDK_VERSION=${{ matrix.pdk_version }}
BOLT_VERSION=${{ matrix.bolt_version }}
PUPPETDB_TERMINI_VERSION=${{ matrix.puppetdb_termini_version }}
- name: Login to Docker Hub
uses: docker/login-action@v3
with:
username: ${{ vars.DOCKERHUB_USER }}
password: ${{ secrets.DOCKERHUB_TOKEN }}

- name: Analyze container image for CVEs
id: analyze-image-cves
uses: docker/scout-action@v1
with:
command: cves
image: 'local://ci/pdc:${{ matrix.puppet_release }}'
sarif-file: sarif.output.${{ matrix.puppet_release }}.${{ github.sha }}.json
write-comment: false

- name: Run Trivy vulnerability scanner
uses: aquasecurity/trivy-action@master
- name: Compare container image to latest from Registry
id: compare-image
uses: docker/scout-action@v1
with:
image-ref: 'ci/pdc:${{ github.sha }}'
format: 'sarif'
output: 'trivy-results.sarif'
command: compare
image: 'local://ci/pdc:${{ matrix.puppet_release }}'
to: 'ghcr.io/betadots/pdc:latest-${{ matrix.puppet_release }}'
summary: true
keep-previous-comments: true

- name: Upload Trivy scan results to GitHub Security tab
- name: Upload SARIF result
id: upload-sarif
uses: github/codeql-action/upload-sarif@v3
with:
sarif_file: 'trivy-results.sarif'
sarif_file: sarif.output.${{ matrix.puppet_release }}.${{ github.sha }}.json

tests:
needs:
Expand Down
1 change: 1 addition & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ RUN apt update && apt upgrade -y && apt install -y --no-install-recommends \
puppetdb-termini=${PUPPETDB_TERMINI_VERSION}-1${UBUNTU_CODENAME} \
unzip \
yamllint \
jq \
&& apt autoremove -y \
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/* \
Expand Down

0 comments on commit 5148897

Please sign in to comment.