@@ -276,25 +276,12 @@ jobs:
276276 - run : |
277277 if [ -f .gitignore ]; then grep -q "self-workflow" .gitignore || echo "self-workflow" >> .gitignore; else echo "self-workflow" >> .gitignore; fi
278278 if [ -f .dockerignore ]; then grep -q "self-workflow" .dockerignore || echo "self-workflow" >> .dockerignore; else echo "self-workflow" >> .dockerignore; fi
279+ # jscpd:ignore-end
279280
280- - id : setup-node
281- if : inputs.container == ''
282- uses : ./self-workflow/actions/setup-node
283- with :
284- working-directory : ${{ inputs.working-directory }}
285- dependencies-cache : |
286- nx
287- prettier
288-
289- - id : get-package-manager
290- if : inputs.container
291- uses : ./self-workflow/actions/get-package-manager
281+ - uses : ./self-workflow/actions/lint
292282 with :
293283 working-directory : ${{ inputs.working-directory }}
294- # jscpd:ignore-end
295-
296- - run : ${{ inputs.container && steps.get-package-manager.outputs.run-script-command || steps.setup-node.outputs.run-script-command }} lint
297- working-directory : ${{ inputs.working-directory }}
284+ container : ${{ inputs.container != '' }}
298285
299286 build :
300287 name : 🏗️ Build
@@ -311,7 +298,7 @@ jobs:
311298 # FIXME: This is a workaround for having workflow ref. See https://github.com/orgs/community/discussions/38659
312299 id-token : write
313300 outputs :
314- artifact-id : ${{ steps.build-artifact-id .outputs.artifact-id }}
301+ artifact-id : ${{ steps.build.outputs.artifact-id }}
315302 steps :
316303 - uses : hoverkraft-tech/ci-github-common/actions/checkout@5f11437c716059f30c635f90055060e4ef8b31a0 # 0.28.0
317304 if : needs.setup.outputs.build-commands && inputs.container == ''
@@ -333,79 +320,17 @@ jobs:
333320 if [ -f .gitignore ]; then grep -q "self-workflow" .gitignore || echo "self-workflow" >> .gitignore; else echo "self-workflow" >> .gitignore; fi
334321 if [ -f .dockerignore ]; then grep -q "self-workflow" .dockerignore || echo "self-workflow" >> .dockerignore; else echo "self-workflow" >> .dockerignore; fi
335322 # jscpd:ignore-end
336- - if : needs.setup.outputs.build-commands
337- uses : actions/github-script@ed597411d8f924073f98dfc5c65a23a2325f34cd # v8.0.0
338- env :
339- BUILD_ENV : ${{ needs.setup.outputs.build-env }}
340- BUILD_SECRETS : ${{ secrets.build-secrets }}
341- with :
342- script : |
343- const envInput = process.env.BUILD_ENV || '{}';
344-
345- let buildEnv = {};
346-
347- try {
348- buildEnv = JSON.parse(envInput);
349- } catch (e) {
350- core.setFailed(`Invalid build env JSON: ${e.message}`);
351- }
352-
353- for (const [key, value] of Object.entries(buildEnv)) {
354- core.exportVariable(key, value);
355- }
356-
357- const secretsInput = process.env.BUILD_SECRETS || '';
358- for (const line of secretsInput.split('\n').map(line => line.trim()).filter(Boolean)) {
359- const [key, ...rest] = line.split('=');
360- if (!key || !rest.length) {
361- return core.setFailed(`Invalid build secrets format: ${line}`);
362- }
363- const value = rest.join('=');
364- core.exportVariable(key.trim(), value.trim());
365- }
366323
367- - id : setup-node
368- if : needs.setup.outputs.build-commands && inputs.container == ''
369- uses : ./self-workflow/actions/setup-node
370- with :
371- working-directory : ${{ inputs.working-directory }}
372- dependencies-cache : |
373- nx
374- gatsby
375- storybook
376-
377- - id : get-package-manager
378- if : needs.setup.outputs.build-commands && inputs.container
379- uses : ./self-workflow/actions/get-package-manager
324+ - id : build
325+ if : needs.setup.outputs.build-commands
326+ uses : ./self-workflow/actions/build
380327 with :
381328 working-directory : ${{ inputs.working-directory }}
382-
383- - if : needs.setup.outputs.build-commands
384- working-directory : ${{ inputs.working-directory }}
385- env :
386- BUILD_COMMANDS : ${{ needs.setup.outputs.build-commands }}
387- RUN_SCRIPT_COMMAND : ${{ inputs.container && steps.get-package-manager.outputs.run-script-command || steps.setup-node.outputs.run-script-command }}
388- run : |
389- echo "$BUILD_COMMANDS" | while IFS= read -r COMMAND ; do
390- # Trim whitespace
391- COMMAND=$(echo "$COMMAND" | xargs)
392-
393- # Skip empty lines
394- if [ -z "$COMMAND" ]; then
395- continue
396- fi
397-
398- echo -e "\n - Running $COMMAND"
399- $RUN_SCRIPT_COMMAND "$COMMAND"
400- done
401-
402- - id : build-artifact-id
403- if : needs.setup.outputs.build-commands && needs.setup.outputs.build-artifact
404- uses : actions/upload-artifact@330a01c490aca151604b8cf639adc76d48f6c5d4 # v5.0.0
405- with :
406- name : ${{ fromJSON(needs.setup.outputs.build-artifact).name }}
407- path : ${{ fromJSON(needs.setup.outputs.build-artifact).paths }}
408- if-no-files-found : error
329+ build-commands : ${{ needs.setup.outputs.build-commands }}
330+ build-env : ${{ needs.setup.outputs.build-env }}
331+ build-secrets : ${{ secrets.build-secrets }}
332+ build-artifact : ${{ needs.setup.outputs.build-artifact }}
333+ container : ${{ inputs.container != '' }}
409334
410335 test :
411336 name : 🧪 Test
@@ -422,6 +347,7 @@ jobs:
422347 contents : read
423348 # FIXME: This is a workaround for having workflow ref. See https://github.com/orgs/community/discussions/38659
424349 id-token : write
350+ pull-requests : write
425351 steps :
426352 - uses : hoverkraft-tech/ci-github-common/actions/checkout@5f11437c716059f30c635f90055060e4ef8b31a0 # 0.28.0
427353 if : inputs.container == ''
@@ -446,43 +372,8 @@ jobs:
446372 if [ -f .gitignore ]; then grep -q "self-workflow" .gitignore || echo "self-workflow" >> .gitignore; else echo "self-workflow" >> .gitignore; fi
447373 if [ -f .dockerignore ]; then grep -q "self-workflow" .dockerignore || echo "self-workflow" >> .dockerignore; else echo "self-workflow" >> .dockerignore; fi
448374
449- - id : setup-node
450- if : inputs.container == ''
451- uses : ./self-workflow/actions/setup-node
375+ - uses : ./self-workflow/actions/test
452376 with :
453377 working-directory : ${{ inputs.working-directory }}
454- dependencies-cache : |
455- nx
456- jest
457-
458- - id : get-package-manager
459- if : needs.setup.outputs.build-commands && inputs.container
460- uses : ./self-workflow/actions/get-package-manager
461- with :
462- working-directory : ${{ inputs.working-directory }}
463-
464- - run : ${{ inputs.container && steps.get-package-manager.outputs.run-script-command || steps.setup-node.outputs.run-script-command }} test:ci
465- working-directory : ${{ inputs.working-directory }}
466- env :
467- CI : " true"
468-
469- - if : inputs.coverage == 'codecov' && inputs.container
470- env :
471- REQUIRED_DEPS : |
472- git
473- curl
474- gpg
475- run : |
476- apt-get update
477- for dep in $REQUIRED_DEPS; do
478- if ! dpkg -s "$dep" >/dev/null 2>&1; then
479- apt-get install -y "$dep"
480- fi
481- done
482-
483- - name : 📊 Code coverage
484- if : inputs.coverage == 'codecov'
485- uses : codecov/codecov-action@5a1091511ad55cbe89839c7260b706298ca349f7 # v5.5.1
486- with :
487- use_oidc : true
488- disable_telem : true
378+ container : ${{ inputs.container != '' }}
379+ coverage : ${{ inputs.coverage }}
0 commit comments