Created
October 18, 2023 19:24
-
-
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.
This file contains hidden or 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
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