|
12 | 12 | - all |
13 | 13 | - csharp |
14 | 14 | - actions |
| 15 | + advanced_setup: |
| 16 | + description: Run advanced CodeQL instead of repository default setup |
| 17 | + required: false |
| 18 | + default: false |
| 19 | + type: boolean |
15 | 20 | push: |
16 | 21 | paths: |
17 | 22 | - ".github/codeql/**" |
@@ -55,33 +60,31 @@ concurrency: |
55 | 60 | cancel-in-progress: ${{ github.event_name == 'pull_request' }} |
56 | 61 |
|
57 | 62 | jobs: |
58 | | - default-setup: |
59 | | - name: Detect default setup |
| 63 | + advanced-setup: |
| 64 | + name: Advanced setup gate |
60 | 65 | runs-on: ubuntu-latest |
61 | 66 | outputs: |
62 | | - enabled: ${{ steps.default-setup.outputs.enabled }} |
| 67 | + enabled: ${{ steps.advanced-setup.outputs.enabled }} |
63 | 68 | steps: |
64 | | - - name: Check CodeQL default setup |
65 | | - id: default-setup |
66 | | - env: |
67 | | - GH_TOKEN: ${{ github.token }} |
| 69 | + - name: Decide whether to run advanced CodeQL |
| 70 | + id: advanced-setup |
68 | 71 | run: | |
69 | | - state="$(gh api "repos/${GITHUB_REPOSITORY}/code-scanning/default-setup" --jq .state 2>/dev/null || true)" |
70 | | - if [ "$state" = "configured" ]; then |
| 72 | + if [ "${{ vars.OPENCLAW_CODEQL_ADVANCED_SETUP }}" = "true" ] || { [ "${{ github.event_name }}" = "workflow_dispatch" ] && [ "${{ inputs.advanced_setup }}" = "true" ]; }; then |
71 | 73 | echo "enabled=true" >> "$GITHUB_OUTPUT" |
72 | | - { |
73 | | - echo "CodeQL default setup is already configured for this repository." |
74 | | - echo "Skipping this advanced workflow because GitHub rejects advanced CodeQL SARIF uploads while default setup is enabled." |
75 | | - } >> "$GITHUB_STEP_SUMMARY" |
| 74 | + echo "Advanced CodeQL enabled for this run." >> "$GITHUB_STEP_SUMMARY" |
76 | 75 | else |
77 | 76 | echo "enabled=false" >> "$GITHUB_OUTPUT" |
78 | | - echo "CodeQL default setup state: ${state:-unavailable}" >> "$GITHUB_STEP_SUMMARY" |
| 77 | + { |
| 78 | + echo "Advanced CodeQL is disabled for this repository workflow." |
| 79 | + echo "The repository currently uses GitHub CodeQL default setup; default setup and advanced setup cannot upload SARIF for the same repository at the same time." |
| 80 | + echo "If maintainers disable default setup, set OPENCLAW_CODEQL_ADVANCED_SETUP=true or dispatch this workflow with advanced_setup=true." |
| 81 | + } >> "$GITHUB_STEP_SUMMARY" |
79 | 82 | fi |
80 | 83 |
|
81 | 84 | csharp: |
82 | 85 | name: C# security |
83 | | - needs: default-setup |
84 | | - if: ${{ needs.default-setup.outputs.enabled != 'true' && (github.event_name != 'pull_request' || !github.event.pull_request.draft) && (github.event_name != 'workflow_dispatch' || inputs.profile == 'all' || inputs.profile == 'csharp') }} |
| 86 | + needs: advanced-setup |
| 87 | + if: ${{ needs.advanced-setup.outputs.enabled == 'true' && (github.event_name != 'pull_request' || !github.event.pull_request.draft) && (github.event_name != 'workflow_dispatch' || inputs.profile == 'all' || inputs.profile == 'csharp') }} |
85 | 88 | runs-on: windows-latest |
86 | 89 | timeout-minutes: 45 |
87 | 90 | steps: |
@@ -115,8 +118,8 @@ jobs: |
115 | 118 |
|
116 | 119 | actions: |
117 | 120 | name: Actions security |
118 | | - needs: default-setup |
119 | | - if: ${{ needs.default-setup.outputs.enabled != 'true' && (github.event_name != 'pull_request' || !github.event.pull_request.draft) && (github.event_name != 'workflow_dispatch' || inputs.profile == 'all' || inputs.profile == 'actions') }} |
| 121 | + needs: advanced-setup |
| 122 | + if: ${{ needs.advanced-setup.outputs.enabled == 'true' && (github.event_name != 'pull_request' || !github.event.pull_request.draft) && (github.event_name != 'workflow_dispatch' || inputs.profile == 'all' || inputs.profile == 'actions') }} |
120 | 123 | runs-on: ubuntu-latest |
121 | 124 | timeout-minutes: 15 |
122 | 125 | steps: |
|
0 commit comments