Skip to content

Commit 775a4e4

Browse files
committed
Initial commit
0 parents  commit 775a4e4

12 files changed

+6059
-0
lines changed

.eslintrc.json

+17
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+
}

.github/workflows/test.yml

+25
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
name: "units-test"
2+
on:
3+
pull_request:
4+
push:
5+
branches:
6+
- master
7+
- 'releases/*'
8+
9+
jobs:
10+
# unit tests
11+
units:
12+
runs-on: ubuntu-latest
13+
steps:
14+
- uses: actions/checkout@v1
15+
- run: npm ci
16+
- run: npm test
17+
18+
# test action works running from the graph
19+
test:
20+
runs-on: ubuntu-latest
21+
steps:
22+
- uses: actions/checkout@v1
23+
- uses: ./
24+
with:
25+
milliseconds: 1000

.gitignore

+65
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
node_modules/
2+
3+
# Editors
4+
.vscode
5+
6+
# Logs
7+
logs
8+
*.log
9+
npm-debug.log*
10+
yarn-debug.log*
11+
yarn-error.log*
12+
13+
# Runtime data
14+
pids
15+
*.pid
16+
*.seed
17+
*.pid.lock
18+
19+
# Directory for instrumented libs generated by jscoverage/JSCover
20+
lib-cov
21+
22+
# Coverage directory used by tools like istanbul
23+
coverage
24+
25+
# nyc test coverage
26+
.nyc_output
27+
28+
# Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files)
29+
.grunt
30+
31+
# Bower dependency directory (https://bower.io/)
32+
bower_components
33+
34+
# node-waf configuration
35+
.lock-wscript
36+
37+
# Compiled binary addons (https://nodejs.org/api/addons.html)
38+
build/Release
39+
40+
# Other Dependency directories
41+
jspm_packages/
42+
43+
# TypeScript v1 declaration files
44+
typings/
45+
46+
# Optional npm cache directory
47+
.npm
48+
49+
# Optional eslint cache
50+
.eslintcache
51+
52+
# Optional REPL history
53+
.node_repl_history
54+
55+
# Output of 'npm pack'
56+
*.tgz
57+
58+
# Yarn Integrity file
59+
.yarn-integrity
60+
61+
# dotenv environment variables file
62+
.env
63+
64+
# next.js build output
65+
.next

LICENSE

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
MIT License
2+
3+
Copyright (c) 2019 GitHub Actions
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.

README.md

+114
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,114 @@
1+
2+
<p align="center">
3+
<a href="https://github.com/actions/javascript-action/actions"><img alt="javscript-action status" src="https://github.com/actions/javascript-action/workflows/units-test/badge.svg"></a>
4+
</p>
5+
6+
# Create a JavaScript Action
7+
8+
Use this template to bootstrap the creation of a JavaScript action.:rocket:
9+
10+
This template includes tests, linting, a validation workflow, publishing, and versioning guidance.
11+
12+
If you are new, there's also a simpler introduction. See the [Hello World JavaScript Action](https://github.com/actions/hello-world-javascript-action)
13+
14+
## Create an action from this template
15+
16+
Click the `Use this Template` and provide the new repo details for your action
17+
18+
## Code in Master
19+
20+
Install the dependencies
21+
```bash
22+
$ npm install
23+
```
24+
25+
Run the tests :heavy_check_mark:
26+
```bash
27+
$ npm test
28+
29+
PASS ./index.test.js
30+
✓ throws invalid number (3ms)
31+
wait 500 ms (504ms)
32+
test runs (95ms)
33+
34+
...
35+
```
36+
37+
## Change action.yml
38+
39+
The action.yml contains defines the inputs and output for your action.
40+
41+
Update the action.yml with your name, description, inputs and outputs for your action.
42+
43+
See the [documentation](https://help.github.com/en/articles/metadata-syntax-for-github-actions)
44+
45+
## Change the Code
46+
47+
Most toolkit and CI/CD operations involve async operations so the action is run in an async function.
48+
49+
```javascript
50+
const core = require('@actions/core');
51+
...
52+
53+
async function run() {
54+
try {
55+
...
56+
}
57+
catch (error) {
58+
core.setFailed(error.message);
59+
}
60+
}
61+
62+
run()
63+
```
64+
65+
See the [toolkit documentation](https://github.com/actions/toolkit/blob/master/README.md#packages) for the various packages.
66+
67+
## Package for distribution
68+
69+
GitHub Actions will run the entry point from the action.yml. Packaging assembles the code into one file that can be checked in to Git, enabling fast and reliable execution and preventing the need to check in node_modules.
70+
71+
Actions are run from GitHub repos. Packaging the action will create a packaged action in the dist folder.
72+
73+
Run package
74+
75+
```bash
76+
npm run package
77+
```
78+
79+
Since the packaged index.js is run from the dist folder.
80+
81+
```bash
82+
git add dist
83+
```
84+
85+
## Create a release branch
86+
87+
Users shouldn't consume the action from master since that would be latest code and actions can break compatibility between major versions.
88+
89+
Checkin to the v1 release branch
90+
91+
```bash
92+
$ git checkout -b v1
93+
$ git commit -a -m "v1 release"
94+
```
95+
96+
```bash
97+
$ git push origin v1
98+
```
99+
100+
Your action is now published! :rocket:
101+
102+
See the [versioning documentation](https://github.com/actions/toolkit/blob/master/docs/action-versioning.md)
103+
104+
## Usage
105+
106+
You can now consume the action by referencing the v1 branch
107+
108+
```yaml
109+
uses: actions/javascript-action@v1
110+
with:
111+
milliseconds: 1000
112+
```
113+
114+
See the [actions tab](https://github.com/actions/javascript-action/actions) for runs of this action! :rocket:

action.yml

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
name: 'Wait'
2+
description: 'Wait a designated number of milliseconds'
3+
inputs:
4+
milliseconds: # id of input
5+
description: 'number of milliseconds to wait'
6+
required: true
7+
default: '1000'
8+
outputs:
9+
time: # output will be available to future steps
10+
description: 'The message to output'
11+
runs:
12+
using: 'node12'
13+
main: 'dist/index.js'

0 commit comments

Comments
 (0)