Skip to content

Commit da18bb9

Browse files
authored
feat(actions): add reusable gitleaks PR scan workflow (#311)
1 parent bd958ea commit da18bb9

3 files changed

Lines changed: 60 additions & 0 deletions

File tree

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
---
2+
name: 🔐 Gitleaks PR Scan
3+
4+
on:
5+
workflow_call:
6+
inputs:
7+
checkout_ref:
8+
description: 'Ref to checkout before scanning (optional).'
9+
required: false
10+
type: string
11+
default: ''
12+
13+
permissions:
14+
contents: read
15+
16+
jobs:
17+
gitleaks:
18+
name: 🔍 Gitleaks scan
19+
runs-on: ubuntu-latest
20+
steps:
21+
- name: 📦 Checkout
22+
uses: actions/checkout@v6
23+
with:
24+
ref: ${{ inputs.checkout_ref != '' && inputs.checkout_ref || github.ref }}
25+
26+
- name: 🔐 Run gitleaks on PR changes
27+
uses: gitleaks/gitleaks-action@v2
28+
env:
29+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
30+
...

‎README.md‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -125,6 +125,7 @@ Above example is just a simple example to call workflow from github shared workf
125125
28. [Terraform Workflow](./docs/28.terraform_workflow.md)
126126
29. [Terraform Module Tag Release Workflow (Shared)](./docs/29.tf-monorepo-tag-release.md)
127127
30. [Terraform PR Plan Diff workflow](./docs/30.tf-pr-checks.md)
128+
31. [Gitleaks PR Scan Workflow](./docs/31.gitleaks-pr-scan.md)
128129
129130
## Feedback
130131
If you come accross a bug or have any feedback, please log it in our [issue tracker](https://github.com/clouddrove/github-shared-workflows/issues), or feel free to drop us an email at [hello@clouddrove.com](mailto:hello@clouddrove.com).

‎docs/31.gitleaks-pr-scan.md‎

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
## [Gitleaks PR Scan Workflow](https://github.com/clouddrove/github-shared-workflows/blob/master/.github/workflows/gitleaks-pr-scan.yml)
2+
3+
This reusable workflow runs Gitleaks to detect hardcoded secrets in pull requests. It is designed to be called from organization/module repositories via `workflow_call`.
4+
5+
#### Usage
6+
Use this workflow when you want a centralized and consistent secret-scanning gate managed from `clouddrove/github-shared-workflows`.
7+
8+
### Highlights
9+
- ✅ Reusable `workflow_call` implementation
10+
- 🔐 Detects leaked credentials/secrets in PR code changes
11+
- 🧩 Can be consumed by `.github` policy repos and module repos
12+
- 🛡️ Uses `GITHUB_TOKEN` from caller context (`secrets: inherit`)
13+
14+
#### Example
15+
```yaml
16+
name: Gitleaks PR Secret Scan
17+
18+
on:
19+
pull_request:
20+
workflow_dispatch:
21+
22+
permissions:
23+
contents: read
24+
25+
jobs:
26+
gitleaks:
27+
uses: clouddrove/github-shared-workflows/.github/workflows/gitleaks-pr-scan.yml@master
28+
secrets: inherit
29+
```

0 commit comments

Comments
 (0)