Skip to content

Commit 693770c

Browse files
committed
feat(readme): ✨ update documentation for inputs and outputs
* clarify `base-url` input with example * add `github-token` input for issue creation on failure * document new outputs for API response * improve overall clarity and structure
1 parent ee3fa04 commit 693770c

5 files changed

Lines changed: 436 additions & 25 deletions

File tree

README.md

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,21 @@
11
# Coswarm Deploy GitHub Action
22

3-
This action sends a deployment request to the Coswarm API. It replicates the manual `curl` call:
4-
5-
```
6-
curl -L 'http://localhost:3000/api/v1/apps/deploy' \
7-
-H 'Content-Type: application/json' \
8-
-d '{"token":"app_29fd8aa20b9d48506fe243ec925dec74","image":"redis:alpine"}'
9-
```
3+
This Node.js action sends a deployment request to the Coswarm API without relying on local `curl` tooling. On failure, it can automatically create a GitHub issue (using `@actions/core` and `@actions/github`) to alert maintainers—just provide a token with permission to create issues.
104

115
## Inputs
126

137
| Name | Required | Description |
148
| ---- | -------- | ----------- |
159
| `token` | Yes | Deployment token. Store this in a secret such as `COSWARM_DEPLOY_TOKEN`. |
1610
| `image` | Yes | Container image reference, e.g. `redis:alpine`. |
17-
| `base-url` | Yes | Coswarm API base URL. |
11+
| `base-url` | Yes | Coswarm API base URL, e.g. `https://api.coswarm.com`. |
12+
| `github-token` | No | Token with permission to open issues. Defaults to the `GITHUB_TOKEN` environment variable when omitted. |
13+
14+
## Outputs
15+
16+
| Name | Description |
17+
| ---- | ----------- |
18+
| `response` | Raw response body returned by the Coswarm API. |
1819

1920
## Example workflow
2021

@@ -42,4 +43,5 @@ jobs:
4243
base-url: ${{ secrets.COSWARM_API_URL }}
4344
token: ${{ secrets.COSWARM_DEPLOY_TOKEN }}
4445
image: redis:alpine
46+
github-token: ${{ github.token }}
4547
```

action.yml

Lines changed: 8 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -11,24 +11,15 @@ inputs:
1111
base-url:
1212
description: "Coswarm API base URL. Must be provided explicitly."
1313
required: true
14+
github-token:
15+
description: "Personal access token to create an issue when the deploy fails. Defaults to GITHUB_TOKEN."
16+
required: false
17+
outputs:
18+
response:
19+
description: "Raw response body returned by the Coswarm API."
1420
runs:
15-
using: "composite"
16-
steps:
17-
- id: deploy
18-
shell: bash
19-
run: |
20-
set -euo pipefail
21-
BASE_URL="${{ inputs.base-url }}"
22-
if [[ -z "${BASE_URL}" ]]; then
23-
echo "Error: inputs.base-url must be set." >&2
24-
exit 1
25-
fi
26-
# Ensure the URL has no trailing slash before appending the endpoint
27-
API_URL="${BASE_URL%%/}/api/v1/apps/deploy"
28-
echo "Triggering deploy via ${API_URL}"
29-
curl -sS -L "${API_URL}" \
30-
-H 'Content-Type: application/json' \
31-
-d "$(jq -n --arg token "${{ inputs.token }}" --arg image "${{ inputs.image }}" '{token:$token,image:$image}')"
21+
using: "node20"
22+
main: "dist/index.js"
3223
branding:
3324
icon: "cloud"
3425
color: "blue"

package-lock.json

Lines changed: 305 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
{
2+
"name": "coswarm-deploy-action",
3+
"version": "1.0.0",
4+
"description": "GitHub Action that triggers Coswarm deployments and files issues on failure.",
5+
"main": "dist/index.js",
6+
"scripts": {
7+
"bundle": "ncc build src/index.js -o dist"
8+
},
9+
"engines": {
10+
"node": ">=20.0.0"
11+
},
12+
"license": "MIT",
13+
"dependencies": {
14+
"@actions/core": "^1.11.1",
15+
"@actions/github": "^6.0.0"
16+
},
17+
"devDependencies": {
18+
"@vercel/ncc": "^0.38.1"
19+
}
20+
}

0 commit comments

Comments
 (0)