- TypeScript 100%
| Filename | Latest commit message | Latest commit date |
|---|---|---|
| .husky | ||
| .licenses/npm | ||
| __test__ | ||
| dist | ||
| docs | ||
| src | ||
| types | ||
| .eslintrc.yml | ||
| .gitattributes | ||
| .gitignore | ||
| .licensed.yml | ||
| .npmrc | ||
| .prettierrc.yml | ||
| action.yml | ||
| LICENSE.md | ||
| package-lock.json | ||
| package.json | ||
| README.md | ||
| tsconfig.eslint.json | ||
| tsconfig.json | ||
actions/forgejo-script
This action makes it easy to quickly write a script in your workflow that uses the Forgejo API and the workflow run context.
To use this action, provide an input named script that contains the body of an asynchronous JavaScript function call.
The following arguments will be provided:
forgejoA pre-authenticated @maks1ms/forgejo-js clientcontextAn object containing the context of the workflow runcoreA reference to the @actions/core packageglobA reference to the @actions/glob packageioA reference to the @actions/io packageexecA reference to the @actions/exec packagerequireA proxy wrapper around the normal Node.jsrequireto enable requiring relative paths (relative to the current working directory) and requiring npm packages installed in the current working directory. If for some reason you need the non-wrappedrequire, there is an escape hatch available:__original_require__is the original value ofrequirewithout our wrapping applied.
Since the script is just a function body, these values will already be
defined, so you don't have to import them (see examples below).
Development
See development.md.
Reading step results
The return value of the script will be in the step's outputs under the "result" key.
- uses: actions/forgejo-script@v1
id: set-result
with:
script: return "Hello!"
result-encoding: string
- name: Get result
run: echo "${{steps.set-result.outputs.result}}"
See "Result encoding" for details on how the encoding of these outputs can be changed.
Result encoding
By default, the JSON-encoded return value of the function is set as the "result" in the
output of a forgejo-script step. For some workflows, string encoding is preferred. This option can be set using the
result-encoding input:
- uses: actions/forgejo-script@v1
id: my-script
with:
result-encoding: string
script: return "I will be string (not JSON) encoded!"
Examples
Note that github-token is optional in this action, and the input is there
in case you need to use a non-default token.
By default, github-script will use the token provided to your workflow.
Print the available attributes of context
- name: View context attributes
uses: actions/forgejo-script@v1
with:
script: console.log(context)
Comment on an issue
on:
issues:
types: [opened]
jobs:
comment:
runs-on: ubuntu-latest
steps:
- uses: actions/forgejo-script@v1
with:
script: |
await forgejo.repos.issueCreateComment(
context.repo.owner,
context.repo.repo,
context.payload.issue.number,
{
body: '👋 Thanks for reporting!'
}
);