Skip to content

Commit 886d778

Browse files
start readme
1 parent 198d21c commit 886d778

5 files changed

Lines changed: 608 additions & 1 deletion

File tree

.eslintrc.json

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
{
2+
"env": {
3+
"commonjs": true,
4+
"es6": true,
5+
"node": true
6+
},
7+
"extends": "eslint:recommended",
8+
"globals": {
9+
"Atomics": "readonly",
10+
"SharedArrayBuffer": "readonly"
11+
},
12+
"parserOptions": {
13+
"ecmaVersion": 2018
14+
},
15+
"rules": {
16+
}
17+
}

README.md

Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
# JavaScript Action Template
2+
3+
A template to bootstrap the creation of a JavaScript action with tests, linting, a validation workflow and publishing scripts.
4+
5+
## Create an action from this template
6+
7+
Click the `Use this Template` and provide the new repo details for your action
8+
9+
## Code in Master
10+
11+
```bash
12+
$ npm install
13+
```
14+
15+
```bash
16+
$ npm test
17+
18+
PASS ./index.test.js
19+
✓ throws invalid number (3ms)
20+
wait 500 ms (504ms)
21+
test runs (95ms)
22+
23+
...
24+
```
25+
26+
## Change actions.yml
27+
28+
The actions.yml contains defines the inputs and output for your action.
29+
30+
Update the actions.yml with your name, description, inputs and outputs for your action.
31+
32+
See the [documentation](https://help.github.com/en/articles/metadata-syntax-for-github-actions)
33+
34+
## Change the Code
35+
36+
Most toolkit and CI/CD operations involve async operations so the action is run in an async function.
37+
38+
```javascript
39+
const core = require('@actions/core');
40+
...
41+
42+
async function run() {
43+
try {
44+
...
45+
}
46+
catch (error) {
47+
core.setFailed(error.message);
48+
}
49+
}
50+
51+
run()
52+
```
53+
54+
See the [toolkit documentation](https://github.com/actions/toolkit/blob/master/README.md#packages) for the various packages.
55+
56+
## Usage:
57+
58+
The uses path will be the org and repo where you create your action
59+
60+
```yaml
61+
uses: actions/javascript-action@v1
62+
with:
63+
milliseconds: 1000
64+
```
65+
66+
67+

index.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
const core = require('@actions/core');
22
const wait = require('./wait');
33

4+
5+
// most @actions toolkit packages have async methods
46
async function run() {
57
try {
68
const ms = core.getInput('milliseconds');

0 commit comments

Comments
 (0)