Skip to content

Commit

Permalink
fix: optimize CodeQL run conditions (#15082)
Browse files Browse the repository at this point in the history
  • Loading branch information
erikburt authored Nov 4, 2024
1 parent 9a11490 commit c3f8926
Showing 1 changed file with 41 additions and 7 deletions.
48 changes: 41 additions & 7 deletions .github/workflows/codeql-analysis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,34 +11,68 @@ on:
- cron: '23 19 * * 4'

jobs:
analyze:
name: Analyze ${{ matrix.language }}
filter:
name: Detect Changes
permissions:
pull-requests: read
outputs:
should-run-go: ${{ steps.changes.outputs.go-changes == 'true' || steps.changes.outputs.workflow-changes == 'true' || github.event == 'schedule' }}
should-run-js: ${{ steps.changes.outputs.js-changes == 'true' || steps.changes.outputs.workflow-changes == 'true' || github.event == 'schedule' }}
runs-on: ubuntu-latest
steps:
- name: Checkout the repo
uses: actions/checkout@v4.2.1
with:
repository: smartcontractkit/chainlink
- uses: dorny/paths-filter@de90cc6fb38fc0963ad72b210f1f284cd68cea36 # v3.0.2
id: changes
with:
filters: |
go-changes:
- '**/*.go'
- '**/go.mod'
- '**/go.sum'
js-changes:
- '**/package.json'
- '**/pnpm-lock.yaml'
- '**/*.js'
- '**/*.ts'
workflow-changes:
- '.github/workflows/codeql-analysis.yml'
analyze:
needs: filter
name: Analyze ${{ matrix.type.language }}
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
language: ['go', 'javascript']

type:
- language: 'go'
should-run: ${{ needs.filter.outputs.should-run-go }}
- language: 'javascript'
should-run: ${{ needs.filter.outputs.should-run-js }}
steps:
- name: Checkout repository
uses: actions/checkout@v4.2.1

- name: Set up Go
if: ${{ matrix.language == 'go' }}
if: ${{ matrix.type.language == 'go' && matrix.type.should-run == 'true' }}
uses: ./.github/actions/setup-go
with:
go-version-file: 'go.mod'
only-modules: 'true'

- name: Touching core/web/assets/index.html
if: ${{ matrix.language == 'go' }}
if: ${{ matrix.type.language == 'go' && matrix.type.should-run == 'true' }}
run: mkdir -p core/web/assets && touch core/web/assets/index.html

- name: Initialize CodeQL
if: ${{ matrix.type.should-run == 'true' }}
uses: github/codeql-action/init@65c74964a9ed8c44ed9f19d4bbc5757a6a8e9ab9 # codeql-bundle-v2.16.1
with:
languages: ${{ matrix.language }}
languages: ${{ matrix.type.language }}

- name: Perform CodeQL Analysis
if: ${{ matrix.type.should-run == 'true' }}
uses: github/codeql-action/analyze@65c74964a9ed8c44ed9f19d4bbc5757a6a8e9ab9 # codeql-bundle-v2.16.1

0 comments on commit c3f8926

Please sign in to comment.