Skip to content

Commit 0600e0a

Browse files
committed
feat(docs): ✨ update README and action.yml with permissions guidance
* add permissions block example for GitHub Actions * clarify usage of `github-token` and Personal Access Token (PAT) in action.yml * bump version in package.json to 1.0.6
1 parent 2d7ffcc commit 0600e0a

3 files changed

Lines changed: 26 additions & 2 deletions

File tree

README.md

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,10 @@ on:
2828
jobs:
2929
deploy:
3030
runs-on: ubuntu-latest
31+
# Recommended: grant the job the permissions needed to post comments or update releases
32+
permissions:
33+
contents: write
34+
issues: write
3135
steps:
3236
- name: Checkout
3337
uses: actions/checkout@v4
@@ -43,5 +47,25 @@ jobs:
4347
base-url: ${{ secrets.COSWARM_API_URL }}
4448
token: ${{ secrets.COSWARM_DEPLOY_TOKEN }}
4549
image: redis:alpine
50+
# Optional: override the token used to post comments/issues/releases.
51+
# Defaults to the automatically provided GITHUB_TOKEN when omitted.
4652
github-token: ${{ github.token }}
4753
```
54+
55+
## Permissions and tokens
56+
57+
- **Prefer granting job permissions**: If the workflow runs in-repo, add a `permissions` block to the job to allow write operations (shown above).
58+
- **Forked PRs limitation**: Workflows triggered from forks do not have access to secrets and receive limited permissions; write operations (comments/releases) will fail in that context.
59+
- **Use a PAT when needed**: To guarantee write access (or to operate across repos), create a Personal Access Token with the minimal scopes you need (for release/commenting `repo` or `public_repo`) and pass it via the `github-token` input as a repository secret.
60+
61+
Example with a PAT (stored as `PERSONAL_GITHUB_TOKEN`):
62+
63+
```yaml
64+
- name: Coswarm Deploy
65+
uses: kintsdev/coswarm-deploy@latest
66+
with:
67+
base-url: ${{ secrets.COSWARM_API_URL }}
68+
token: ${{ secrets.COSWARM_DEPLOY_TOKEN }}
69+
image: redis:alpine
70+
github-token: ${{ secrets.PERSONAL_GITHUB_TOKEN }}
71+
```

action.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ inputs:
1212
description: "Coswarm API base URL. Must be provided explicitly."
1313
required: true
1414
github-token:
15-
description: "Personal access token to create an issue when the deploy fails. Defaults to GITHUB_TOKEN."
15+
description: "GitHub token used to create issues/comments and update releases. Defaults to GITHUB_TOKEN.\n\nIf you rely on the default GITHUB_TOKEN, ensure the calling workflow grants the action write permissions (for example `contents: write` and `issues: write`). For workflows triggered from forks, secrets and write permissions may be unavailable — in that case provide a Personal Access Token (PAT) via this input with minimal required scopes (e.g. `repo`/`public_repo`)."
1616
required: false
1717
outputs:
1818
response:

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "coswarm-deploy-action",
3-
"version": "1.0.5",
3+
"version": "1.0.6",
44
"description": "GitHub Action that triggers Coswarm deployments and files issues on failure.",
55
"main": "build/index.js",
66
"scripts": {

0 commit comments

Comments
 (0)