feat: run on Forgejo Actions as well as GitHub Actions #1

Open
natsukium wants to merge 3 commits from feat/forgejo-support into main
Owner

Makes the action usable from Forgejo Actions, not only GitHub Actions.
Verified end to end on this instance: run 5 posts the comment above using the
automatic workflow token, with no extra secret.

Forgejo Runner already exposes GitHub-compatible event variables, so the action
reached the right runner; what it got wrong was every URL it built.

  • Comment and compare links were hardcoded to github.com; they now come from
    GITHUB_SERVER_URL via the action context.
  • The "View diff as HTML" link used GITHUB_RUN_ID. On Forgejo that is a global
    database id (3516 for run 5 here, which 404s); run pages are addressed by the
    repository-scoped index in GITHUB_RUN_NUMBER.
  • Minimizing outdated comments is skipped on Forgejo, which has no GraphQL API,
    so those comments stay visible instead of failing the run.

Artifacts cannot work on Forgejo today. @actions/artifact 6.2 and later send a
mime_type field in CreateArtifact; Forgejo's CreateArtifactRequest protobuf
defines fields 1-5 only and its handler unmarshals without DiscardUnknown, so it
answers HTTP 500 Error decode request body. That proto has not changed since it
was ported from Gitea in March 2024, and there is no issue open for it. Pinning
back to @actions/artifact 6.1 is not an option either, because skipArchive —
which keeps the HTML viewer artifact from being double-zipped — arrived in the
same 6.2 release.

So full mode now treats the upload as a warning rather than a failed run; the PR
comment carries the diff regardless. diff-only and comment-only pass results
between jobs as artifacts and stay GitHub-only until Forgejo accepts the field.

.forgejo/workflows/test-nix-diff-action.yml exercises the action here. Adding it
also stops Forgejo from picking up .github/workflows, whose runs-on: ubuntu-latest
jobs had been failing on this instance.

Makes the action usable from Forgejo Actions, not only GitHub Actions. Verified end to end on this instance: run 5 posts the comment above using the automatic workflow token, with no extra secret. Forgejo Runner already exposes GitHub-compatible event variables, so the action reached the right runner; what it got wrong was every URL it built. - Comment and compare links were hardcoded to `github.com`; they now come from `GITHUB_SERVER_URL` via the action context. - The "View diff as HTML" link used `GITHUB_RUN_ID`. On Forgejo that is a global database id (3516 for run 5 here, which 404s); run pages are addressed by the repository-scoped index in `GITHUB_RUN_NUMBER`. - Minimizing outdated comments is skipped on Forgejo, which has no GraphQL API, so those comments stay visible instead of failing the run. Artifacts cannot work on Forgejo today. `@actions/artifact` 6.2 and later send a `mime_type` field in `CreateArtifact`; Forgejo's `CreateArtifactRequest` protobuf defines fields 1-5 only and its handler unmarshals without `DiscardUnknown`, so it answers HTTP 500 `Error decode request body`. That proto has not changed since it was ported from Gitea in March 2024, and there is no issue open for it. Pinning back to `@actions/artifact` 6.1 is not an option either, because `skipArchive` — which keeps the HTML viewer artifact from being double-zipped — arrived in the same 6.2 release. So full mode now treats the upload as a warning rather than a failed run; the PR comment carries the diff regardless. `diff-only` and `comment-only` pass results between jobs as artifacts and stay GitHub-only until Forgejo accepts the field. `.forgejo/workflows/test-nix-diff-action.yml` exercises the action here. Adding it also stops Forgejo from picking up `.github/workflows`, whose `runs-on: ubuntu-latest` jobs had been failing on this instance.
feat: run on Forgejo Actions as well as GitHub Actions
Some checks failed
Test nix-diff-action / environment (pull_request) Successful in 0s
Test nix-diff-action / full (pull_request) Failing after 53s
baaa710cb4
Forgejo Runner exposes GitHub-compatible event variables, so the action
already reached the right runner; what it got wrong was every URL it
built. Comment and compare links were hardcoded to github.com instead of
GITHUB_SERVER_URL, and the run link used GITHUB_RUN_ID, which on Forgejo
is a global database id rather than the repository-scoped index its run
pages are addressed by.

@actions/artifact refuses any host but github.com before it ever touches
ACTIONS_RESULTS_URL, which Forgejo serves compatibly. Vendoring a patched
copy would tie this action's releases to upstream's, so only the host
guard's input is masked while every service URL stays Forgejo's.

Minimizing outdated comments is skipped on Forgejo because it has no
GraphQL API; the comments stay visible rather than failing the run.
fix: keep Forgejo runs green when artifact upload is impossible
All checks were successful
Test nix-diff-action / environment (pull_request) Successful in 1s
Test nix-diff-action / full (pull_request) Successful in 10s
e06bfccbe5
@actions/artifact 6.2 and later send a mime_type field in CreateArtifact.
Forgejo's CreateArtifactRequest protobuf defines no such field and its
handler unmarshals without DiscardUnknown, so it rejects the request with
HTTP 500 rather than ignoring the unknown field. Pinning back to 6.1 is
not an option because skipArchive, which keeps the HTML viewer artifact
from being double-zipped, arrived in the same release.

Full mode's real output is the PR comment, which already carries the
diff, so the upload is now a warning there instead of a failed run. The
host guard bypass is gone with it: getting past that check only moved the
failure one request further along. diff-only and comment-only hand
results between jobs as artifacts and stay GitHub-only until Forgejo
accepts the field.
test: exercise the Forgejo comment path unconditionally
All checks were successful
Test nix-diff-action / full (pull_request) Successful in 9s
6105aa0717
A pull request that changes no derivation would otherwise skip the
comment, leaving the Forgejo comment API path untested.

Nix Diff

Compare changes

devShell

Attribute: devShells.x86_64-linux.default

Diff Output
<<< /nix/store/mg75d77v92ggczjfbi3aq1gf2p5hh7kf-nix-shell.drv
>>> /nix/store/mg75d77v92ggczjfbi3aq1gf2p5hh7kf-nix-shell.drv

PATHS: 3943 -> 3943 (+0, -0)
SIZE: 14.4 MiB -> 14.4 MiB
DIFF: 0 bytes

Generated by nix-diff-action using dix

<!-- nix-diff-action:devShell --> ## Nix Diff [Compare changes](https://git.natsukium.com/natsukium/nix-diff-action/compare/92ef45c2e2b793e14b981b57f972bcdd5da71ee3...6105aa071770d7c24a4f00b6a81b23c74293300f) ### devShell **Attribute**: `devShells.x86_64-linux.default` <details> <summary>Diff Output</summary> ``` <<< /nix/store/mg75d77v92ggczjfbi3aq1gf2p5hh7kf-nix-shell.drv >>> /nix/store/mg75d77v92ggczjfbi3aq1gf2p5hh7kf-nix-shell.drv PATHS: 3943 -> 3943 (+0, -0) SIZE: 14.4 MiB -> 14.4 MiB DIFF: 0 bytes ``` </details> --- <sub>Generated by [nix-diff-action](https://github.com/natsukium/nix-diff-action) using [dix](https://github.com/manic-systems/dix)</sub> <!-- nix-diff-action-footer sha=6105aa071770d7c24a4f00b6a81b23c74293300f -->
All checks were successful
Test nix-diff-action / full (pull_request) Successful in 9s
This pull request can be merged automatically.
You are not authorized to merge this pull request.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin feat/forgejo-support:feat/forgejo-support
git switch feat/forgejo-support

Merge

Merge the changes and update on Forgejo.

Warning: The "Autodetect manual merge" setting is not enabled for this repository, you will have to mark this pull request as manually merged afterwards.

git switch main
git merge --no-ff feat/forgejo-support
git switch feat/forgejo-support
git rebase main
git switch main
git merge --ff-only feat/forgejo-support
git switch feat/forgejo-support
git rebase main
git switch main
git merge --no-ff feat/forgejo-support
git switch main
git merge --squash feat/forgejo-support
git switch main
git merge --ff-only feat/forgejo-support
git switch main
git merge feat/forgejo-support
git push origin main
Sign in to join this conversation.
No reviewers
No labels
No milestone
No assignees
2 participants
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
natsukium/nix-diff-action!1
No description provided.