File tree Expand file tree Collapse file tree 1 file changed +24
-13
lines changed Expand file tree Collapse file tree 1 file changed +24
-13
lines changed Original file line number Diff line number Diff line change
1
+ ---
1
2
name : Secrets scanning
2
- on :
3
+ on : # yamllint disable-line rule:truthy
3
4
push :
4
5
branches :
5
6
- main
@@ -12,20 +13,30 @@ jobs:
12
13
test :
13
14
runs-on : ubuntu-latest
14
15
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 }
25
36
- uses : actions/checkout@v4
26
37
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}}
29
40
- name : Secret Scanning
30
41
uses : trufflesecurity/trufflehog@main
31
42
with :
You can’t perform that action at this time.
0 commit comments