Skip to content

Commit 6cbc769

Browse files
authored
Merge pull request #926 from rackerlabs/fix-truffles
fix: change Trufflehog workflow to use Github script
2 parents a55bded + 6bdaaa2 commit 6cbc769

File tree

1 file changed

+24
-13
lines changed

1 file changed

+24
-13
lines changed

.github/workflows/trufflehog.yaml

Lines changed: 24 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
1+
---
12
name: Secrets scanning
2-
on:
3+
on: # yamllint disable-line rule:truthy
34
push:
45
branches:
56
- main
@@ -12,20 +13,30 @@ jobs:
1213
test:
1314
runs-on: ubuntu-latest
1415
steps:
15-
- shell: bash
16-
run: |
17-
if [ "${{ github.event_name }}" == "push" ]; then
18-
echo "depth=$(($(jq length <<< '${{ toJson(github.event.commits) }}') + 2))" >> $GITHUB_ENV
19-
echo "branch=${{ github.ref_name }}" >> $GITHUB_ENV
20-
fi
21-
if [ "${{ github.event_name }}" == "pull_request" ]; then
22-
echo "depth=$((${{ github.event.pull_request.commits }}+2))" >> $GITHUB_ENV
23-
echo "branch=${{ github.event.pull_request.head.ref }}" >> $GITHUB_ENV
24-
fi
16+
- uses: actions/github-script@v7
17+
id: git-intel
18+
with:
19+
script: |
20+
let depth = 0;
21+
let branch = "";
22+
core.debug(context.payload)
23+
if (context.eventName == "push") {
24+
depth = context.payload.commits.length
25+
branch = context.ref
26+
}
27+
28+
if (context.eventName == "pull_request") {
29+
depth = context.payload.pull_request.commits
30+
branch = context.payload.pull_request.head.ref
31+
}
32+
33+
depth = depth + 2
34+
core.info(`Will fetch ${depth} commits from ${branch}.`)
35+
return { "depth": depth, "branch": branch }
2536
- uses: actions/checkout@v4
2637
with:
27-
ref: ${{env.branch}}
28-
fetch-depth: ${{env.depth}}
38+
ref: ${{steps.git-intel.outputs.result.branch}}
39+
fetch-depth: ${{steps.git-intel.outputs.result.depth}}
2940
- name: Secret Scanning
3041
uses: trufflesecurity/trufflehog@main
3142
with:

0 commit comments

Comments
 (0)