Forgejo drop-in for actions/github-script: run inline JS with a Forgejo API client, context, and core. No github.com.
  • JavaScript 74.2%
  • Shell 18.8%
  • Makefile 7%
Find a file
Stephen Way f24ac03c3d
Some checks are pending
test / unit (push) Waiting to run
test / e2e (push) Waiting to run
Repoint references from rasterstate to fjord org
Org migration: the action family now lives under fjord/. Repoints internal repo references (uses:, CI badges, docs, migration guides) at fjord/ and sets the action author to fjord. The old rasterstate copies are left in place.
2026-06-03 16:17:00 -07:00
.forgejo/workflows Repoint references from rasterstate to fjord org 2026-06-03 16:17:00 -07:00
src Initial release: forgejo-script 2026-05-31 19:52:36 -07:00
tests Initial release: forgejo-script 2026-05-31 19:52:36 -07:00
.gitignore Initial release: forgejo-script 2026-05-31 19:52:36 -07:00
action.yml Repoint references from rasterstate to fjord org 2026-06-03 16:17:00 -07:00
CHANGELOG.md Initial release: forgejo-script 2026-05-31 19:52:36 -07:00
LICENSE Initial release: forgejo-script 2026-05-31 19:52:36 -07:00
Makefile Initial release: forgejo-script 2026-05-31 19:52:36 -07:00
MIGRATION.md Repoint references from rasterstate to fjord org 2026-06-03 16:17:00 -07:00
README.md Repoint references from rasterstate to fjord org 2026-06-03 16:17:00 -07:00

Forgejo Script

Forgejo's actions/github-script. Run an inline JavaScript script with a Forgejo API client, the workflow context, and core, no github.com, no octokit. The client speaks the Forgejo API.

Part of the Fjord Actions bundle.

Usage

permissions:
  contents: read
  # plus whatever your script needs (issues: write, pull-requests: write, ...)

jobs:
  triage:
    runs-on: [self-hosted, Linux]
    steps:
      - uses: https://rasterhub.com/fjord/forgejo-script@v1
        with:
          script: |
            const { owner, repo } = context.repo;
            const pr = context.payload.pull_request;
            if (pr && pr.title.startsWith('WIP')) {
              await api.post(`/repos/${owner}/${repo}/issues/${pr.number}/labels`, {
                labels: ['work-in-progress'],
              });
              core.info('labelled WIP');
            }
        env:
          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}   # a Forgejo token on Forgejo

The script runs as the body of an async function, so top-level await works and return <value> populates the result output.

In scope

Name What
api Forgejo API client (see below). The token is preset.
context repo (owner/repo), eventName, sha, ref, payload (the event JSON), issue, runId, actor, serverUrl, apiUrl, ...
core Logging, setOutput, setFailed, setSecret, input helpers.
fetch The global fetch, for anything the client doesn't cover.
require, process, console The usual Node globals.

The api client

Paths are relative to the API base (/repos/owner/name/...). Helpers return the parsed JSON body and throw on a non-2xx status:

const issues = await api.get(`/repos/${owner}/${repo}/issues?state=open`);
await api.post(`/repos/${owner}/${repo}/issues/${n}/comments`, { body: 'hi' });
await api.patch(`/repos/${owner}/${repo}/issues/${n}`, { state: 'closed' });
await api.del(`/repos/${owner}/${repo}/issues/comments/${id}`);
const all = await api.paginate(`/repos/${owner}/${repo}/issues`); // follows Link
const res = await api.request('GET', '/version');                 // {status, ok, data}

Inputs

Input Default Description
script (required) The JavaScript to run.
result-encoding json Encode the return value for the result output: json or string.
token GITHUB_TOKEN / FORGEJO_TOKEN env Forgejo token for the client.
api_url GITHUB_API_URL, then GITHUB_SERVER_URL+/api/v1 Forgejo API base.

Outputs

Output Description
result The script return value, encoded per result-encoding.

See MIGRATION.md for differences from actions/github-script.

License

MIT, see LICENSE.