Skip to content

Commit 8497527

Browse files
committed
fix(continuous-integration): improve support for working-directory
Signed-off-by: Emilien Escalle <[email protected]>
1 parent e96599d commit 8497527

File tree

1 file changed

+19
-10
lines changed

1 file changed

+19
-10
lines changed

.github/workflows/continuous-integration.yml

Lines changed: 19 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ on:
5858
Accepts a JSON object for lint options. See [lint action](../../actions/lint/README.md).
5959
It should generate lint reports in standard formats.
6060
61-
Example:
61+
Example:
6262
6363
```json:package.json
6464
{
@@ -90,7 +90,7 @@ on:
9090
Accepts a JSON object for test options. See [test action](../../actions/test/README.md).
9191
If coverage is enabled, it should generate test and coverage reports in standard formats.
9292
93-
Example:
93+
Example:
9494
9595
```json:package.json
9696
{
@@ -224,7 +224,7 @@ jobs:
224224
try {
225225
const {pathMapping: parsedPathMapping, ...parsedContainer} = JSON.parse(containerInput);
226226
core.debug(`Parsed container input as JSON: ${JSON.stringify(parsedContainer)}`);
227-
227+
228228
container = {
229229
...container,
230230
...parsedContainer,
@@ -234,7 +234,7 @@ jobs:
234234
core.debug(`Parsed path mapping: ${JSON.stringify(parsedPathMapping)}`);
235235
if (parsedPathMapping){
236236
pathMapping = parsedPathMapping;
237-
}
237+
}
238238
239239
} catch (error) {
240240
return core.setFailed(`Failed to parse container input as JSON: ${error.message}`,{ cause: error });
@@ -327,27 +327,25 @@ jobs:
327327
volumes: ${{ fromJSON(needs.prepare.outputs.container-volumes || '[]') }}
328328
credentials: ${{ fromJSON(needs.prepare.outputs.container-username && format('{{"username":{0},"password":{1}}}',toJSON(needs.prepare.outputs.container-username),toJSON(secrets.container-password)) || '{}') }}
329329
outputs:
330+
working-directory: ${{ steps.working-directory.outputs.working-directory }}
330331
build-env: ${{ steps.build-variables.outputs.env }}
331332
build-commands: ${{ steps.build-variables.outputs.commands }}
332333
build-artifact: ${{ steps.build-variables.outputs.artifact }}
333-
working-directory: ${{ steps.build-variables.outputs.working-directory }}
334334
steps:
335335
- name: Checkout repository
336336
if: inputs.container == ''
337337
uses: hoverkraft-tech/ci-github-common/actions/checkout@5e8d0e6d1e76d8577a070db6d0128a91b1c9d5ad # 0.30.2
338338

339-
- id: build-variables
340-
if: inputs.build != ''
339+
- id: working-directory
341340
uses: actions/github-script@ed597411d8f924073f98dfc5c65a23a2325f34cd # v8.0.0
342341
env:
343-
WORKING_DIRECTORY: ${{ inputs.working-directory }}
344-
BUILD_INPUT: ${{ inputs.build }}
342+
WORKING_DIRECTORY_INPUT: ${{ inputs.working-directory }}
345343
with:
346344
script: |
347345
const fs = require('node:fs');
348346
const path = require('node:path');
349347
350-
let workingDirectory = process.env.WORKING_DIRECTORY || '.';
348+
let workingDirectory = process.env.WORKING_DIRECTORY_INPUT || '.';
351349
if (!path.isAbsolute(workingDirectory)) {
352350
workingDirectory = path.join(process.env.GITHUB_WORKSPACE, workingDirectory);
353351
}
@@ -360,6 +358,17 @@ jobs:
360358
core.debug(`Running in working directory: ${workingDirectory}`);
361359
core.setOutput('working-directory', workingDirectory);
362360
361+
- id: build-variables
362+
if: inputs.build != ''
363+
uses: actions/github-script@ed597411d8f924073f98dfc5c65a23a2325f34cd # v8.0.0
364+
env:
365+
WORKING_DIRECTORY: ${{ steps.working-directory.outputs.working-directory }}
366+
BUILD_INPUT: ${{ inputs.build }}
367+
with:
368+
script: |
369+
const path = require('node:path');
370+
371+
const workingDirectory = process.env.WORKING_DIRECTORY;
363372
const buildInput = process.env.BUILD_INPUT.trim();
364373
365374
let commands = [];

0 commit comments

Comments
 (0)