Skip to content

Harden GitHub Actions workflows #256

Harden GitHub Actions workflows

Harden GitHub Actions workflows #256

Workflow file for this run

name: Secret scan
on:
pull_request:
branches: [master]
push:
branches: [master]
permissions:
contents: read
pull-requests: read # Allows gitleaks to inspect pull-request metadata.
concurrency:
group: secret-scan-${{ github.ref }}
cancel-in-progress: true
jobs:
leak-patterns:
name: scripts/leak-check.sh
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
# Need full history so --range can resolve the base SHA.
fetch-depth: 0
persist-credentials: false
- name: Run leak check
env:
BASE_SHA: ${{ github.event.pull_request.base.sha }}
EVENT_NAME: ${{ github.event_name }}
HEAD_SHA: ${{ github.event.pull_request.head.sha }}
run: |
if [ "$EVENT_NAME" = "pull_request" ]; then
base="$BASE_SHA"
head="$HEAD_SHA"
echo "Scanning $base..$head"
./scripts/leak-check.sh --range "$base..$head"
else
echo "Scanning all tracked files at HEAD"
./scripts/leak-check.sh --all
fi
gitleaks:
name: gitleaks
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
fetch-depth: 0
persist-credentials: false
- uses: gitleaks/gitleaks-action@e0c47f4f8be36e29cdc102c57e68cb5cbf0e8d1e # v3.0.0
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}