Skip to content

Commit

Permalink
Update action.yml + README
Browse files Browse the repository at this point in the history
  • Loading branch information
harveysanders committed Oct 10, 2023
1 parent f0046ae commit 40ac333
Show file tree
Hide file tree
Showing 4 changed files with 68 additions and 32 deletions.
8 changes: 6 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,12 @@ jobs:
id: test-action
uses: ./
with:
milliseconds: 1000
subject: 'github.actions.test'
message: '{"action": "action-nats-publish"}'
urls: tls://connect.ngs.global
jwt: ${{ secrets.NATS_CLIENT_JWT }}
nKeySeed: ${{ secrets.NATS_NKEY_SEED }}

- name: Print Output
id: output
run: echo "${{ steps.test-action.outputs.time }}"
run: echo "${{ steps.test-action.outputs.published }}"
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -101,3 +101,4 @@ __tests__/runner/*
.idea
.vscode
*.code-workspace
.secrets
59 changes: 41 additions & 18 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,28 +1,54 @@
# Create a JavaScript Action Using TypeScript
# NATS-pub-action

[![GitHub Super-Linter](https://github.com/actions/typescript-action/actions/workflows/linter.yml/badge.svg)](https://github.com/super-linter/super-linter)
![CI](https://github.com/actions/typescript-action/actions/workflows/ci.yml/badge.svg)

Use this template to bootstrap the creation of a TypeScript action. :rocket:
GitHub action to publish messages to a NATS server

This template includes compilation support, tests, a validation workflow,
publishing, and versioning guidance.
## Inputs

If you are new, there's also a simpler introduction in the
[Hello world JavaScript action repository](https://github.com/actions/hello-world-javascript-action).
### `subject`

## Create Your Own Action
**Required** The NATS subject where the messages should be published.

To create your own action, you can use this repository as a template! Just
follow the below instructions:
### `message`

1. Click the **Use this template** button at the top of the repository
1. Select **Create a new repository**
1. Select an owner and name for your new repository
1. Click **Create repository**
1. Clone your new repository
**Required** JSON-serialized message. Default `"{}"`.

## Initial Setup
### `urls`

**Required** Comma separated NATS server URLs. Example:
`nats://localhost:4222,nats://localhost:4223`.

### `jwt`

JSON web token used to authenticate on the NATS server.

### `nKeySeed`

Secret
[NKey seed](https://docs.nats.io/running-a-nats-service/configuration/securing_nats/auth_intro/nkey_auth)
used to authenticate on the NATS server.

## Outputs

### `published`

The `message` and the `subject` that was published.

## Example usage

```yaml
uses: operationspark/action-nats-publish@v1
with:
subject: 'operationspark.foo'
message: '{"data": "Hello world!"}'
urls: 'nat://localhost:4222'
jwt: ${{ secrets.NATS_JWT }}
nKeySeed: ${{ secrets.NATS_NKEY_SEED }}
```
## Initial Devlopment Setup
After you've cloned the repository to your local machine or codespace, you'll
need to perform some initial setup steps before you can develop your action.
Expand Down Expand Up @@ -67,9 +93,6 @@ The [`action.yml`](action.yml) file defines metadata about your action, such as
input(s) and output(s). For details about this file, see
[Metadata syntax for GitHub Actions](https://docs.github.com/en/actions/creating-actions/metadata-syntax-for-github-actions).

When you copy this repository, update `action.yml` with the name, description,
inputs, and outputs for your action.

## Update the Action Code

The [`src/`](./src/) directory is the heart of your action! This contains the
Expand Down
32 changes: 20 additions & 12 deletions action.yml
Original file line number Diff line number Diff line change
@@ -1,19 +1,27 @@
name: 'The name of your action here'
description: 'Provide a description here'
author: 'Your name or organization here'

# Define your inputs here.
name: nats-publish
description: Publishes a message to a NATS subject
author: Operation Spark
inputs:
milliseconds:
description: 'Your input description here'
subject:
description: The subject to publish to
required: true
message:
description: The message to publish
required: true
default: '1000'
default: '{}'
urls:
description: The NATS server URLs
required: true
jwt:
description: The JWT to use for authentication
required: false
nKeySeed:
description: The NKey seed to use to sign the JWT
required: false

# Define your outputs here.
outputs:
time:
description: 'Your output description here'

published:
description: The published message
runs:
using: node20
main: dist/index.js

0 comments on commit 40ac333

Please sign in to comment.