Skip to content

Commit eb05e7c

Browse files
committed
ci(workflows): enhance fortress workflow configurations
- Update multiple fortress-* workflows with security improvements - Improve workflow setup, benchmarks, performance summary, and security scans - Enhanced scorecard workflow configuration
1 parent 6e4c3f8 commit eb05e7c

8 files changed

Lines changed: 183 additions & 64 deletions

.github/workflows/fortress-benchmarks.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ jobs:
5050
timeout-minutes: 30 # Prevent hung benchmarks
5151
strategy:
5252
fail-fast: false # Continue running other benchmarks if one fails
53-
matrix: ${{ fromJson(inputs.benchmark-matrix) }}
53+
matrix: ${{ fromJSON(inputs.benchmark-matrix) }}
5454
runs-on: ${{ matrix.os }}
5555

5656
steps:

.github/workflows/fortress-performance-summary.yml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,11 @@ on:
5151
required: false
5252
type: string
5353
default: "skipped"
54+
status-check-result:
55+
description: "Result of the status-check job"
56+
required: false
57+
type: string
58+
default: "skipped"
5459
test-matrix:
5560
description: "Test matrix JSON"
5661
required: true
@@ -263,6 +268,8 @@ jobs:
263268
if [[ "${{ inputs.benchmarks-result }}" != "skipped" ]]; then
264269
echo "| 🏃 Benchmarks | ${{ inputs.benchmarks-result }} | $([ "${{ inputs.benchmarks-result }}" = "success" ] && echo "✅" || echo "❌") |"
265270
fi
271+
# Always show status-check result
272+
echo "| 🎯 All Tests Passed | ${{ inputs.status-check-result }} | $([ "${{ inputs.status-check-result }}" = "success" ] && echo "✅" || echo "❌") |"
266273
# Only show release row if it was attempted
267274
if [[ "${{ inputs.release-result }}" != "skipped" ]]; then
268275
echo "| 🚀 Release | ${{ inputs.release-result }} | $([ "${{ inputs.release-result }}" = "success" ] && echo "✅" || echo "❌") |"
@@ -312,6 +319,7 @@ jobs:
312319
[ "${{ inputs.code-quality-result }}" != "success" ] && [ "${{ inputs.code-quality-result }}" != "skipped" ] && FAILED_JOBS="${FAILED_JOBS}Code Quality, "
313320
[ "${{ inputs.test-suite-result }}" != "success" ] && [ "${{ inputs.test-suite-result }}" != "skipped" ] && FAILED_JOBS="${FAILED_JOBS}Test Suite, "
314321
[ "${{ inputs.benchmarks-result }}" != "success" ] && [ "${{ inputs.benchmarks-result }}" != "skipped" ] && FAILED_JOBS="${FAILED_JOBS}Benchmarks, "
322+
[ "${{ inputs.status-check-result }}" != "success" ] && [ "${{ inputs.status-check-result }}" != "skipped" ] && FAILED_JOBS="${FAILED_JOBS}Status Check, "
315323
[ "${{ inputs.release-result }}" != "success" ] && [ "${{ inputs.release-result }}" != "skipped" ] && FAILED_JOBS="${FAILED_JOBS}Release, "
316324
317325
if [ -n "$FAILED_JOBS" ]; then

.github/workflows/fortress-release.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ on:
3838
required: true
3939
slack-webhook:
4040
description: "Slack webhook URL for notifications"
41-
required: true
41+
required: false
4242

4343
# ————————————————————————————————————————————————————————————————
4444
# Permissions

.github/workflows/fortress-security-scans.yml

Lines changed: 66 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,21 @@ on:
1717
description: "JSON string of environment variables"
1818
required: true
1919
type: string
20+
enable-nancy:
21+
description: "Enable Nancy security scan"
22+
required: false
23+
type: boolean
24+
default: true
25+
enable-govulncheck:
26+
description: "Enable govulncheck security scan"
27+
required: false
28+
type: boolean
29+
default: true
30+
enable-gitleaks:
31+
description: "Enable Gitleaks security scan"
32+
required: false
33+
type: boolean
34+
default: true
2035
primary-runner:
2136
description: "Primary runner OS"
2237
required: true
@@ -43,6 +58,7 @@ jobs:
4358
ask-nancy:
4459
name: 🛡️ Ask Nancy (Dependency Checks)
4560
runs-on: ${{ inputs.primary-runner }}
61+
if: ${{ inputs.enable-nancy }}
4662
steps:
4763
# ————————————————————————————————————————————————————————————————
4864
# Parse environment variables
@@ -124,6 +140,7 @@ jobs:
124140
govulncheck:
125141
name: 🔐 Run govulncheck (Vulnerability Scan)
126142
runs-on: ${{ inputs.primary-runner }}
143+
if: ${{ inputs.enable-govulncheck }}
127144
steps:
128145
# ————————————————————————————————————————————————————————————————
129146
# Parse environment variables
@@ -229,7 +246,7 @@ jobs:
229246
gitleaks:
230247
name: 🕵️ Run Gitleaks (Secret Scan)
231248
runs-on: ${{ inputs.primary-runner }}
232-
if: github.event.pull_request.head.repo.full_name == github.repository
249+
if: ${{ inputs.enable-gitleaks }}
233250
steps:
234251
# ————————————————————————————————————————————————————————————————
235252
# Parse environment variables
@@ -243,6 +260,38 @@ jobs:
243260
echo "$key=$value" >> $GITHUB_ENV
244261
done
245262
263+
# ————————————————————————————————————————————————————————————————
264+
# Check repository security conditions
265+
# ————————————————————————————————————————————————————————————————
266+
- name: 🔍 Check repository security conditions
267+
id: repo-check
268+
env:
269+
GITHUB_EVENT_NAME: ${{ github.event_name }}
270+
GITHUB_ACTOR: ${{ github.actor }}
271+
GITHUB_REPOSITORY: ${{ github.repository }}
272+
GITHUB_HEAD_REF: ${{ github.head_ref }}
273+
PR_HEAD_REPO: ${{ github.event.pull_request.head.repo.full_name }}
274+
run: |
275+
echo "🔍 Checking repository security conditions..."
276+
echo "Event Name: $GITHUB_EVENT_NAME"
277+
echo "Actor: $GITHUB_ACTOR"
278+
echo "Repository: $GITHUB_REPOSITORY"
279+
echo "Head Ref: $GITHUB_HEAD_REF"
280+
281+
# For workflow_call, we typically trust the calling workflow from the same repo
282+
# For pull_request events, check if head repo matches base repo
283+
if [[ "$GITHUB_EVENT_NAME" == "workflow_call" ]]; then
284+
echo "✅ Workflow call from same repository - security scans allowed"
285+
echo "is_same_repo=true" >> $GITHUB_OUTPUT
286+
elif [[ "$PR_HEAD_REPO" == "$GITHUB_REPOSITORY" ]] || [[ -z "$PR_HEAD_REPO" ]]; then
287+
echo "✅ Same repository or push event - security scans allowed"
288+
echo "is_same_repo=true" >> $GITHUB_OUTPUT
289+
else
290+
echo "⚠️ Fork detected - skipping secret-sensitive scans for security"
291+
echo "PR Head Repo: $PR_HEAD_REPO"
292+
echo "is_same_repo=false" >> $GITHUB_OUTPUT
293+
fi
294+
246295
# ————————————————————————————————————————————————————————————————
247296
# Checkout code and set up Go environment
248297
# ————————————————————————————————————————————————————————————————
@@ -252,6 +301,7 @@ jobs:
252301
fetch-depth: 0 # Fetch all history so Gitleaks can scan commits
253302

254303
- name: 🔍 Run gitleaks scan
304+
if: steps.repo-check.outputs.is_same_repo == 'true'
255305
uses: gitleaks/gitleaks-action@ff98106e4c7b2bc287b24eaf42907196329070c7 # v8.27.2
256306
env:
257307
GITHUB_TOKEN: ${{ secrets.github-token }}
@@ -263,6 +313,7 @@ jobs:
263313
GITLEAKS_VERSION: ${{ env.GITLEAKS_VERSION }}
264314

265315
- name: 📊 Job Summary
316+
if: steps.repo-check.outputs.is_same_repo == 'true'
266317
run: |
267318
echo "## 🕵️ Gitleaks Secret Scan Summary" >> $GITHUB_STEP_SUMMARY
268319
echo "" >> $GITHUB_STEP_SUMMARY
@@ -274,3 +325,17 @@ jobs:
274325
echo "| **Result** | ✅ No secrets detected (see logs for details) |" >> $GITHUB_STEP_SUMMARY
275326
echo "" >> $GITHUB_STEP_SUMMARY
276327
echo "🎯 **Secret scan completed successfully.**" >> $GITHUB_STEP_SUMMARY
328+
329+
- name: 📊 Fork Security Notice
330+
if: steps.repo-check.outputs.is_same_repo == 'false'
331+
run: |
332+
echo "## 🕵️ Gitleaks Secret Scan Summary" >> $GITHUB_STEP_SUMMARY
333+
echo "" >> $GITHUB_STEP_SUMMARY
334+
echo "| 🔒 Security Details | ⚠️ Status |" >> $GITHUB_STEP_SUMMARY
335+
echo "|---|---|" >> $GITHUB_STEP_SUMMARY
336+
echo "| **Tool** | Gitleaks |" >> $GITHUB_STEP_SUMMARY
337+
echo "| **Fork Detected** | ${{ github.event.pull_request.head.repo.full_name || 'N/A (not a PR event)' }} |" >> $GITHUB_STEP_SUMMARY
338+
echo "| **Base Repository** | ${{ github.repository }} |" >> $GITHUB_STEP_SUMMARY
339+
echo "| **Result** | ⚠️ Skipped for security (fork cannot access secrets) |" >> $GITHUB_STEP_SUMMARY
340+
echo "" >> $GITHUB_STEP_SUMMARY
341+
echo "🔒 **Secret scanning was skipped because this PR comes from a fork. This is a security feature to prevent secret exposure.**" >> $GITHUB_STEP_SUMMARY

0 commit comments

Comments
 (0)