@github-actions-workflow-ts/cli 2.0.0-beta.0 → 2.0.0-beta.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +127 -0
- package/package.json +2 -2
package/README.md
ADDED
|
@@ -0,0 +1,127 @@
|
|
|
1
|
+
# @github-actions-workflow-ts/cli
|
|
2
|
+
|
|
3
|
+
CLI to generate GitHub Actions YAML workflow files from TypeScript.
|
|
4
|
+
|
|
5
|
+
Stop writing workflows in YAML and use TypeScript instead!
|
|
6
|
+
|
|
7
|
+
<p align="center"><img src="https://github.com/emmanuelnk/github-actions-workflow-ts/assets/19330930/9121bb33-cd51-41f3-830f-9b4bd1117320" alt="github-actions-workflow-ts-logo" width="400"/></p>
|
|
8
|
+
|
|
9
|
+
<p align="center">
|
|
10
|
+
<a href="https://github.com/emmanuelnk/github-actions-workflow-ts">
|
|
11
|
+
<img src="https://raw.githubusercontent.com/ellerbrock/open-source-badges/master/badges/open-source-v1/open-source.png" alt="love opensource">
|
|
12
|
+
</a>
|
|
13
|
+
<a href="https://github.com/emmanuelnk/github-actions-workflow-ts/blob/master/LICENSE">
|
|
14
|
+
<img src="https://img.shields.io/badge/license-MIT-green.svg" alt="license">
|
|
15
|
+
</a>
|
|
16
|
+
<a href="https://www.npmjs.com/package/@github-actions-workflow-ts/cli">
|
|
17
|
+
<img src="https://img.shields.io/npm/v/@github-actions-workflow-ts/cli.svg" alt="npm version">
|
|
18
|
+
</a>
|
|
19
|
+
</p>
|
|
20
|
+
|
|
21
|
+
## Installation
|
|
22
|
+
|
|
23
|
+
Install both the library and CLI:
|
|
24
|
+
|
|
25
|
+
```bash
|
|
26
|
+
npm install --save-dev @github-actions-workflow-ts/lib @github-actions-workflow-ts/cli
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
## Usage
|
|
30
|
+
|
|
31
|
+
### 1. Write your workflow in TypeScript
|
|
32
|
+
|
|
33
|
+
Create a `*.wac.ts` file (e.g., `deploy.wac.ts`) anywhere in your project:
|
|
34
|
+
|
|
35
|
+
```ts
|
|
36
|
+
import { Workflow, NormalJob, Step } from '@github-actions-workflow-ts/lib'
|
|
37
|
+
|
|
38
|
+
const checkoutStep = new Step({
|
|
39
|
+
name: 'Checkout',
|
|
40
|
+
uses: 'actions/checkout@v3',
|
|
41
|
+
})
|
|
42
|
+
|
|
43
|
+
const testJob = new NormalJob('Test', {
|
|
44
|
+
'runs-on': 'ubuntu-latest',
|
|
45
|
+
'timeout-minutes': 2
|
|
46
|
+
})
|
|
47
|
+
|
|
48
|
+
// IMPORTANT: Export the workflow to generate the YAML file
|
|
49
|
+
export const exampleWorkflow = new Workflow('example-filename', {
|
|
50
|
+
name: 'Example',
|
|
51
|
+
on: {
|
|
52
|
+
workflow_dispatch: {}
|
|
53
|
+
}
|
|
54
|
+
})
|
|
55
|
+
|
|
56
|
+
testJob.addStep(checkoutStep)
|
|
57
|
+
exampleWorkflow.addJob(testJob)
|
|
58
|
+
```
|
|
59
|
+
|
|
60
|
+
### 2. Generate the YAML files
|
|
61
|
+
|
|
62
|
+
```bash
|
|
63
|
+
npx gwf build
|
|
64
|
+
|
|
65
|
+
# OR
|
|
66
|
+
|
|
67
|
+
npx generate-workflow-files build
|
|
68
|
+
```
|
|
69
|
+
|
|
70
|
+
This will generate `.github/workflows/example-filename.yml` from your TypeScript workflow definition.
|
|
71
|
+
|
|
72
|
+
## CLI Commands
|
|
73
|
+
|
|
74
|
+
| Command | Alias | Description |
|
|
75
|
+
|---------|-------|-------------|
|
|
76
|
+
| `gwf build` | `generate-workflow-files build`, `gawts build` | Generate YAML workflow files from `*.wac.ts` files |
|
|
77
|
+
|
|
78
|
+
## Configuration
|
|
79
|
+
|
|
80
|
+
Create a `wac.config.json` file in your project root to customize generation:
|
|
81
|
+
|
|
82
|
+
```json
|
|
83
|
+
{
|
|
84
|
+
"refs": false,
|
|
85
|
+
"headerText": [
|
|
86
|
+
"# Auto-generated from <source-file-path>",
|
|
87
|
+
"# Do not edit this file directly"
|
|
88
|
+
]
|
|
89
|
+
}
|
|
90
|
+
```
|
|
91
|
+
|
|
92
|
+
| Property | Description | Default |
|
|
93
|
+
|----------|-------------|---------|
|
|
94
|
+
| `refs` | Convert duplicate objects into YAML references | `false` |
|
|
95
|
+
| `headerText` | Custom header text for generated files. Use `<source-file-path>` as placeholder. | Default header |
|
|
96
|
+
| `dumpOptions` | Options for js-yaml dump function | Default options |
|
|
97
|
+
|
|
98
|
+
## Integration with Husky
|
|
99
|
+
|
|
100
|
+
For seamless automation, integrate with [husky](https://github.com/typicode/husky):
|
|
101
|
+
|
|
102
|
+
```bash
|
|
103
|
+
npm install --save-dev husky
|
|
104
|
+
npx husky-init
|
|
105
|
+
```
|
|
106
|
+
|
|
107
|
+
Add to `package.json`:
|
|
108
|
+
```json
|
|
109
|
+
{
|
|
110
|
+
"scripts": {
|
|
111
|
+
"build:workflows": "npx gwf build && git add .github/workflows/*.yml"
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
```
|
|
115
|
+
|
|
116
|
+
Add pre-commit hook:
|
|
117
|
+
```bash
|
|
118
|
+
npx husky add .husky/pre-commit "npm run build:workflows"
|
|
119
|
+
```
|
|
120
|
+
|
|
121
|
+
## Documentation
|
|
122
|
+
|
|
123
|
+
For full documentation, examples, and API reference, visit the [main repository](https://github.com/emmanuelnk/github-actions-workflow-ts).
|
|
124
|
+
|
|
125
|
+
## License
|
|
126
|
+
|
|
127
|
+
MIT
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@github-actions-workflow-ts/cli",
|
|
3
|
-
"version": "2.0.0-beta.
|
|
3
|
+
"version": "2.0.0-beta.1",
|
|
4
4
|
"description": "CLI to generate GitHub Actions YAML from TypeScript workflow files",
|
|
5
5
|
"author": "Emmanuel N Kyeyune",
|
|
6
6
|
"license": "MIT",
|
|
@@ -34,7 +34,7 @@
|
|
|
34
34
|
"js-yaml": "^4.1.0",
|
|
35
35
|
"tsx": "^4.19.3",
|
|
36
36
|
"yargs": "^17.7.2",
|
|
37
|
-
"@github-actions-workflow-ts/lib": "2.0.0-beta.
|
|
37
|
+
"@github-actions-workflow-ts/lib": "2.0.0-beta.1"
|
|
38
38
|
},
|
|
39
39
|
"devDependencies": {
|
|
40
40
|
"@jest/globals": "^29.7.0",
|