|
29 | 29 | SONAR_PROJECT_KEY: "bartstc_vite-ts-react-template" |
30 | 30 |
|
31 | 31 | jobs: |
| 32 | + # Exposes workflow-level env vars as outputs so they can be referenced in |
| 33 | + # job-level `if:` expressions (the `env` context is not available there). |
| 34 | + config: |
| 35 | + runs-on: ubuntu-latest |
| 36 | + outputs: |
| 37 | + snyk_enabled: ${{ steps.set.outputs.snyk_enabled }} |
| 38 | + sonarcloud_enabled: ${{ steps.set.outputs.sonarcloud_enabled }} |
| 39 | + static_analysis_branch: ${{ steps.set.outputs.static_analysis_branch }} |
| 40 | + steps: |
| 41 | + - id: set |
| 42 | + run: | |
| 43 | + echo "snyk_enabled=$SNYK_ENABLED" >> "$GITHUB_OUTPUT" |
| 44 | + echo "sonarcloud_enabled=$SONARCLOUD_ENABLED" >> "$GITHUB_OUTPUT" |
| 45 | + echo "static_analysis_branch=$STATIC_ANALYSIS_BRANCH" >> "$GITHUB_OUTPUT" |
| 46 | +
|
32 | 47 | lint-tests: |
33 | 48 | uses: ./.github/workflows/run-tests.yml |
34 | 49 | with: |
@@ -179,10 +194,11 @@ jobs: |
179 | 194 | path: coverage/**/* |
180 | 195 |
|
181 | 196 | snyk: |
| 197 | + needs: config |
182 | 198 | if: > |
183 | | - ${{ env.SNYK_ENABLED == 'true' |
184 | | - && (github.ref_name == env.STATIC_ANALYSIS_BRANCH |
185 | | - || github.base_ref == env.STATIC_ANALYSIS_BRANCH) }} |
| 199 | + ${{ needs.config.outputs.snyk_enabled == 'true' |
| 200 | + && (github.ref_name == needs.config.outputs.static_analysis_branch |
| 201 | + || github.base_ref == needs.config.outputs.static_analysis_branch) }} |
186 | 202 | runs-on: ubuntu-latest |
187 | 203 | permissions: |
188 | 204 | contents: read |
@@ -232,11 +248,11 @@ jobs: |
232 | 248 | category: snyk |
233 | 249 |
|
234 | 250 | sonarcloud: |
| 251 | + needs: [config, unit-tests, storybook-tests] |
235 | 252 | if: > |
236 | | - ${{ env.SONARCLOUD_ENABLED == 'true' |
237 | | - && (github.ref_name == env.STATIC_ANALYSIS_BRANCH |
238 | | - || github.base_ref == env.STATIC_ANALYSIS_BRANCH) }} |
239 | | - needs: [unit-tests, storybook-tests] |
| 253 | + ${{ needs.config.outputs.sonarcloud_enabled == 'true' |
| 254 | + && (github.ref_name == needs.config.outputs.static_analysis_branch |
| 255 | + || github.base_ref == needs.config.outputs.static_analysis_branch) }} |
240 | 256 | runs-on: ubuntu-latest |
241 | 257 | steps: |
242 | 258 | - name: Checkout |
|
0 commit comments