-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
6b668cf
commit da4cf83
Showing
6 changed files
with
89 additions
and
65 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
cradle: | ||
cabal: | ||
- path: "app/Main.hs" | ||
component: "gh-actions-docs:exe:gh-actions-docs" | ||
- path: 'app/Main.hs' | ||
component: 'gh-actions-docs:exe:gh-actions-docs' |
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
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -54,9 +54,6 @@ runs: | |
if: ${{ inputs.checkout == 'true' }} | ||
uses: actions/checkout@v4 | ||
|
||
- name: Set up Docker Buildx | ||
uses: docker/setup-buildx-action@v3 | ||
|
||
- name: Parse input and set environment variables | ||
shell: bash | ||
run: | | ||
|
@@ -65,6 +62,9 @@ runs: | |
echo "IMAGE_NAME=$IMAGE_NAME" >> "$GITHUB_ENV" | ||
echo "IMAGE_LONG_NAME=$IMAGE_NAME:${{ github.sha }}-${{ github.run_number }}" >> "$GITHUB_ENV" | ||
echo "TRIVY_SARIF=trivy.sarif" >> "$GITHUB_ENV" | ||
echo "TRIVY_IGNORE=.trivyignore" >> "$GITHUB_ENV" | ||
if [[ -z "${{ inputs.docker-build-context }}" ]]; then | ||
export DOCKER_DIR=`dirname ${{ inputs.dockerfile }}` # default to the directory of the Dockerfile | ||
else | ||
|
@@ -86,24 +86,24 @@ runs: | |
|
||
- name: Login to ACR | ||
shell: bash | ||
run: az acr login --name '${{ inputs.ACR_NAME }}' | ||
run: az acr login --name '${{ inputs.ACR_NAME }}' --expose-token | ||
|
||
- name: Build image | ||
uses: docker/build-push-action@v5 | ||
with: | ||
context: ${{ env.DOCKER_DIR }} | ||
file: ${{ inputs.dockerfile }} | ||
push: 'false' | ||
load: 'true' | ||
tags: '${{ env.IMAGE_LONG_NAME }},${{ env.IMAGE_NAME }}:latest-cache' | ||
cache-from: 'type=registry,ref=${{ env.IMAGE_NAME }}:latest-cache' | ||
cache-to: 'type=inline' | ||
- name: Build image with podman | ||
shell: bash | ||
run: | | ||
# Build image with podman | ||
podman pull '${{ env.IMAGE_NAME }}:latest-cache' || true | ||
podman build '${{ env.DOCKER_DIR }}' \ | ||
-f '${{ inputs.dockerfile }}' \ | ||
-t '${{ env.IMAGE_LONG_NAME }}' \ | ||
-t '${{ env.IMAGE_NAME }}:latest-cache' | ||
- name: Setup Trivy ignore file | ||
shell: bash | ||
run: | | ||
# Setup Trivy ignore file | ||
touch .trivyignore | ||
touch '${{ env.TRIVY_IGNORE }}' | ||
if [ -z "${{ inputs.trivy-cve-ignores }}" ]; then | ||
echo "No CVEs to ignore" | ||
|
@@ -112,42 +112,39 @@ runs: | |
echo "Ignoring CVEs: ${{ inputs.trivy-cve-ignores }}" | ||
for TRIVY_CVE in "$(echo ${{ inputs.trivy-cve-ignores }} | sed 's/,/ /g')"; do | ||
echo "$TRIVY_CVE" >> .trivyignore | ||
echo "$TRIVY_CVE" >> '${{ env.TRIVY_IGNORE }}' | ||
done | ||
- name: Run Trivy vulnerability scanner | ||
uses: aquasecurity/[email protected] | ||
with: | ||
image-ref: ${{ env.IMAGE_LONG_NAME }} | ||
exit-code: '1' | ||
format: 'table' | ||
severity: ${{ inputs.severity }} | ||
trivyignores: '.trivyignore' | ||
ignore-unfixed: true | ||
scanners: ${{ inputs.trivy-enable-secret-scanner == 'true' && 'vuln,misconfig,secret' || 'vuln,misconfig' }} | ||
skip-dirs: ${{ inputs.trivy-skip-dirs }} | ||
- name: Run Trivy vulnerability scanner (PR) | ||
shell: bash | ||
if: github.event_name == 'pull_request' | ||
run: | | ||
trivy image '${{ env.IMAGE_LONG_NAME }}' \ | ||
--format 'table' \ | ||
--exit-code '1' \ | ||
--severity '${{ inputs.severity }}' \ | ||
--ignorefile '${{ env.TRIVY_IGNORE }}' \ | ||
${{ inputs.skip-dirs != '' && format('--skip-dirs {0}', inputs.skip-dirs) || '' }} | ||
- name: Run Trivy vulnerability scanner | ||
uses: aquasecurity/[email protected] | ||
with: | ||
image-ref: ${{ env.IMAGE_LONG_NAME }} | ||
format: 'sarif' | ||
output: 'trivy.sarif' | ||
severity: ${{ inputs.severity }} | ||
trivyignores: '.trivyignore' | ||
ignore-unfixed: true | ||
scanners: ${{ inputs.trivy-enable-secret-scanner == 'true' && 'vuln,misconfig,secret' || 'vuln,misconfig' }} | ||
skip-dirs: ${{ inputs.trivy-skip-dirs }} | ||
- name: Run Trivy vulnerability scanner (push) | ||
shell: bash | ||
if: github.event_name == 'push' | ||
run: | | ||
trivy image '${{ env.IMAGE_LONG_NAME }}' \ | ||
--format 'sarif' \ | ||
--output '${{ env.TRIVY_SARIF }}' \ | ||
--exit-code '1' \ | ||
--severity '${{ inputs.severity }}' \ | ||
--ignorefile '${{ env.TRIVY_IGNORE }}' \ | ||
${{ inputs.skip-dirs != '' && format('--skip-dirs {0}', inputs.skip-dirs) || '' }} | ||
- name: Upload Trivy scan results to GitHub Security tab | ||
uses: github/codeql-action/upload-sarif@v3 | ||
if: github.event_name == 'push' && failure() | ||
with: | ||
sarif_file: trivy.sarif | ||
sarif_file: ${{ env.TRIVY_SARIF }} | ||
category: 'Trivy' | ||
if: github.event_name == 'push' && failure() | ||
|
||
- name: Push image | ||
shell: bash | ||
run: docker push '${{ env.IMAGE_NAME }}' --all-tags | ||
run: podman push '${{ env.IMAGE_NAME }}' --all-tags |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -46,16 +46,16 @@ runs: | |
echo "AVD-DS-0026" >> '${{ inputs.trivyignore }}' | ||
- name: Run Trivy vulnerability scanner in IaC mode | ||
uses: aquasecurity/[email protected] | ||
with: | ||
scan-type: 'config' | ||
format: 'sarif' | ||
exit-code: '0' | ||
output: ${{ env.TRIVY_SARIF }} | ||
severity: ${{ inputs.severity }} | ||
trivyignores: ${{ inputs.trivyignore }} | ||
ignore-unfixed: 'true' | ||
skip-dirs: ${{ inputs.skip-dirs }} | ||
shell: bash | ||
run: | | ||
# Run Trivy | ||
trivy config '${{ inputs.path }}' \ | ||
--format 'sarif' \ | ||
--output '${{ env.TRIVY_SARIF }}' \ | ||
--exit-code '0' \ | ||
--severity '${{ inputs.severity }}' \ | ||
--ignorefile '${{ inputs.trivyignore }}' \ | ||
${{ inputs.skip-dirs != '' && format('--skip-dirs {0}', inputs.skip-dirs) || '' }} | ||
- name: Upload Trivy report to GitHub Security tab | ||
if: ${{ inputs.upload-report == 'true' }} | ||
|