Skip to content

Commit 690c130

Browse files
committed
Add logic to determine if self-hosted
1 parent 26cb6da commit 690c130

File tree

5 files changed

+15
-13
lines changed

5 files changed

+15
-13
lines changed

.github/actions/build-node-python/action.yml

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ inputs:
2626
enable_node_cache:
2727
description: "enables the yarn cache download and upload"
2828
required: false
29-
default: "true"
29+
default: "false"
3030
download_yarn_lock:
3131
description: "downloads the node-yarn-lock artifact (only available when build-node was called before)"
3232
required: false
@@ -99,6 +99,17 @@ inputs:
9999
runs:
100100
using: "composite"
101101
steps:
102+
- name: Determine runner configuration
103+
id: runner_configuration
104+
shell: bash
105+
run: |
106+
# If the GH_ACTIONS_SELF_HOSTED is in the environment variables, we handle things like caching differently
107+
if [[ -n "$GH_ACTIONS_SELF_HOSTED" ]]; then
108+
echo "self_hosted=true" >> "$GITHUB_OUTPUT"
109+
else
110+
echo "self_hosted=false" >> "$GITHUB_OUTPUT"
111+
fi
112+
102113
# Node
103114
- uses: ./tmp/github-workflows/.github/actions/get-node-version
104115
if: inputs.enable_node == 'true' && inputs.node_version == ''
@@ -185,7 +196,7 @@ runs:
185196
# Enable yarn download cache, @see https://github.com/actions/cache/tree/main/save#always-save-cache and https://github.com/actions/setup-node/issues/325
186197
- name: Restore yarn cache
187198
uses: actions/cache/restore@v4
188-
if: inputs.enable_node == 'true' && inputs.enable_node_cache == 'true'
199+
if: inputs.enable_node == 'true' && inputs.enable_node_cache == 'true' && steps.runner_configuration.outputs.self_hosted == 'false'
189200
with:
190201
# This path is the global yarn cache, because for some reason the local .yarn/cache is not used. Maybe we need to set the cacheFolder, enableGlobalCache, ... options differently? @see https://yarnpkg.com/configuration/yarnrc#cacheFolder
191202
path: ~/.yarn/berry/cache/
@@ -290,7 +301,7 @@ runs:
290301
# Node
291302
- name: Save yarn cache
292303
uses: actions/cache/save@v4
293-
if: inputs.enable_node == 'true' && steps.build.outcome == 'success' && inputs.enable_node_cache == 'true'
304+
if: inputs.enable_node == 'true' && steps.build.outcome == 'success' && inputs.enable_node_cache == 'true' && steps.runner_configuration.outputs.self_hosted == 'false'
294305
with:
295306
# This path is the global yarn cache, because for some reason the local .yarn/cache is not used. Maybe we need to set the cacheFolder, enableGlobalCache, ... options differently? @see https://yarnpkg.com/configuration/yarnrc#cacheFolder
296307
path: ~/.yarn/berry/cache/

.github/workflows/build-docker-artifacts.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -276,6 +276,7 @@ jobs:
276276

277277
- name: Determine trivy scan severity levels
278278
id: configure_trivy
279+
shell: bash
279280
run: |
280281
if [[ "${{ github.event.inputs.scan_high_severity }}" == "false" ]] || \
281282
[[ "${{ vars.SCAN_HIGH_SEVERITY }}" == "false" ]] || \

.github/workflows/build-node-python.yml

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -157,8 +157,6 @@ jobs:
157157
python_version: ${{ vars.PYTHON_VERSION || inputs.python_version }}
158158
github_ro_token: ${{ github.event.repository.private == true && secrets.DATAVISYN_BOT_REPO_TOKEN || github.token }}
159159
run_node_bundle: ${{ inputs.node_run_webpack }}
160-
enable_node_cache: ${{ inputs.runs_on != 'self-hosted' }}
161-
enable_python_cache: ${{ inputs.runs_on != 'self-hosted' }}
162160
chromatic_enable: ${{ inputs.chromatic_enable }}
163161
chromatic_project_token: ${{ secrets.CHROMATIC_PROJECT_TOKEN }}
164162
upload_yarn_lock: "node-yarn-lock-${{ inputs.branch || github.sha }}"
@@ -198,8 +196,6 @@ jobs:
198196
python_version: ${{ vars.PYTHON_VERSION || inputs.python_version }}
199197
github_ro_token: ${{ github.event.repository.private == true && secrets.DATAVISYN_BOT_REPO_TOKEN || github.token }}
200198
run_node_bundle: ${{ inputs.node_run_webpack }}
201-
enable_node_cache: ${{ inputs.runs_on != 'self-hosted' }}
202-
enable_python_cache: ${{ inputs.runs_on != 'self-hosted' }}
203199

204200
# If cypress is used, build node and python sequentially as it is avoiding the duplicate install overhead
205201
build-node-python-cypress:
@@ -289,8 +285,6 @@ jobs:
289285
python_version: ${{ vars.PYTHON_VERSION || inputs.python_version }}
290286
github_ro_token: ${{ github.event.repository.private == true && secrets.DATAVISYN_BOT_REPO_TOKEN || github.token }}
291287
run_node_bundle: false # Disable the build here and call afterwards, as otherwise the yarn run env:decrypt will fail due to a missing yarn install
292-
enable_node_cache: ${{ inputs.cypress_runs_on != 'self-hosted' && inputs.runs_on != 'self-hosted' }}
293-
enable_python_cache: ${{ inputs.cypress_runs_on != 'self-hosted' && inputs.runs_on != 'self-hosted' }}
294288
chromatic_enable: ${{ inputs.chromatic_enable }}
295289
chromatic_project_token: ${{ secrets.CHROMATIC_PROJECT_TOKEN }}
296290
- name: Decrypt .env.enc and <app>/.env.enc
@@ -433,8 +427,6 @@ jobs:
433427
github_ro_token: ${{ github.event.repository.private == true && secrets.DATAVISYN_BOT_REPO_TOKEN || github.token }}
434428
run_node_bundle: false # Disable the build here and call afterwards, as otherwise the yarn run env:decrypt will fail due to a missing yarn install
435429
run_playwright_browser_install: true
436-
enable_node_cache: ${{ inputs.playwright_runs_on != 'self-hosted' && inputs.runs_on != 'self-hosted' }}
437-
enable_python_cache: ${{ inputs.playwright_runs_on != 'self-hosted' && inputs.runs_on != 'self-hosted' }}
438430
chromatic_enable: false # Set to false as we run chromatic below w/ playwright integration
439431
chromatic_project_token: ${{ secrets.CHROMATIC_PROJECT_TOKEN }}
440432
upload_yarn_lock: "node-yarn-lock-${{ inputs.branch || github.sha }}"

.github/workflows/build-node.yml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,5 @@ jobs:
7373
npm_registry: ${{ vars.NPM_REGISTRY }}
7474
github_ro_token: ${{ github.event.repository.private == true && secrets.DATAVISYN_BOT_REPO_TOKEN || github.token }}
7575
run_node_bundle: ${{ inputs.node_run_webpack }}
76-
enable_node_cache: ${{ inputs.runs_on != 'self-hosted' }}
7776
chromatic_enable: ${{ inputs.chromatic_enable }}
7877
chromatic_project_token: ${{ secrets.CHROMATIC_PROJECT_TOKEN }}

.github/workflows/build-python.yml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,4 +58,3 @@ jobs:
5858
enable_python: true
5959
github_ro_token: ${{ github.event.repository.private == true && secrets.DATAVISYN_BOT_REPO_TOKEN || github.token }}
6060
python_version: ${{ vars.PYTHON_VERSION || inputs.python_version }}
61-
enable_python_cache: ${{ inputs.runs_on != 'self-hosted' }}

0 commit comments

Comments
 (0)