|
| 1 | +--- |
| 2 | +name: docker-scout |
| 3 | +on: |
| 4 | + workflow_call: |
| 5 | + inputs: |
| 6 | + IMAGES: |
| 7 | + description: 'Dockerhub repository name' |
| 8 | + required: true |
| 9 | + type: string |
| 10 | + IMAGE_TAG: |
| 11 | + description: 'Image tag for latest docker image' |
| 12 | + type: string |
| 13 | + default: latest |
| 14 | + COMPARE_TAG: |
| 15 | + description: 'provide the tag of the image you like to compare with' |
| 16 | + required: true |
| 17 | + type: string |
| 18 | + # Filter flags |
| 19 | + IGNORE-BASE: |
| 20 | + description: 'Ignore vulnerabilities from base image' |
| 21 | + default: false |
| 22 | + type: string |
| 23 | + IGNORE-UNCHANGED: |
| 24 | + description: 'Filter out unchanged packages' |
| 25 | + default: true |
| 26 | + type: string |
| 27 | + ONLY-FIXED: |
| 28 | + description: 'Filter to fixable CVEs' |
| 29 | + default: false |
| 30 | + type: string |
| 31 | + WRITE-COMMENT: |
| 32 | + description: 'Write the output as a Pull Request comment' |
| 33 | + default: true |
| 34 | + type: string |
| 35 | + secrets: |
| 36 | + DOCKERHUB_USERNAME: |
| 37 | + description: 'dockerhub username' |
| 38 | + required: true |
| 39 | + DOCKERHUB_PASSWORD: |
| 40 | + description: 'dockerhub password' |
| 41 | + required: true |
| 42 | + TOKEN: |
| 43 | + description: 'Github Token' |
| 44 | + required: true |
| 45 | + |
| 46 | +jobs: |
| 47 | + docker-scout: |
| 48 | + runs-on: ubuntu-latest |
| 49 | + |
| 50 | + steps: |
| 51 | + - name: Checkout git repo |
| 52 | + uses: actions/checkout@v4 |
| 53 | + |
| 54 | + - name: Setup Docker buildx |
| 55 | + |
| 56 | + with: |
| 57 | + driver-opts: | |
| 58 | + image=moby/buildkit:v0.10.6 |
| 59 | +
|
| 60 | + - name: Login to Docker Hub |
| 61 | + uses: docker/login-action@v3 |
| 62 | + with: |
| 63 | + username: ${{ secrets.DOCKERHUB_USERNAME }} |
| 64 | + password: ${{ secrets.DOCKERHUB_PASSWORD }} |
| 65 | + |
| 66 | + - name: Build docker image |
| 67 | + env: |
| 68 | + IMAGE_TAG: ${{ inputs.IMAGE_TAG }} |
| 69 | + images: ${{ inputs.IMAGES }} |
| 70 | + run: | |
| 71 | + docker build -t $images:$IMAGE_TAG . |
| 72 | + # docker push $images:$IMAGE_TAG |
| 73 | +
|
| 74 | + - name: Docker Scout |
| 75 | + id: docker-scout |
| 76 | + uses: docker/scout-action@v1 |
| 77 | + with: |
| 78 | + command: cves,recommendations,compare |
| 79 | + to-latest: false |
| 80 | + to: ${{ inputs.IMAGES }}:${{ inputs.COMPARE_TAG }} |
| 81 | + image: ${{ inputs.IMAGES }}:${{ inputs.IMAGE_TAG }} |
| 82 | + ignore-base: ${{ inputs.IGNORE-BASE }} |
| 83 | + ignore-unchanged: ${{ inputs.IGNORE-BASE }} |
| 84 | + only-fixed: ${{ inputs.ONLY-FIXED }} |
| 85 | + write-comment: ${{ inputs.WRITE-COMMENT }} |
| 86 | + github-token: ${{ secrets.TOKEN }} |
| 87 | +... |
0 commit comments