Skip to content

Commit

Permalink
intermediate env vars
Browse files Browse the repository at this point in the history
  • Loading branch information
IlyasMoutawwakil committed Oct 14, 2024
1 parent d58bb25 commit bedef80
Showing 1 changed file with 14 additions and 19 deletions.
33 changes: 14 additions & 19 deletions .github/workflows/security.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,40 +2,35 @@ name: Security Checks

on:
push:
branches:
- main
pull_request:
branches:
- main

concurrency:
cancel-in-progress: true
group: ${{ github.workflow }}-${{ github.ref }}

permissions:
contents: read

jobs:
secrets:
trufflehog:
runs-on: ubuntu-latest
steps:
- name: Set up environment variables
shell: bash
- shell: bash
run: |
if [ "${{ github.event_name }}" == "push" ]; then
echo "depth=$(($(jq length <<< '${{ toJson(github.event.commits) }}') + 2))" >> $GITHUB_ENV
echo "branch=${{ github.ref_name }}" >> $GITHUB_ENV
if [ "$EVENT_NAME" == "push" ]; then
echo "depth=$(($(jq length <<< '$COMMITS') + 2))" >> $GITHUB_ENV
echo "branch=$REF_NAME" >> $GITHUB_ENV
fi
if [ "${{ github.event_name }}" == "pull_request" ]; then
echo "depth=$((${{ github.event.pull_request.commits }}+2))" >> $GITHUB_ENV
echo "branch=${{ github.event.pull_request.head.ref }}" >> $GITHUB_ENV
if [ "$EVENT_NAME" == "pull_request" ]; then
echo "depth=$(($PR_COMMITS+2))" >> $GITHUB_ENV
echo "branch=$PR_REF" >> $GITHUB_ENV
fi
env:
REF_NAME: ${{ github.ref_name }}
EVENT_NAME: ${{ github.event_name }}
COMMITS: ${{ toJson(github.event.commits) }}
PR_REF: ${{ github.event.pull_request.head.ref }}
PR_COMMITS: ${{ github.event.pull_request.commits }}

- name: Checkout code
uses: actions/checkout@v4
with:
ref: ${{env.branch}}
fetch-depth: ${{env.depth}}

- name: Scan for secrets
uses: trufflesecurity/trufflehog@main

0 comments on commit bedef80

Please sign in to comment.