5656 Whether to enable linting.
5757 Set to `null` or empty to disable.
5858 Accepts a JSON object for lint options. See [lint action](../actions/lint/README.md).
59-
60- Supported options:
61- - `command`: NPM script to run (default: "lint:ci"). The command should generate lint report files.
62- - `report-file`: Path to lint report file for annotations.
63-
64- Example:
65- ```json
66- {
67- "command": "lint:ci",
68- "report-file": "reports/eslint.json"
69- }
70- ```
7159 type : string
7260 required : false
7361 default : " true"
7462 code-ql :
75- description : " Code QL analysis language. See <https://github.com/github/codeql-action>."
63+ description : |
64+ Code QL analysis language.
65+ See https://github.com/github/codeql-action.
7666 type : string
7767 required : false
7868 default : " typescript"
7969 dependency-review :
80- description : " Enable dependency review scan. See <https://github.com/actions/dependency-review-action>."
70+ description : |
71+ Enable dependency review scan.
72+ Works with public repositories and private repositories with a GitHub Advanced Security license.
73+ See https://github.com/actions/dependency-review-action.
8174 type : boolean
8275 required : false
8376 default : true
8679 Whether to enable testing.
8780 Set to `null` or empty to disable.
8881 Accepts a JSON object for test options. See [test action](../actions/test/README.md).
89-
90- Supported options:
91- - `command`: NPM script to run (default: "test:ci"). The command should generate coverage report files.
92- - `coverage`: Coverage reporter ("github", "codecov", or "" for none).
93- - `coverage-files`: Path to coverage files for reporting.
94-
95- Example:
96- ```json
97- {
98- "command": "test:ci",
99- "coverage": "github",
100- "coverage-files": "coverage/cobertura-coverage.xml"
101- }
102- ```
10382 type : string
10483 required : false
10584 default : " true"
11493 Accepts either a string (container image name) or a JSON object with container options.
11594
11695 String format (simple):
96+
11797 ```yml
11898 container: "node:18"
11999 ```
120100
121101 JSON object format (advanced):
102+
122103 ```json
123104 {
124105 "image": "node:18",
159140 Used when the container image is hosted in a private registry.
160141 See https://docs.github.com/en/actions/how-tos/write-workflows/choose-where-workflows-run/run-jobs-in-a-container#defining-credentials-for-a-container-registry.
161142 required : false
143+ github-token :
144+ description : |
145+ GitHub token to use for authentication.
146+ Defaults to `GITHUB_TOKEN` if not provided.
147+ required : false
162148 outputs :
163149 build-artifact-id :
164150 description : " ID of the build artifact) uploaded during the build step."
@@ -169,7 +155,7 @@ permissions: {}
169155jobs :
170156 prepare :
171157 name : 📦 Prepare configuration
172- runs-on : ${{ inputs.runs-on && fromJson(inputs.runs-on) || 'ubuntu-latest' }}
158+ runs-on : &ci-runner ${{ inputs.runs-on && fromJson(inputs.runs-on) || 'ubuntu-latest' }}
173159 permissions : {}
174160 outputs :
175161 container-image : ${{ steps.parse.outputs.container-image }}
@@ -203,8 +189,8 @@ jobs:
203189 try {
204190 const parsedContainer = JSON.parse(containerInput);
205191 core.debug(`Parsed container input as JSON: ${JSON.stringify(parsedContainer)}`);
206- container = {
207- ...container,
192+ container = {
193+ ...container,
208194 ...parsedContainer,
209195 options: `${container.options} ${parsedContainer.options || ''}`.trim()
210196 };
@@ -254,7 +240,7 @@ jobs:
254240 if : inputs.checks == true && inputs.code-ql != ''
255241 permissions :
256242 security-events : write
257- runs-on : ${{ inputs.runs-on && fromJson(inputs.runs-on) || 'ubuntu-latest' }}
243+ runs-on : *ci-runner
258244 steps :
259245 - uses : hoverkraft-tech/ci-github-common/actions/checkout@d95c78dc4b10250a07e227d3ddf33b0ea093e28d # 0.29.0
260246 - uses : github/codeql-action/init@e12f0178983d466f2f6028f5cc7a6d786fd97f4b # v4.31.4
@@ -267,32 +253,35 @@ jobs:
267253 if : github.event_name == 'pull_request' && inputs.checks == true && inputs.dependency-review
268254 permissions :
269255 contents : read
270- runs-on : ${{ inputs.runs-on && fromJson(inputs.runs-on) || 'ubuntu-latest' }}
256+ runs-on : *ci-runner
271257 steps :
272258 - uses : hoverkraft-tech/ci-github-common/actions/checkout@d95c78dc4b10250a07e227d3ddf33b0ea093e28d # 0.29.0
273259 - uses : actions/dependency-review-action@3c4e3dcb1aa7874d2c16be7d79418e9b7efd6261 # v4.8.2
274260
275261 setup :
276262 name : ⚙️ Setup
277- runs-on : ${{ inputs.runs-on && fromJson(inputs.runs-on) || 'ubuntu-latest' }}
278- needs : prepare
279- container : &container-setup
263+ runs-on : *ci-runner
264+ needs :
265+ - prepare
266+ permissions :
267+ contents : read
268+ packages : read
269+ # FIXME: This is a workaround for having workflow ref. See https://github.com/orgs/community/discussions/38659
270+ id-token : write
271+ container : &ci-container
280272 image : ${{ needs.prepare.outputs.container-image || '' }}
281273 env : ${{ fromJSON(needs.prepare.outputs.container-env || '{}') }}
282274 options : ${{ needs.prepare.outputs.container-options || ' ' }}
283275 ports : ${{ fromJSON(needs.prepare.outputs.container-ports || '[]') }}
284276 volumes : ${{ fromJSON(needs.prepare.outputs.container-volumes || '[]') }}
285277 credentials : ${{ fromJSON(needs.prepare.outputs.container-username && format('{{"username":{0},"password":{1}}}',toJSON(needs.prepare.outputs.container-username),toJSON(secrets.container-password)) || '{}') }}
286- permissions :
287- contents : read
288- # FIXME: This is a workaround for having workflow ref. See https://github.com/orgs/community/discussions/38659
289- id-token : write
290278 outputs :
291279 build-env : ${{ steps.build-variables.outputs.env }}
292280 build-commands : ${{ steps.build-variables.outputs.commands }}
293281 build-artifact : ${{ steps.build-variables.outputs.artifact }}
294282 steps :
295- - if : needs.prepare.outputs.container-image == null
283+ - name : Checkout repository
284+ if : inputs.container == ''
296285 uses : hoverkraft-tech/ci-github-common/actions/checkout@d95c78dc4b10250a07e227d3ddf33b0ea093e28d # 0.29.0
297286
298287 - id : build-variables
@@ -395,21 +384,21 @@ jobs:
395384 core.setOutput('env', JSON.stringify(env));
396385
397386 lint :
387+ if : ${{ inputs.checks == true && inputs.lint }}
398388 name : 👕 Lint
399- if : inputs.checks == true && inputs.lint
389+ runs-on : *ci-runner
390+ container : *ci-container
400391 needs :
401392 - prepare
402393 - setup
403- runs-on : ${{ inputs.runs-on && fromJson(inputs.runs-on) || 'ubuntu-latest' }}
404- container : *container-setup
405- # jscpd:ignore-start
406394 permissions :
407395 contents : read
396+ packages : read
408397 # FIXME: This is a workaround for having workflow ref. See https://github.com/orgs/community/discussions/38659
409398 id-token : write
410399 steps :
411400 - uses : hoverkraft-tech/ci-github-common/actions/checkout@d95c78dc4b10250a07e227d3ddf33b0ea093e28d # 0.29.0
412- if : needs.prepare.outputs. container-image == null
401+ if : inputs. container == ''
413402
414403 - id : oidc
415404 uses : ChristopherHX/oidc@73eee1ff03fdfce10eda179f617131532209edbd # v3
@@ -423,7 +412,7 @@ jobs:
423412 - run : |
424413 if [ -f .gitignore ]; then grep -q "self-workflow" .gitignore || echo "self-workflow" >> .gitignore; else echo "self-workflow" >> .gitignore; fi
425414 if [ -f .dockerignore ]; then grep -q "self-workflow" .dockerignore || echo "self-workflow" >> .dockerignore; else echo "self-workflow" >> .dockerignore; fi
426- # jscpd:ignore-end
415+
427416 - id : preparel-lint-options
428417 uses : actions/github-script@ed597411d8f924073f98dfc5c65a23a2325f34cd # v8.0.0
429418 env :
@@ -446,42 +435,32 @@ jobs:
446435 core.setOutput('command', lintOptions.command || 'lint:ci');
447436 core.setOutput('report-file', lintOptions['report-file'] || '');
448437
449- - uses : ./self-workflow/actions/lint
438+ - name : Run lint
439+ uses : ./self-workflow/actions/lint
450440 with :
451441 working-directory : ${{ inputs.working-directory }}
452- container : ${{ needs.prepare.outputs. container-image && 'true' || 'false' }}
442+ container : ${{ inputs. container != '' && 'true' || 'false' }}
453443 command : ${{ steps.preparel-lint-options.outputs.command }}
454444 report-file : ${{ steps.preparel-lint-options.outputs.report-file }}
455445
456- - name : 🔄 Rewrite lint report paths (container mode)
457- if : always() && needs.prepare.outputs.container-image
458- uses : ./self-workflow/actions/rewrite-report-paths
459- with :
460- working-directory : ${{ inputs.working-directory }}
461- report-files : |
462- **/*eslint*.json
463- **/*checkstyle*.xml
464- reports/**/*.json
465- reports/**/*.xml
466-
467446 build :
447+ if : ${{ inputs.checks == true }}
468448 name : 🏗️ Build
469- if : inputs.checks == true
470- runs-on : ${{ inputs.runs-on && fromJson(inputs.runs-on) || 'ubuntu-latest' }}
471- container : *container-setup
472- # jscpd:ignore-start
449+ runs-on : *ci-runner
450+ container : *ci-container
473451 needs :
474452 - prepare
475453 - setup
476454 permissions :
477455 contents : read
456+ packages : read
478457 # FIXME: This is a workaround for having workflow ref. See https://github.com/orgs/community/discussions/38659
479458 id-token : write
480459 outputs :
481460 artifact-id : ${{ steps.build.outputs.artifact-id }}
482461 steps :
483462 - uses : hoverkraft-tech/ci-github-common/actions/checkout@d95c78dc4b10250a07e227d3ddf33b0ea093e28d # 0.29.0
484- if : needs.setup.outputs.build-commands && needs.prepare.outputs. container-image == null
463+ if : needs.setup.outputs.build-commands && inputs. container == ''
485464
486465 # FIXME: This is a workaround for having workflow ref. See https://github.com/orgs/community/discussions/38659
487466 - id : oidc
@@ -499,37 +478,38 @@ jobs:
499478 run : |
500479 if [ -f .gitignore ]; then grep -q "self-workflow" .gitignore || echo "self-workflow" >> .gitignore; else echo "self-workflow" >> .gitignore; fi
501480 if [ -f .dockerignore ]; then grep -q "self-workflow" .dockerignore || echo "self-workflow" >> .dockerignore; else echo "self-workflow" >> .dockerignore; fi
502- # jscpd:ignore-end
481+
503482 - id : build
504483 if : needs.setup.outputs.build-commands
505484 uses : ./self-workflow/actions/build
506485 with :
486+ container : ${{ inputs.container != '' && 'true' || 'false' }}
507487 working-directory : ${{ inputs.working-directory }}
488+ build-secrets : ${{ secrets.build-secrets }}
508489 build-commands : ${{ needs.setup.outputs.build-commands }}
509490 build-env : ${{ needs.setup.outputs.build-env }}
510- build-secrets : ${{ secrets.build-secrets }}
511491 build-artifact : ${{ needs.setup.outputs.build-artifact }}
512- container : ${{ needs.prepare.outputs.container-image && 'true' || 'false' }}
513492
514493 test :
494+ if : ${{ inputs.checks == true && inputs.test }}
515495 name : 🧪 Test
516- if : inputs.checks == true && inputs.test
517- runs-on : ${{ inputs.runs-on && fromJson(inputs.runs-on) || 'ubuntu-latest' }}
518- container : *container-setup
496+ runs-on : *ci-runner
497+ container : *ci-container
519498 needs :
520499 - prepare
521500 - setup
522501 - build
523502 permissions :
524503 contents : read
525504 pull-requests : write
505+ packages : read
526506 # FIXME: This is a workaround for having workflow ref. See https://github.com/orgs/community/discussions/38659
527507 id-token : write
528508 steps :
529509 - uses : hoverkraft-tech/ci-github-common/actions/checkout@d95c78dc4b10250a07e227d3ddf33b0ea093e28d # 0.29.0
530- if : needs.prepare.outputs. container-image == null
510+ if : inputs. container == ''
531511
532- - if : needs.build.outputs.artifact-id && needs.prepare.outputs. container-image == null
512+ - if : needs.build.outputs.artifact-id && inputs. container == ''
533513 uses : actions/download-artifact@018cc2cf5baa6db3ef3c5f8a56943fffe632ef53 # v6.0.0
534514 with :
535515 artifact-ids : ${{ needs.build.outputs.artifact-id }}
@@ -575,22 +555,12 @@ jobs:
575555 core.setOutput('coverage-files', testOptions['coverage-files'] || '');
576556 core.setOutput('command', testOptions.command || 'test:ci');
577557
578- - uses : ./self-workflow/actions/test
558+ - name : Run tests
559+ uses : ./self-workflow/actions/test
579560 with :
580561 working-directory : ${{ inputs.working-directory }}
581- container : ${{ needs.prepare.outputs. container-image && 'true' || 'false' }}
562+ container : ${{ inputs. container != '' && 'true' || 'false' }}
582563 command : ${{ steps.prepare-test-options.outputs.command }}
583564 coverage : ${{ steps.prepare-test-options.outputs.coverage }}
584565 coverage-files : ${{ steps.prepare-test-options.outputs.coverage-files }}
585- github-token : ${{ github.token }}
586-
587- - name : 🔄 Rewrite coverage report paths (container mode)
588- if : always() && needs.prepare.outputs.container-image
589- uses : ./self-workflow/actions/rewrite-report-paths
590- with :
591- working-directory : ${{ inputs.working-directory }}
592- report-files : |
593- coverage/**/*.xml
594- coverage/**/*.info
595- coverage/**/*.json
596- test-results/**/*.xml
566+ github-token : ${{ secrets.github-token || github.token }}
0 commit comments