Skip to content

Commit

Permalink
Merge pull request #53 from JasonEtco/slash-commands
Browse files Browse the repository at this point in the history
Slash commands
  • Loading branch information
JasonEtco committed Mar 16, 2019
2 parents ee53d0d + 6900976 commit 92b7566
Show file tree
Hide file tree
Showing 10 changed files with 478 additions and 249 deletions.
16 changes: 16 additions & 0 deletions .github/actions/publish-release/publish_release
Expand Up @@ -9,6 +9,22 @@ if [[ -z "$NPM_AUTH_TOKEN" ]]; then
exit 1
fi

# Copied from https://github.com/actions/npm/blob/master/entrypoint.sh
# Respect NPM_CONFIG_USERCONFIG if it is provided, default to $HOME/.npmrc
NPM_CONFIG_USERCONFIG="${NPM_CONFIG_USERCONFIG-"$HOME/.npmrc"}"
NPM_REGISTRY_URL="${NPM_REGISTRY_URL-registry.npmjs.org}"
NPM_STRICT_SSL="${NPM_STRICT_SSL-true}"
NPM_REGISTRY_SCHEME="https"
if ! $NPM_STRICT_SSL
then
NPM_REGISTRY_SCHEME="http"
fi

# Allow registry.npmjs.org to be overridden with an environment variable
printf "//%s/:_authToken=%s\\nregistry=%s\\nstrict-ssl=%s" "$NPM_REGISTRY_URL" "$NPM_AUTH_TOKEN" "${NPM_REGISTRY_SCHEME}://$NPM_REGISTRY_URL" "${NPM_STRICT_SSL}" > "$NPM_CONFIG_USERCONFIG"

chmod 0600 "$NPM_CONFIG_USERCONFIG"

FILE=/release-workflow-tag
if [ ! -f $FILE ]; then
echo "Publishing to @latest"
Expand Down
34 changes: 34 additions & 0 deletions README.md
Expand Up @@ -50,6 +50,7 @@ This will create a new folder `my-cool-action` with the following files:
* [The Toolkit class](#toolkit-options)
* [Authenticated GitHub API client](#toolsgithub)
* [Logging](#toolslog)
* [Slash commands](#toolscommandcommand-args-match--promise)
* [Parsing arguments](#toolsarguments)
* [Reading files](#toolsgetfilepath-encoding--utf8)
* [Run a CLI command](#toolsruninworkspacecommand-args-execaoptions)
Expand Down Expand Up @@ -132,6 +133,39 @@ In the GitHub Actions output, this is the result:

<br>

### tools.command(command, (args, match) => Promise<void>)

Respond to a slash-command posted in a GitHub issue, comment, pull request, pull request review or commit comment. Arguments to the slash command are parsed by [minimist](https://github.com/substack/minimist). You can use a slash command in a larger comment, but the command must be at the start of the line:

```
Hey, let's deploy this!
/deploy --app example --container node:alpine
```

```ts
tools.command('deploy', async (args: ParsedArgs, match: RegExpExecArray) => {
console.log(args)
// -> { app: 'example', container: 'node:alpine' }
})
```

The handler will run multiple times for each match:

```
/deploy 1
/deploy 2
/deploy 3
```

```ts
let i = 0
await tools.command('deploy', () => { i++ })
console.log(i)
// -> 3
```

<br>

### tools.config(filename)

Get the configuration settings for this action in the project workspace. This method can be used in three different ways:
Expand Down

0 comments on commit 92b7566

Please sign in to comment.