Skip to content

Commit da4bea0

Browse files
committed
chore: fix ci yaml
1 parent 979b8aa commit da4bea0

1 file changed

Lines changed: 23 additions & 7 deletions

File tree

.github/workflows/ci.yml

Lines changed: 23 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,21 @@ env:
2929
SONAR_PROJECT_KEY: "bartstc_vite-ts-react-template"
3030

3131
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+
3247
lint-tests:
3348
uses: ./.github/workflows/run-tests.yml
3449
with:
@@ -179,10 +194,11 @@ jobs:
179194
path: coverage/**/*
180195

181196
snyk:
197+
needs: config
182198
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) }}
186202
runs-on: ubuntu-latest
187203
permissions:
188204
contents: read
@@ -232,11 +248,11 @@ jobs:
232248
category: snyk
233249

234250
sonarcloud:
251+
needs: [config, unit-tests, storybook-tests]
235252
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) }}
240256
runs-on: ubuntu-latest
241257
steps:
242258
- name: Checkout

0 commit comments

Comments
 (0)