Feature/integrate docker scout with git hub actions #4
Workflow file for this run
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Vulnerability Comparison | |
on: | |
pull_request: | |
branches: ["**"] | |
env: | |
# Image repository, without hostname and tag | |
REGISTRY: docker.io | |
IMAGE_NAME: "gatewaydio/gatewayd" | |
SHA: ${{ github.event.pull_request.head.sha || github.event.after }} | |
COMPARE_TAG: latest | |
jobs: | |
vulnerability-comparison: | |
runs-on: ubuntu-latest | |
permissions: | |
contents: read | |
packages: write | |
pull-requests: write | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v4 | |
with: | |
ref: ${{ env.SHA }} | |
- name: Set short SHA | |
id: vars | |
run: echo "SHA_SHORT=$(echo $GITHUB_SHA | cut -c1-7)" >> $GITHUB_ENV | |
- name: Set up QEMU | |
uses: docker/setup-qemu-action@v3 | |
- name: Set up Docker Buildx | |
uses: docker/setup-buildx-action@v3 | |
- name: Login to Docker Hub | |
uses: docker/login-action@v3 | |
with: | |
registry: ${{ env.REGISTRY }} | |
username: ${{ secrets.DOCKERHUB_USERNAME }} | |
password: ${{ secrets.DOCKERHUB_TOKEN }} | |
- name: Build and push Docker image | |
uses: docker/build-push-action@v5 | |
with: | |
context: . | |
push: false | |
load: ${{ github.event_name == 'pull_request' }} | |
tags: "${{ env.IMAGE_NAME }}:${{ env.SHA_SHORT }}" | |
cache-from: type=gha | |
cache-to: type=gha,mode=max | |
- name: Docker Scout | |
id: docker-scout | |
uses: docker/scout-action@v1 | |
with: | |
command: compare | |
image: "${{ env.IMAGE_NAME }}:${{ env.COMPARE_TAG }}" | |
to: "${{ env.IMAGE_NAME }}:${{ env.SHA_SHORT }}" | |
ignore-unchanged: true | |
only-severities: critical,high | |
github-token: ${{ secrets.GITHUB_TOKEN }} |