Skip to content

Commit

Permalink
Merge pull request #20 from urcomputeringpal/jnewland-patch-1
Browse files Browse the repository at this point in the history
Improve docs
  • Loading branch information
jnewland authored May 14, 2023
2 parents 4780ca4 + 245b5cd commit b2c0dc0
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 12 deletions.
23 changes: 12 additions & 11 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,15 @@ A workflow wrapping https://github.com/actions/github-script with Typescript fun

## Features

- Enables easily running Typescript functions exported from a module like the one in [`.github/`](./.github/) in Actions workflows. Builds and caches build results automatically.
- Allows writing tests for your scripts and running them locally with `npm test`.
- Enables easily running Typescript functions exported from a tiny private module like the one in [`.github/`](./.github/) in Actions workflows. Caches build results automatically.
- Enables a local testing workflow for advanced Actions logic.
- Provides a superior experience to editing Javascript embedded in YAML.

## Usage

### Writing scripts

The `@urcomputeringpal/github-script-ts` package contains a type definition for the [arguments](https://github.com/actions/github-script#actionsgithub-script) passed to your script. Put all of these files in `.github` to create scripts of your own:
The [`@urcomputeringpal/github-script-ts`](https://www.npmjs.com/package/@urcomputeringpal/github-script-ts) package contains a type definition for the [arguments](https://github.com/actions/github-script#actionsgithub-script) passed to your script. Put all of these files in `.github` to create scripts of your own:

#### `src/function1.ts`

Expand Down Expand Up @@ -66,19 +66,13 @@ export { function1 } from "./function1";

### Running your script in a workflow

See [`action.yml`](./action.yml) for all accepted inputs.

```yaml
- name: Checkout repository
uses: actions/checkout@v3

# Perform setup. Caches build results with actions/cache.
# Expects a package.json with a "build" script that exports
# functions that accept the following arguments
# (see .github/src/types.ts):
#
# * github - A pre-authenticated octokit/rest.js client with pagination plugins
# * context - An object containing the context of the workflow run
# * core - A reference to the @actions/core package

- name: Setup TypeScript scripts
uses: urcomputeringpal/github-script-ts@v0

Expand All @@ -91,6 +85,13 @@ export { function1 } from "./function1";
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
function: function1
# args: >
# {github, context, core, exec, io, fetch}
# path: ./.github
# build: npm run build
# module: src/index.js
# result-encoding: string


- name: Use function1 result
run: |
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@urcomputeringpal/github-script-ts",
"version": "0.0.4",
"version": "0.0.5",
"description": "actions/github-script for Typescript",
"repository": "https://github.com/urcomputeringpal/github-script-ts",
"files": [
Expand Down

0 comments on commit b2c0dc0

Please sign in to comment.