Repository navigation
108 lines (97 loc) · 3.73 KB
/
Copy pathexample.yml
File metadata and controls
108 lines (97 loc) · 3.73 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
name: PR Analysis Example
on:
schedule:
# Run every Monday at 9 AM UTC
- cron: '0 9 * * 1'
workflow_dispatch:
inputs:
output_format:
description: 'Output format (json or csv)'
required: false
default: 'json'
type: choice
options:
- json
- csv
clean_cache:
description: 'Clean cache and start fresh'
required: false
default: 'false'
type: boolean
push:
paths:
- .github/workflows/example.yml
permissions:
contents: read
jobs:
analyze-prs:
runs-on: ubuntu-latest
permissions:
contents: read
steps:
- name: Harden the runner (Audit all outbound calls)
uses: step-security/harden-runner@e14015d583714f6e62063499dc959a02595150a1 # v2.21.1
with:
egress-policy: audit
- name: Checkout repository
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
- name: Detect GitHub token
id: token_check
env:
GH_PAT: ${{ secrets.GH_PAT }}
run: |
if [ -n "$GH_PAT" ]; then
echo "token_available=true" >> "$GITHUB_OUTPUT"
echo "GitHub token detected. Running PR analysis."
else
echo "token_available=false" >> "$GITHUB_OUTPUT"
echo "::warning::GH_PAT is not configured. Skipping PR analysis and running the standard Jest unit tests instead."
fi
- name: Restore HTTP cache
if: steps.token_check.outputs.token_available == 'true'
uses: actions/cache@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6.1.0
with:
path: .http_cache
key: http-cache-${{ github.run_id }}
restore-keys: |
http-cache-
- name: Run PR analysis with charts
if: steps.token_check.outputs.token_available == 'true'
uses: devops-actions/github-copilot-pr-analysis@a32a2170ed15148dada014bd200a9ee68f922a8c # v0.0.6
with:
github_token: ${{ secrets.GH_PAT }}
output_format: ${{ inputs.output_format || 'json' }}
analyze_all_repos: 'true'
clean_cache: ${{ inputs.clean_cache || 'false' }}
# Optional: Skip specific organizations or selectively include repos
# skipped_orgs: |
# unwanted-org
# partial-org:include:repo1,repo2
- name: Install test dependencies
if: steps.token_check.outputs.token_available != 'true'
run: npm ci
- name: Run standard test suite
if: steps.token_check.outputs.token_available != 'true'
run: node --experimental-vm-modules node_modules/jest-cli/bin/jest.js --runInBand --testPathIgnorePatterns=tests/api-retry-integration.test.js
- name: Upload analysis results
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
if: always() && steps.token_check.outputs.token_available == 'true'
with:
name: pr-analysis-results-${{ github.run_number }}
path: report/pr_analysis_*
retention-days: 30
- name: Display results summary
if: always()
run: |
{
if [ "${{ steps.token_check.outputs.token_available }}" = "true" ]; then
echo "## Analysis Complete! 🎉"
echo ""
echo "Analysis results have been uploaded as artifacts."
echo "Check the charts and tables in the step summary above."
else
echo "## Test fallback executed"
echo ""
echo "No GH_PAT was provided, so PR analysis was skipped and the standard Jest unit tests were run instead."
fi
} >> "$GITHUB_STEP_SUMMARY"