1
0
Fork 0

update readme

pull/183/head
Bryan MacFarlane 2019-10-03 12:45:11 -04:00
parent a1c30dfc53
commit 1643ea2734
2 changed files with 43 additions and 18 deletions

View File

@ -1,5 +1,9 @@
name: toolkit-unit-tests name: toolkit-unit-tests
on: [push] on:
push:
paths:
- 'packages/**'
- '*.json'
jobs: jobs:
Ubuntu: Ubuntu:
name: Run Ubuntu name: Run Ubuntu

View File

@ -7,10 +7,15 @@
<a href="https://github.com/actions/toolkit"><img alt="GitHub Actions status" src="https://github.com/actions/toolkit/workflows/toolkit-unit-tests/badge.svg"></a> <a href="https://github.com/actions/toolkit"><img alt="GitHub Actions status" src="https://github.com/actions/toolkit/workflows/toolkit-unit-tests/badge.svg"></a>
</p> </p>
## GitHub Actions Toolkit ## GitHub Actions Toolkit
The GitHub Actions ToolKit provides a set of packages to make creating actions easier. The GitHub Actions ToolKit provides a set of packages to make creating actions easier.
<br/>
<h3 align="center">Get started with the <a href="https://github.com/actions/javascript-action">javascript-action template</a>!</h3>
<br/>
## Packages ## Packages
:heavy_check_mark: [@actions/core](packages/core) :heavy_check_mark: [@actions/core](packages/core)
@ -66,6 +71,12 @@ Outlines the differences and why you would want to create a JavaScript or a cont
<br/> <br/>
<br/> <br/>
:curly_loop: [Versioning](docs/action-versioning.md)
Actions are downloaded and run from the GitHub graph of repos. This contains guidance for versioning actions and safe releases.
<br/>
<br/>
[Hello World JavaScript Action](https://github.com/actions/hello-world-javascript-action) [Hello World JavaScript Action](https://github.com/actions/hello-world-javascript-action)
Illustrates how to create a simple hello world javascript action. Illustrates how to create a simple hello world javascript action.
@ -83,7 +94,14 @@ Illustrates how to create a simple hello world javascript action.
Walkthrough and template for creating a JavaScript Action with tests, linting, workflow, publishing, and versioning. Walkthrough and template for creating a JavaScript Action with tests, linting, workflow, publishing, and versioning.
```javascript ```javascript
async function run() {
try {
const ms = core.getInput('milliseconds');
console.log(`Waiting ${ms} milliseconds ...`)
...
```
```javascript
PASS ./index.test.js PASS ./index.test.js
✓ throws invalid number ✓ throws invalid number
✓ wait 500 ms ✓ wait 500 ms
@ -91,7 +109,7 @@ PASS ./index.test.js
Test Suites: 1 passed, 1 total Test Suites: 1 passed, 1 total
Tests: 3 passed, 3 total Tests: 3 passed, 3 total
``` ```
<br/> <br/>
<br/> <br/>
@ -107,13 +125,15 @@ async function run() {
const ms = core.getInput('milliseconds'); const ms = core.getInput('milliseconds');
console.log(`Waiting ${ms} milliseconds ...`) console.log(`Waiting ${ms} milliseconds ...`)
... ...
```
```javascript
PASS ./index.test.js
✓ throws invalid number
✓ wait 500 ms
✓ test runs
} catch (error) { Test Suites: 1 passed, 1 total
core.setFailed(error.message); Tests: 3 passed, 3 total
}
}
run();
``` ```
<br/> <br/>
<br/> <br/>
@ -124,11 +144,8 @@ Create an action that is delivered as a container and run with docker.
```docker ```docker
FROM alpine:3.10 FROM alpine:3.10
COPY LICENSE README.md / COPY LICENSE README.md /
COPY entrypoint.sh /entrypoint.sh COPY entrypoint.sh /entrypoint.sh
ENTRYPOINT ["/entrypoint.sh"] ENTRYPOINT ["/entrypoint.sh"]
``` ```
<br/> <br/>
@ -138,18 +155,22 @@ ENTRYPOINT ["/entrypoint.sh"]
Create an action that is delivered as a container which uses the toolkit. This example uses the GitHub context to construct an Octokit client. Create an action that is delivered as a container which uses the toolkit. This example uses the GitHub context to construct an Octokit client.
```docker
FROM node:slim
COPY . .
RUN npm install --production
ENTRYPOINT ["node", "/lib/main.js"]
```
```javascript ```javascript
const myInput = core.getInput('myInput'); const myInput = core.getInput('myInput');
core.debug(`Hello ${myInput} from inside a container`); core.debug(`Hello ${myInput} from inside a container`);
const context = github.context; const context = github.context;
console.log(`We can even get context data, like the repo: ${context.repo.repo}`) console.log(`We can even get context data, like the repo: ${context.repo.repo}`)
``` ```
<br/> <br/>
<br/> <br/>
:curly_loop: [Versioning](docs/action-versioning.md)
Recommendations on versioning, releases and tagging your action. Recommendations on versioning, releases and tagging your action.
<br/> <br/>
<br/> <br/>