Skip to content

Commit

Permalink
Merge pull request #14 from globis-org/mod/target-path
Browse files Browse the repository at this point in the history
feat: 全ディレクトリをスキャンするように変更する
  • Loading branch information
mutao-net authored Jan 22, 2024
2 parents 85b15f7 + c60956c commit 9379c60
Showing 1 changed file with 1 addition and 38 deletions.
39 changes: 1 addition & 38 deletions .github/workflows/secrets-scan.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,61 +4,24 @@ on:
pull_request:

jobs:
filter:
runs-on: ubuntu-latest
if: ${{ !contains(github.actor, '[bot]') }} # [bot]を含む場合は除外する
outputs:
workdirs: ${{ steps.dirs.outputs.workdirs }}
steps:
- name: Checkout
uses: actions/[email protected]
with:
ref: ${{ github.head_ref }}

- name: Fetch PR base ref
run: |
git fetch --depth=1 origin ${{ github.base_ref }}:${{ github.base_ref }}
# 変更の入ったディレクトリのみ取得する
- name: Get changed directories
id: dirs
run: |
workdirs=$(git diff --name-only ${{ github.base_ref }} ${{ github.head_ref }} | xargs -I {} dirname {} | sort | uniq | jq -R -s -c 'split("\n")[:-1]')
echo "workdirs=$workdirs" >> $GITHUB_OUTPUT
scan:
needs: filter
runs-on: ubuntu-latest
if: ${{ !contains(github.actor, '[bot]') }} # [bot]を含む場合は除外する
strategy:
matrix:
workdir: ${{ fromJSON(needs.filter.outputs.workdirs) }}
steps:
- name: Checkout
uses: actions/[email protected]
with:
ref: ${{ github.head_ref }}

- name: Check if workdir exists
id: check
run: |
if [ -d "${{ matrix.workdir }}" ]; then
echo "exists=true" >> $GITHUB_OUTPUT
else
echo "exists=false" >> $GITHUB_OUTPUT
fi
- name: Run Aqua Security Trivy
uses: aquasecurity/[email protected]
with:
scan-type: fs
scan-ref: ${{ matrix.workdir }}
scan-ref: . # default
severity: UNKNOWN,LOW,MEDIUM,HIGH,CRITICAL # default
scanners: secret
output: trivy.txt
exit-code: 1
if: steps.check.outputs.exists == 'true'

- name: Post PR comments
if: failure()
Expand Down

0 comments on commit 9379c60

Please sign in to comment.