-
Notifications
You must be signed in to change notification settings - Fork 1.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
JavaScript walk through update #107
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -27,9 +27,9 @@ The toolkit provides five separate packages. See the docs for each action. | |
|
||
Actions are units of work which can either run in a container or on the host machine. | ||
|
||
[Choosing an action type](docs/action-types.md): Outlines the differences and why you would want to create a host or a container based action. | ||
[Choosing an action type](docs/action-types.md): Outlines the differences and why you would want to create a JavaScript or a container based action. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. NOTE to self: need to add another block encouraging 1 action to 1 repo for market place and versioning to be viable in this model |
||
|
||
[JavaScript Action Walkthrough](docs/javascript-action.md): A full walkthrough creating an action using the toolkit along with TypeScript and Jest for unit testing. It also covers a branching strategy for versioning and safely testing and releasing an action. | ||
[JavaScript Action Walkthrough using a Template](docs/javascript-action.md): A full walkthrough creating an action using the toolkit along with TypeScript for compile time support and Jest for unit testing. It also covers a branching strategy for versioning and safely testing and releasing an action. | ||
|
||
[Docker Action Walkthrough](docs/container-action.md): Create an action that is delivered as a container and run with docker. | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
<mxfile modified="2019-09-04T11:27:58.307Z" host="www.draw.io" agent="Mozilla/5.0 (Macintosh; Intel Mac OS X 10_14_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/76.0.3809.100 Safari/537.36" etag="MFzGVuAX-y50cwbudjLg" version="11.2.5" type="device" pages="1"><diagram name="Page-1" id="ff44883e-f642-bcb2-894b-16b3d25a3f0b">7Vtbc5s4GP01nj4lA+L+WCdp96E70910uu1TB4OMmWDkEdhx9tfvJ5AM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m4LE1fsbaHgVYrgsC1OAaaPvGGexnG2TbC70nwK2XKdrifja2DTCRc6F2waZ1OTHroi9ee7wzmbWoTefZpdPs0uUu9ybKx+HBsnMG890/GQ7zng1XhBl1u2tnVPClhdBHUp67pn85602+0oOmSartmgolgyTW9MKZkzPEDDp3nydtW7Z3TVu2vZqno3+lTvl5nq3yiMgZP9r1Uedj/Kw5fzHgeeESkTubJNO9/RgXZLPUVBzDEsCFUgzGybJuCPv1214DuSftZEVHafWsFX8FAiqojisMQ1h3GFDtzMuJKLZGucZZi3EOKorr0y+85Jeg/KwO6eRv17clBmqurf7dN3DPYDfVToPA8LtoG/Z8yMpJjZDoaOmcXRXTv68lSLfUXRV3BxySfNQfcFeFBHhF+v94QEPc/u5xiSfZQN36F+juwwuWa/fo6pSYL51y3Pgd/1PIfOppiao9TfS577T6cIWrdDol2h03tcdCgZLzO3d2uDlDSEvDFujQMpeWSQziZp+X190bQvuxbIb+zJp5oH2zXJK+o7wWeqGb6rCuBNQ/ZQPEsxY71G8KZ6bF3nXCfLN5xf9QPZUVTzq/3CoGa2ytYxJgjGFFN24Mmy3oZ08Gzw0BsZH0DNwLAPcLnMea/47cIY2N1jkMBAA8N41oQYOiAhNicrvG+u3vNilv73LMfj7Xfx1r6s0GtezFQTY1tSW5chdJWrxm9KCunYxp/Exsnv8QWBApIOo7MJpZi4hdHuN3euByp/i1+5L5F5Pqx072jJkU3zUzS+7XFYzHSBzcFbtteBb22Io9kPUfc//XwZD09OOx3q55umfIJwsgQWFJtfRNbdm9+dWg//AQ==</diagram></mxfile> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Do we need this file/what is it doing? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes! Try and update the image included without it ;) . It's a draw.io file per the file name and the xml declaration. ;) |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,57 +6,55 @@ The [javascript-template](https://github.com/actions/javascript-template) repo c | |
|
||
Navigate to https://github.com/actions/javascript-template | ||
|
||
Click on `Use this template` to create the repo for your action. | ||
Click on `Use this template` to create the repo for your action. Provide a name such as `myaction`. | ||
|
||
 | ||
|
||
Complete creating your repo and clone the repo. | ||
# Clone and Update | ||
|
||
> NOTE: The location of the repo will be how users will reference your action in their workflow file with the using keyword. | ||
|
||
e.g. To use https://github.com/actions/setup-node, user's will author: | ||
|
||
```yaml | ||
steps: | ||
uses: actions/setup-node@master | ||
```bash | ||
$ git clone <repolocation> | ||
$ cd myaction | ||
``` | ||
|
||
Update the `author` element in the package.json file. | ||
|
||
# Dev Workflow | ||
|
||
The workflow below describes one possible workflow with a branching strategy. Others exist. | ||
|
||
> Key Point: the branch that users reference in their workflow files should reference an action that has **only** the production dependencies. | ||
> Key Point: the branch that users reference in their workflow files should reference an action from a distribution branch that has **only** the production dependencies. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This reads a bit confusing, can we add an example? "For instance, you would want to reference X and not Y". There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is covered further down in the doc in the section for creating a distribution branch. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The following paragraph also discussed a concrete distribution branch of releases/v1. It also clarifies that the runner will download and run from that distribution branch. |
||
|
||
The workflow below describes a strategy where you code in master (with node_modules ignored) with a v1 branch users reference and contains the product references. Actions are self contained referenced on the github graph of repos. | ||
The workflow below describes a strategy where you code in master (with node_modules ignored) with a distribution releases/v1 branch users reference via a tag. Actions are self contained referenced from the github graph of repos, downloaded by the runner and run intact at runtime. | ||
|
||
## Install Dependencies | ||
|
||
After creating a repo from the template and cloning it, you will be in master. The command below will install the toolkit, other dependencies and dev dependencies | ||
After creating a repo from the template and cloning it, you will be in master. The command below will install the toolkit, other dependencies and dev dependencies. node_modules are ignored in the coding master branch. | ||
|
||
```bash | ||
$ npm install | ||
``` | ||
|
||
## Define Metadata | ||
|
||
Your action has a name and a description. Update the author. | ||
|
||
Create inputs that your unit of work will need. These will be what workflow authors set with the `with:` keyword. | ||
Your action has a name and a description. Update all fields . | ||
|
||
```yaml | ||
name: 'My new action' | ||
description: 'A test action' | ||
author: 'GitHub' | ||
name: 'Hello' | ||
description: 'Outputs Hello to a named input' | ||
author: 'me' | ||
inputs: | ||
myInput: | ||
description: 'Input to use' | ||
default: 'world' | ||
name: | ||
description: 'the name to say hello to' | ||
default: 'World' | ||
runs: | ||
using: 'node12' | ||
main: 'lib/main.js' | ||
|
||
``` | ||
|
||
The `name` input will be referenced by workflow authors using the `with:` keyword. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Add example? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yeah, it's covered in the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Good catch ... |
||
|
||
Note that the action will be run with node 12 (carried by the runner) and the entry point is specified with `main:` | ||
|
||
## Change Code and Add Tests | ||
|
@@ -68,8 +66,8 @@ import * as core from '@actions/core'; | |
|
||
async function run() { | ||
try { | ||
const myInput = core.getInput('myInput'); | ||
core.debug(`Hello ${myInput}!`); | ||
const nameInput = core.getInput('name'); | ||
console.log(`Hello ${nameInput}!`); | ||
} catch (error) { | ||
core.setFailed(error.message); | ||
} | ||
|
@@ -78,14 +76,14 @@ async function run() { | |
run(); | ||
``` | ||
|
||
Modify tests in `__tests__/main.test.ts`. The template uses [jest](https://github.com/facebook/jest). | ||
Note that tests are in `__tests__/main.test.ts`. The template uses [jest](https://github.com/facebook/jest) to get you started with unit testing. | ||
|
||
## Build and Test | ||
|
||
```bash | ||
$ npm run build | ||
|
||
> node12[email protected] build /Users/user/Projects/testnode12 | ||
> javascript[email protected] build /Users/user/Projects/myaction | ||
> tsc | ||
|
||
$ npm test | ||
|
@@ -107,12 +105,12 @@ $ git add <whatever only files you added> | |
$ git commit -m "Message" | ||
``` | ||
|
||
## Publish a v1-release Action | ||
## Publish a releases/v1 Action | ||
|
||
After changing some files, create a v1-release branch which we will release | ||
After changing some files, create a releases/v1 branch which we will release | ||
|
||
```bash | ||
$ git checkout -b v1-release | ||
$ git checkout -b releases/v1 | ||
``` | ||
|
||
> NOTE: We will provide tooling and an action to automate this soon. | ||
|
@@ -139,7 +137,7 @@ Once the action has a self contained version in the v1-release branch, you can t | |
|
||
```yaml | ||
steps: | ||
uses: {org}/{reponame}@v1-release | ||
uses: {org}/{reponame}@releases/v1 | ||
``` | ||
|
||
## Release Current Changes as v1 | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we make it explicit here that we recommend Typescript to make life easier?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think the next block covers that. Choosing an action type is orthogonal to dev tooling chosen. Case in point is our next action / in official docs is a topic on creating an action from scratch (hello world) in pure javascript. This doc strictly covers javascript vs container and why you would do one or the other.