Permalink
June 4, 2021 09:44
June 4, 2021 09:44
June 4, 2021 09:44
June 4, 2021 09:44
June 4, 2021 09:44
June 4, 2021 09:44
June 4, 2021 09:44
June 4, 2021 09:44
June 4, 2021 09:44
June 4, 2021 09:44
Newer
100644
93 lines (61 sloc)
2.17 KB
2
3
> First, you'll need to have a reasonably modern version of `node` handy. This won't work with versions older than 9, for instance.
4
7
```bash
8
$ npm install
9
```
10
11
Build the typescript and package it for distribution
13
```bash
15
```
16
19
```bash
20
$ npm test
21
22
PASS ./index.test.js
23
✓ throws invalid number (3ms)
24
✓ wait 500 ms (504ms)
25
✓ test runs (95ms)
26
27
...
28
```
29
30
## Change action.yml
31
32
The action.yml contains defines the inputs and output for your action.
33
34
Update the action.yml with your name, description, inputs and outputs for your action.
35
36
See the [documentation](https://help.github.com/en/articles/metadata-syntax-for-github-actions)
37
38
## Change the Code
39
40
Most toolkit and CI/CD operations involve async operations so the action is run in an async function.
41
42
```javascript
43
import * as core from '@actions/core';
44
...
45
46
async function run() {
48
...
50
catch (error) {
51
core.setFailed(error.message);
52
}
53
}
54
55
run()
56
```
57
58
See the [toolkit documentation](https://github.com/actions/toolkit/blob/master/README.md#packages) for the various packages.
59
60
## Publish to a distribution branch
61
63
64
Then run [ncc](https://github.com/zeit/ncc) and push the results:
66
```bash
67
$ npm run package
68
$ git add dist
69
$ git commit -a -m "prod dependencies"
70
$ git push origin releases/v1
71
```
72
73
Note: We recommend using the `--license` option for ncc, which will create a license file for all of the production node modules used in your project.
74
76
77
See the [versioning documentation](https://github.com/actions/toolkit/blob/master/docs/action-versioning.md)
78
79
## Validate
80
81
You can now validate the action by referencing `./` in a workflow in your repo (see [test.yml](.github/workflows/test.yml))
82
83
```yaml
84
uses: ./
85
with:
86
milliseconds: 1000
87
```
88
89
See the [actions tab](https://github.com/actions/typescript-action/actions) for runs of this action! :rocket:
90
91
## Usage:
92
93
After testing you can [create a v1 tag](https://github.com/actions/toolkit/blob/master/docs/action-versioning.md) to reference the stable and latest V1 action