|
1 | | -# Build Action |
| 1 | +<!-- header:start --> |
2 | 2 |
|
3 | | -Composite action to build Node.js projects with support for custom commands, environment variables, and artifact handling. |
| 3 | +#  GitHub Action: Build |
| 4 | + |
| 5 | +<div align="center"> |
| 6 | + <img src="https://opengraph.githubassets.com/b83a39d0a270998cbae0974683a11eba4481aa44bbb4abbc39522474251c5b0a/hoverkraft-tech/ci-github-nodejs" width="60px" align="center" alt="Build" /> |
| 7 | +</div> |
| 8 | + |
| 9 | +--- |
| 10 | + |
| 11 | +<!-- header:end --> |
| 12 | +<!-- badges:start --> |
| 13 | + |
| 14 | +[](https://github.com/marketplace/actions/build) |
| 15 | +[](https://github.com/hoverkraft-tech/ci-github-nodejs/releases) |
| 16 | +[](http://choosealicense.com/licenses/mit/) |
| 17 | +[](https://img.shields.io/github/stars/hoverkraft-tech/ci-github-nodejs?style=social) |
| 18 | +[](https://github.com/hoverkraft-tech/ci-github-nodejs/blob/main/CONTRIBUTING.md) |
| 19 | + |
| 20 | +<!-- badges:end --> |
| 21 | +<!-- overview:start --> |
| 22 | + |
| 23 | +## Overview |
| 24 | + |
| 25 | +Action to build Node.js projects with support for custom commands, environment variables, and artifact handling |
| 26 | + |
| 27 | +<!-- overview:end --> |
| 28 | +<!-- usage:start --> |
4 | 29 |
|
5 | 30 | ## Usage |
6 | 31 |
|
7 | | -```yaml |
8 | | -- uses: hoverkraft-tech/ci-github-nodejs/actions/build@main |
| 32 | +````yaml |
| 33 | +- uses: hoverkraft-tech/ci-github-nodejs/actions/build@db1c1d36ff3e87c4513eded15d85acb78dcbd9b9 # copilot/refactor-ci-actions-lint-test |
9 | 34 | with: |
10 | | - # Working directory where build commands are executed |
11 | | - # Default: "." |
12 | | - working-directory: "." |
13 | | - |
14 | | - # List of build commands to execute (npm/pnpm/yarn script names) |
15 | | - # Required |
16 | | - build-commands: | |
17 | | - build |
18 | | - compile |
19 | | -
|
20 | | - # JSON object of environment variables for the build |
21 | | - # Default: "{}" |
22 | | - build-env: | |
23 | | - { |
24 | | - "NODE_ENV": "production", |
25 | | - "API_URL": "https://api.example.com" |
26 | | - } |
27 | | -
|
28 | | - # Multi-line string of secrets in env format |
29 | | - # Default: "" |
30 | | - build-secrets: | |
31 | | - SECRET_KEY=${{ secrets.SECRET_KEY }} |
32 | | - API_TOKEN=${{ secrets.API_TOKEN }} |
33 | | -
|
34 | | - # JSON object for artifact upload configuration |
35 | | - # Default: "" |
36 | | - build-artifact: | |
37 | | - { |
38 | | - "name": "build-artifacts", |
39 | | - "paths": "dist/\nbuild/" |
40 | | - } |
| 35 | + # Working directory where the build commands are executed. |
| 36 | + # Can be absolute or relative to the repository root. |
| 37 | + # |
| 38 | + # Default: `.` |
| 39 | + working-directory: . |
| 40 | + |
| 41 | + # List of build commands to execute, one per line. |
| 42 | + # These are npm/pnpm/yarn script names (e.g., "build", "compile"). |
| 43 | + # |
| 44 | + # This input is required. |
| 45 | + build-commands: "" |
| 46 | + |
| 47 | + # JSON object of environment variables to set during the build. |
| 48 | + # Example: {"NODE_ENV": "production", "API_URL": "https://api.example.com"} |
| 49 | + # |
| 50 | + # Default: `{}` |
| 51 | + build-env: "{}" |
| 52 | + |
| 53 | + # Multi-line string of secrets in env format (KEY=VALUE). |
| 54 | + # Example: |
| 55 | + # ``` |
| 56 | + # SECRET_KEY=${{ secrets.SECRET_KEY }} |
| 57 | + # API_TOKEN=${{ secrets.API_TOKEN }} |
| 58 | + # ``` |
| 59 | + build-secrets: "" |
| 60 | + |
| 61 | + # JSON object specifying artifact upload configuration. |
| 62 | + # Format: {"name": "artifact-name", "paths": "path1\npath2"} |
| 63 | + build-artifact: "" |
41 | 64 |
|
42 | 65 | # Whether running in container mode (skips checkout and node setup) |
43 | | - # Default: "false" |
| 66 | + # Default: `false` |
44 | 67 | container: "false" |
45 | | -``` |
| 68 | +```` |
| 69 | + |
| 70 | +<!-- usage:end --> |
| 71 | +<!-- inputs:start --> |
46 | 72 |
|
47 | 73 | ## Inputs |
48 | 74 |
|
49 | | -| Name | Description | Required | Default | |
50 | | -| ------------------- | ---------------------------------------------------------------------------- | -------- | ------- | |
51 | | -| `working-directory` | Working directory where build commands are executed | No | `.` | |
52 | | -| `build-commands` | List of build commands to execute (npm/pnpm/Yarn script names), one per line | Yes | - | |
53 | | -| `build-env` | JSON object of environment variables to set during the build | No | `{}` | |
54 | | -| `build-secrets` | Multi-line string of secrets in env format (KEY=VALUE) | No | `""` | |
55 | | -| `build-artifact` | JSON object specifying artifact upload configuration | No | `""` | |
56 | | -| `container` | Whether running in container mode (skips checkout and node setup) | No | `false` | |
| 75 | +| **Input** | **Description** | **Required** | **Default** | |
| 76 | +| ----------------------- | --------------------------------------------------------------------------------------------------------------------------------------- | ------------ | ----------- | |
| 77 | +| **`working-directory`** | Working directory where the build commands are executed. | **false** | `.` | |
| 78 | +| | Can be absolute or relative to the repository root. | | | |
| 79 | +| **`build-commands`** | List of build commands to execute, one per line. | **true** | - | |
| 80 | +| | These are npm/pnpm/Yarn script names (e.g., "build", "compile"). | | | |
| 81 | +| **`build-env`** | JSON object of environment variables to set during the build. | **false** | `\{}` | |
| 82 | +| | Example: {"NODE_ENV": "production", "API_URL": "<https://api.example.com"}> | | | |
| 83 | +| **`build-secrets`** | Multi-line string of secrets in env format (KEY=VALUE). | **false** | - | |
| 84 | +| | Example: | | | |
| 85 | +| | <!-- textlint-disable --><pre>SECRET_KEY=${{ secrets.SECRET_KEY }} API_TOKEN=${{ secrets.API_TOKEN }}</pre><!-- textlint-enable --> | | | |
| 86 | +| **`build-artifact`** | JSON object specifying artifact upload configuration. | **false** | - | |
| 87 | +| | Format: {"name": "artifact-name", "paths": "path1\npath2"} | | | |
| 88 | +| **`container`** | Whether running in container mode (skips checkout and node setup) | **false** | `false` | |
| 89 | + |
| 90 | +<!-- inputs:end --> |
| 91 | +<!-- secrets:start --> |
| 92 | +<!-- secrets:end --> |
| 93 | +<!-- outputs:start --> |
57 | 94 |
|
58 | 95 | ## Outputs |
59 | 96 |
|
60 | | -| Name | Description | |
61 | | -| ------------- | ------------------------------------------------------- | |
62 | | -| `artifact-id` | ID of the uploaded artifact (if artifact was specified) | |
| 97 | +| **Output** | **Description** | |
| 98 | +| ----------------- | ------------------------------------------------------- | |
| 99 | +| **`artifact-id`** | ID of the uploaded artifact (if artifact was specified) | |
63 | 100 |
|
64 | | -## Examples |
| 101 | +<!-- outputs:end --> |
| 102 | +<!-- examples:start --> |
| 103 | +<!-- examples:end --> |
| 104 | +<!-- contributing:start --> |
65 | 105 |
|
66 | | -### Basic build |
| 106 | +## Contributing |
67 | 107 |
|
68 | | -```yaml |
69 | | -- uses: hoverkraft-tech/ci-github-nodejs/actions/build@main |
70 | | - with: |
71 | | - build-commands: "build" |
72 | | -``` |
| 108 | +Contributions are welcome! Please see the [contributing guidelines](https://github.com/hoverkraft-tech/ci-github-nodejs/blob/main/CONTRIBUTING.md) for more details. |
73 | 109 |
|
74 | | -### Build with artifact upload |
| 110 | +<!-- contributing:end --> |
| 111 | +<!-- security:start --> |
| 112 | +<!-- security:end --> |
| 113 | +<!-- license:start --> |
75 | 114 |
|
76 | | -```yaml |
77 | | -- uses: hoverkraft-tech/ci-github-nodejs/actions/build@main |
78 | | - with: |
79 | | - build-commands: | |
80 | | - build |
81 | | - package |
82 | | - build-artifact: | |
83 | | - { |
84 | | - "name": "build-output", |
85 | | - "paths": "dist/" |
86 | | - } |
87 | | -``` |
88 | | - |
89 | | -### Build with environment variables and secrets |
90 | | - |
91 | | -```yaml |
92 | | -- uses: hoverkraft-tech/ci-github-nodejs/actions/build@main |
93 | | - with: |
94 | | - build-commands: "build" |
95 | | - build-env: | |
96 | | - { |
97 | | - "NODE_ENV": "production", |
98 | | - "API_URL": "https://api.example.com" |
99 | | - } |
100 | | - build-secrets: | |
101 | | - SECRET_KEY=${{ secrets.SECRET_KEY }} |
102 | | -``` |
| 115 | +## License |
| 116 | + |
| 117 | +This project is licensed under the MIT License. |
| 118 | + |
| 119 | +SPDX-License-Identifier: MIT |
| 120 | + |
| 121 | +Copyright © 2025 Hoverkraft |
| 122 | + |
| 123 | +For more details, see the [license](http://choosealicense.com/licenses/mit/). |
| 124 | + |
| 125 | +<!-- license:end --> |
| 126 | +<!-- generated:start --> |
| 127 | + |
| 128 | +--- |
| 129 | + |
| 130 | +This documentation was automatically generated by [CI Dokumentor](https://github.com/hoverkraft-tech/ci-dokumentor). |
| 131 | + |
| 132 | +<!-- generated:end --> |
0 commit comments