A Forgejo-compatible fork of actions/github-script for running JavaScript in workflows.
  • TypeScript 100%
Find a file
Repository files (latest commit first)
Filename Latest commit message Latest commit date
2026-07-21 18:20:32 +03:00
.husky Upgrade husky to v9 2024-07-24 20:48:36 -07:00
.licenses/npm migrate to forgejo 2025-05-11 09:25:17 +03:00
__test__ Fix overriding request options from @actions/github 2022-09-30 15:15:18 -04:00
dist feat: migrate from forgejo-js to @maks1ms/forgejo-js in order to support a more recent version of Forgejo 2026-07-21 18:20:01 +03:00
docs prepare release 2021-11-19 19:20:22 +01:00
src feat: migrate from forgejo-js to @maks1ms/forgejo-js in order to support a more recent version of Forgejo 2026-07-21 18:20:01 +03:00
types feat: migrate from forgejo-js to @maks1ms/forgejo-js in order to support a more recent version of Forgejo 2026-07-21 18:20:01 +03:00
.eslintrc.yml Update dependencies and use Node 20 2023-10-11 16:11:59 -04:00
.gitattributes Mark licenses as generated 2020-08-06 21:05:36 -04:00
.gitignore chore: Remove .vscode settings 2025-01-28 17:18:57 -05:00
.licensed.yml Add production licenses with licensed 2020-08-06 20:27:06 -04:00
.npmrc Update dependencies and use Node 20 2023-10-11 16:11:59 -04:00
.prettierrc.yml Add ESLint and Prettier 2020-05-18 11:28:54 -04:00
action.yml migrate to forgejo 2025-05-11 09:25:17 +03:00
LICENSE.md migrate to forgejo 2025-05-11 09:25:17 +03:00
package-lock.json feat: migrate from forgejo-js to @maks1ms/forgejo-js in order to support a more recent version of Forgejo 2026-07-21 18:20:01 +03:00
package.json release: 1.1.0 2026-07-21 18:20:32 +03:00
README.md feat: migrate from forgejo-js to @maks1ms/forgejo-js in order to support a more recent version of Forgejo 2026-07-21 18:20:01 +03:00
tsconfig.eslint.json Fix null handling, covered by integration tests 2023-04-04 22:11:47 +01:00
tsconfig.json Add tests for the AsyncFunction 2020-02-27 17:27:49 -05:00

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:

  • forgejo A pre-authenticated @maks1ms/forgejo-js client
  • context An object containing the context of the workflow run
  • core A reference to the @actions/core package
  • glob A reference to the @actions/glob package
  • io A reference to the @actions/io package
  • exec A reference to the @actions/exec package
  • require A proxy wrapper around the normal Node.js require to 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-wrapped require, there is an escape hatch available: __original_require__ is the original value of require without 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!'
              }
            );