Skip to content

Commit f0826cd

Browse files
committed
Initial commit
0 parents  commit f0826cd

File tree

12 files changed

+6054
-0
lines changed

12 files changed

+6054
-0
lines changed

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

.github/workflows/test.yml

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
name: "test-local"
2+
on:
3+
pull_request:
4+
push:
5+
branches:
6+
- master
7+
- 'releases/*'
8+
9+
jobs:
10+
test:
11+
runs-on: ubuntu-latest
12+
steps:
13+
- uses: actions/checkout@v1
14+
15+
- run: npm ci
16+
- run: npm test
17+
- uses: ./
18+
with:
19+
milliseconds: 1000

.gitignore

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

LICENSE

Lines changed: 21 additions & 0 deletions
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

Lines changed: 114 additions & 0 deletions
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"><img alt="GitHub Actions status" src="https://github.com/actions/javascript-action/workflows/test-local/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

Lines changed: 13 additions & 0 deletions
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)