Skip to content

Commit

Permalink
fix(ci): Authenticate Trivy correctly for ephemeral build (#4227)
Browse files Browse the repository at this point in the history
  • Loading branch information
khvn26 authored Jun 25, 2024
1 parent fe7cc53 commit b9a6f92
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions .github/workflows/.reusable-docker-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -111,9 +111,13 @@ jobs:
steps.build.outputs.build-id) || format('{0}/flagsmith/{1}:{2}', inputs.registry-url, inputs.image-name,
steps.meta.outputs.version) }} >> $GITHUB_OUTPUT
- name: Login to Depot Registry
- name: Render Depot token
id: depot-token
if: inputs.scan && inputs.ephemeral
run: depot pull-token | docker login -u x-token --password-stdin registry.depot.dev
run: |
export DEPOT_TOKEN=$(depot pull-token)
echo ::add-mask::$DEPOT_TOKEN
echo depot-token=$DEPOT_TOKEN >> $GITHUB_OUTPUT
- name: Run Trivy vulnerability scanner
id: trivy
Expand All @@ -124,8 +128,8 @@ jobs:
format: sarif
output: trivy-results.sarif
env:
TRIVY_USERNAME: ${{ github.actor }}
TRIVY_PASSWORD: ${{ secrets.GITHUB_TOKEN }}
TRIVY_USERNAME: ${{ inputs.ephemeral && 'x-token' || github.actor }}
TRIVY_PASSWORD: ${{ inputs.ephemeral && steps.depot-token.outputs.depot-token || secrets.GITHUB_TOKEN }}

- name: Upload Trivy scan results to GitHub Security tab
uses: github/codeql-action/upload-sarif@v2
Expand Down

0 comments on commit b9a6f92

Please sign in to comment.