Skip to content

Commit

Permalink
Initial release
Browse files Browse the repository at this point in the history
  • Loading branch information
LouisBoudreau committed Feb 21, 2022
1 parent b86e45b commit 6b9ca9e
Show file tree
Hide file tree
Showing 11 changed files with 8,877 additions and 210 deletions.
120 changes: 21 additions & 99 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,105 +1,27 @@
# Create a JavaScript Action using TypeScript
# Get Current workflow run conclusion

Use this template to bootstrap the creation of a TypeScript action.:rocket:
This action computes the conclusion of the current workflow.

This template includes compilation support, tests, a validation workflow, publishing, and versioning guidance.
See [action.yml](./action.yml) for the list of `inputs` and `outputs`.

If you are new, there's also a simpler introduction. See the [Hello World JavaScript Action](https://github.com/actions/hello-world-javascript-action)

## Create an action from this template

Click the `Use this Template` and provide the new repo details for your action

## Code in Main

> First, you'll need to have a reasonably modern version of `node` handy. This won't work with versions older than 9, for instance.
Install the dependencies
```bash
$ yarn install
```

Build the typescript and package it for distribution
```bash
$ yarn build && yarn package
```

Run the tests :heavy_check_mark:
```bash
$ yarn test

PASS ./index.test.js
✓ throws invalid number (3ms)
wait 500 ms (504ms)
test runs (95ms)

...
```

## Change action.yml

The action.yml contains defines the inputs and output for your action.

Update the action.yml with your name, description, inputs and outputs for your action.

See the [documentation](https://help.github.com/en/articles/metadata-syntax-for-github-actions)

## Change the Code

Most toolkit and CI/CD operations involve async operations so the action is run in an async function.

```javascript
import * as core from '@actions/core';
...

async function run() {
try {
...
}
catch (error) {
core.setFailed(error.message);
}
}

run()
```

See the [toolkit documentation](https://github.com/actions/toolkit/blob/master/README.md#packages) for the various packages.

## Publish to a distribution branch

Actions are run from GitHub repos so we will checkin the packed dist folder.

Then run [ncc](https://github.com/zeit/ncc) and push the results:
```bash
$ yarn package
$ git add dist
$ git commit -a -m "prod dependencies"
$ git push origin releases/v1
```

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.

Your action is now published! :rocket:

See the [versioning documentation](https://github.com/actions/toolkit/blob/master/docs/action-versioning.md)

## Validate

You can now validate the action by referencing `./` in a workflow in your repo (see [test.yml](.github/workflows/test.yml))
## Example usage

```yaml
uses: ./
with:
milliseconds: 1000
ping-slack:
name: Ping slack to update workflow run conclusion
runs-on: ubuntu-latest

steps:
- name: Get workflow run conclusion
id: current-run-conclusion
uses: agendrix/[email protected]
with:
token: ${{ secrets.GITHUB_TOKEN }}
deployments_outcome: [ ${{ needs.main_deployment.deployment_outcome }} ]
- name: Ping Slack for outcome
uses: agendrix/slack-notifier/[email protected]
with:
state: ${{ steps.current-run-conclusion.outputs.conclusion }}
lambda-url: ${{ secrets.slack_lambda_endpoint }}
api-secret: ${{ secrets.slack_api_secret }}
```
See the [actions tab](https://github.com/actions/typescript-action/actions) for runs of this action! :rocket:
## Usage:
After testing you can [create a v1 tag](https://github.com/actions/toolkit/blob/master/docs/action-versioning.md) to reference the stable and latest V1 action
## Helpers
If you created helpers that you consider could benefit to other actions, please consider contributing by adding them to the `helpers` folder.
28 changes: 0 additions & 28 deletions __tests__/main.test.ts

This file was deleted.

17 changes: 11 additions & 6 deletions action.yml
Original file line number Diff line number Diff line change
@@ -1,11 +1,16 @@
name: 'Your name here'
description: 'Provide a description here'
author: 'Your name or organization here'
name: Get current run conclusion
description: Compute the conclusion of the current workflow run
author: '[email protected]'
inputs:
milliseconds: # change this
token:
required: true
description: 'input description here'
default: 'default value if applicable'
description: "This should be a personal access token with access to your repository. Ex: ${{ secrets.GITHUB_TOKEN }}"
deployments_outcome:
required: false
description: "Outcome of the deployments. Accepted values are any values from DeploymentOutcome enum: https://github.com/agendrix/wait-for-ecs-service-deployment-action/blob/main/src/ecs/types.ts"
outputs:
conclusion:
description: Conclusion of the current workflow run
runs:
using: 'node12'
main: 'dist/index.js'
Loading

0 comments on commit 6b9ca9e

Please sign in to comment.