Skip to content

Commit 6b4b1bd

Browse files
committed
Initial commit
0 parents  commit 6b4b1bd

19 files changed

+10199
-0
lines changed

.eslintignore

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
dist/

.eslintrc.json

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

.gitattributes

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
dist/** -diff linguist-generated=true

.github/dependabot.yml

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
version: 2
2+
updates:
3+
# Enable version updates for npm
4+
- package-ecosystem: "npm"
5+
# Look for `package.json` and `lock` files in the `root` directory
6+
directory: "/"
7+
# Check the npm registry for updates every day (weekdays)
8+
schedule:
9+
interval: "daily"

.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+
- main
7+
- 'releases/*'
8+
9+
jobs:
10+
# unit tests
11+
units:
12+
runs-on: ubuntu-latest
13+
steps:
14+
- uses: actions/checkout@v2
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@v2
23+
- uses: ./
24+
with:
25+
milliseconds: 1000

.gitignore

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

CODEOWNERS

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
* @actions/actions-runtime

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

+116
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,116 @@
1+
# Create a JavaScript Action
2+
3+
<p align="center">
4+
<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>
5+
</p>
6+
7+
Use this template to bootstrap the creation of a JavaScript action.:rocket:
8+
9+
This template includes tests, linting, a validation workflow, publishing, and versioning guidance.
10+
11+
If you are new, there's also a simpler introduction. See the [Hello World JavaScript Action](https://github.com/actions/hello-world-javascript-action)
12+
13+
## Create an action from this template
14+
15+
Click the `Use this Template` and provide the new repo details for your action
16+
17+
## Code in Main
18+
19+
Install the dependencies
20+
21+
```bash
22+
npm install
23+
```
24+
25+
Run the tests :heavy_check_mark:
26+
27+
```bash
28+
$ npm test
29+
30+
PASS ./index.test.js
31+
✓ throws invalid number (3ms)
32+
wait 500 ms (504ms)
33+
test runs (95ms)
34+
...
35+
```
36+
37+
## Change action.yml
38+
39+
The action.yml 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 prepare
74+
75+
```bash
76+
npm run prepare
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+
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.
101+
102+
Your action is now published! :rocket:
103+
104+
See the [versioning documentation](https://github.com/actions/toolkit/blob/master/docs/action-versioning.md)
105+
106+
## Usage
107+
108+
You can now consume the action by referencing the v1 branch
109+
110+
```yaml
111+
uses: actions/javascript-action@v1
112+
with:
113+
milliseconds: 1000
114+
```
115+
116+
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)