Skip to content

Instantly share code, notes, and snippets.

@joeleonjr
Created October 18, 2023 19:24
Show Gist options
  • Save joeleonjr/cedb50ad3c716bdf11cbd0e6bb0677ea to your computer and use it in GitHub Desktop.
Save joeleonjr/cedb50ad3c716bdf11cbd0e6bb0677ea to your computer and use it in GitHub Desktop.
Sample YAML file for integrating TruffleHog Open-Source into a GitHub Action pipeline.
on:
push:
branches:
- main
pull_request:
permissions:
contents: read
id-token: write
issues: write
pull-requests: write
jobs:
TruffleHog:
runs-on: ubuntu-latest
defaults:
run:
shell: bash
steps:
- name: Set Shallow Clone Depth & Branch Values
id: set_values
run: |
if [ "${{ github.event_name }}" == "push" ]; then
echo "branch=${{ github.ref_name }}" >> $GITHUB_OUTPUT
echo "depth=$(echo '${{ toJSON(github.event.commits) }}' | jq length)" >> $GITHUB_OUTPUT
fi
if [ "${{ github.event_name }}" == "pull_request" ]; then
echo "branch=${{ github.event.pull_request.head.ref }}" >> $GITHUB_OUTPUT
echo "depth=${{ github.event.pull_request.commits }}" >> $GITHUB_OUTPUT
fi
- name: Checkout code
uses: actions/checkout@v3
with:
ref: ${{ steps.set_values.outputs.branch }}
fetch-depth: ${{ steps.set_values.outputs.depth }}
- name: TruffleHog OSS
id: trufflehog
uses: trufflesecurity/trufflehog@main
continue-on-error: true
with:
path: ./
- name: Scan Results Status
if: steps.trufflehog.outcome == 'failure'
run: exit 1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment