Skip to content

Commit 42de837

Browse files
committed
Only report build failures on protected branches
1 parent af668a2 commit 42de837

File tree

2 files changed

+13
-2
lines changed

2 files changed

+13
-2
lines changed

.github/workflows/build-targets.yaml

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,14 @@ jobs:
108108
REPOSITORY: ${{ github.repository }}
109109
AWS_ROLE_TO_ASSUME: ${{ secrets.AWS_ROLE_TO_ASSUME }}
110110
steps:
111+
- name: Check if protected branch
112+
id: check-branch
113+
run: |
114+
if [[ "$GITHUB_REF_NAME" == "main" ]] || [[ "$GITHUB_REF_NAME" =~ ^[0-9]+\.[0-9]+$ ]]; then
115+
echo "is_protected=true" >> $GITHUB_OUTPUT
116+
else
117+
echo "is_protected=false" >> $GITHUB_OUTPUT
118+
fi
111119
- name: Use role credentials for metrics
112120
id: aws-creds
113121
continue-on-error: ${{ env.REPOSITORY != 'aws/code-editor' }}
@@ -117,7 +125,7 @@ jobs:
117125
role-duration-seconds: 900
118126
aws-region: us-east-1
119127
- name: Report failure
120-
if: steps.aws-creds.outcome == 'success'
128+
if: steps.aws-creds.outcome == 'success' && steps.check-branch.outputs.is_protected == 'true'
121129
run: |
122130
aws cloudwatch put-metric-data \
123131
--namespace "GitHub/Workflows" \

.github/workflows/security-scan.yaml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -616,7 +616,10 @@ jobs:
616616
owner: context.repo.owner,
617617
repo: context.repo.repo,
618618
workflow_id: "build-targets.yaml",
619-
ref: context.ref
619+
ref: context.ref,
620+
inputs: {
621+
triggered_by: 'workflow'
622+
}
620623
})
621624
622625
handle-failures:

0 commit comments

Comments
 (0)