Skip to content

Commit 62b80d8

Browse files
authored
testing security-guardian.yml
1 parent 923bdd0 commit 62b80d8

File tree

1 file changed

+54
-1
lines changed

1 file changed

+54
-1
lines changed

.github/workflows/security-guardian.yml

Lines changed: 54 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,62 @@ name: Security Guardian
22
on:
33
pull_request: {}
44

5+
# Triggered from a separate job when a review is added
6+
workflow_run:
7+
workflows: [PR Linter Trigger]
8+
types:
9+
- completed
10+
11+
# Trigger when a status is updated (CodeBuild leads to statuses)
12+
status: {}
13+
14+
# Trigger when a check suite is completed (GitHub actions and CodeCov create checks)
15+
check_suite:
16+
types: [completed]
17+
518
jobs:
19+
download-if-workflow-run:
20+
runs-on: ubuntu-latest
21+
outputs:
22+
pr_number: ${{ steps.pr_output.outputs.pr_number }}
23+
pr_sha: ${{ steps.pr_output.outputs.pr_sha }}
24+
# if conditions on all individual steps because subsequent jobs depend on this job
25+
# and we cannot skip it entirely
26+
steps:
27+
- name: 'Download workflow_run artifact'
28+
if: github.event_name == 'workflow_run'
29+
uses: dawidd6/action-download-artifact@v9
30+
with:
31+
run_id: ${{ github.event.workflow_run.id }}
32+
name: pr_info
33+
path: pr/
34+
search_artifacts: true
35+
36+
- name: 'Determine PR info'
37+
# PR info comes from the artifact if downloaded, or GitHub context if not.
38+
if: github.event_name == 'workflow_run'
39+
id: 'pr_output'
40+
run: |
41+
if [[ ! -f pr/pr_number ]]; then
42+
echo "${{ github.event.pull_request.number }}" > pr/pr_number
43+
fi
44+
if [[ ! -f pr/pr_sha ]]; then
45+
echo "${{ github.event.pull_request.head.sha }}" > pr/pr_sha
46+
fi
47+
cat pr/*
48+
echo "pr_number=$(cat pr/pr_number)" >> "$GITHUB_OUTPUT"
49+
echo "pr_sha=$(cat pr/pr_sha)" >> "$GITHUB_OUTPUT"
50+
651
run-security-guardian:
52+
# Necessary to have sufficient permissions to write to the PR
53+
permissions:
54+
contents: read
55+
pull-requests: write
56+
statuses: read
57+
issues: read
58+
checks: read
759
runs-on: ubuntu-latest
60+
needs: download-if-workflow-run
861
steps:
962
- name: Checkout
1063
uses: actions/checkout@v4
@@ -14,7 +67,7 @@ jobs:
1467
run: |
1568
echo "Getting changed CloudFormation templates..."
1669
mkdir -p changed_templates
17-
70+
1871
git fetch origin main --depth=1
1972
2073
base_sha="${{ github.event.pull_request.base.sha }}"

0 commit comments

Comments
 (0)