Forgejo sccache action with automatic version detection
Find a file
Tom Foster 909cdda68a
All checks were successful
Test sccache action / test-action (push) Successful in 4s
Mirror sccache binaries / mirror-sccache (push) Successful in 5s
refactor: convert to Forgejo-only action with package registry support
Remove GitHub API dependencies and simplify for Forgejo environments exclusively.
Implements automatic version detection from Forgejo package registry with API
fallback to HTML parsing.

Includes comprehensive test workflow and pre-commit configuration for code quality.
Removes token requirement and reduces bundle size from 629kB to 517kB.
2025-09-07 08:46:35 +01:00
.forgejo/workflows refactor: convert to Forgejo-only action with package registry support 2025-09-07 08:46:35 +01:00
dist refactor: convert to Forgejo-only action with package registry support 2025-09-07 08:46:35 +01:00
src refactor: convert to Forgejo-only action with package registry support 2025-09-07 08:46:35 +01:00
.eslintrc.json Fix lint 2023-01-10 12:41:30 +08:00
.gitattributes Fix attr 2023-01-11 11:21:31 +08:00
.gitignore ci: add Forgejo workflow to mirror sccache binaries 2025-09-06 21:37:10 +01:00
.markdownlint.yaml refactor: convert to Forgejo-only action with package registry support 2025-09-07 08:46:35 +01:00
.pre-commit-config.yaml refactor: convert to Forgejo-only action with package registry support 2025-09-07 08:46:35 +01:00
.prettierrc.json feat: Implement basic sccache action support 2023-01-09 23:29:45 +08:00
action.yml refactor: convert to Forgejo-only action with package registry support 2025-09-07 08:46:35 +01:00
LICENSE Add license 2023-01-09 15:53:06 +01:00
package-lock.json Bump ts-jest from 29.2.6 to 29.3.2 (#200) 2025-05-28 08:52:12 +02:00
package.json refactor: convert to Forgejo-only action with package registry support 2025-09-07 08:46:35 +01:00
README.md refactor: convert to Forgejo-only action with package registry support 2025-09-07 08:46:35 +01:00
tsconfig.json feat: Implement basic sccache action support 2023-01-09 23:29:45 +08:00

sccache-action (Forgejo fork)

This is a Forgejo-optimised fork of Mozilla's sccache-action that eliminates GitHub API dependencies and rate limiting issues. It's designed specifically for Forgejo environments and won't work on GitHub - use the original Mozilla action for GitHub workflows.

The action integrates sccache into your Forgejo Actions workflows to cache compilation results, significantly reducing build times across subsequent runs.

How it works

Rather than downloading binaries directly from GitHub (which requires authentication and hits rate limits), this fork:

  1. Mirrors sccache releases automatically using a Forgejo workflow that checks for updates and stores binaries in your instance's package registry
  2. Detects versions dynamically by querying your Forgejo instance's package API to find the latest available version
  3. Downloads locally from your own package registry, avoiding external dependencies entirely

The action automatically detects which Forgejo instance it's running on and uses the appropriate package registry - no configuration needed.

Usage

Add this step to your Forgejo Actions workflow:

The action automatically finds the latest sccache version available in your package registry:

- name: Setup sccache
  uses: your-forgejo-instance/owner/sccache-action@v1

Specify a particular version

If you need a specific version:

- name: Setup sccache
  uses: your-forgejo-instance/owner/sccache-action@v1
  with:
    version: "v0.10.0"

Custom registry configuration

To use a different Forgejo instance or repository for sccache packages:

- name: Setup sccache
  uses: your-forgejo-instance/owner/sccache-action@v1
  with:
    server: "https://your-forgejo.example.com"
    owner: "your-owner"

For action maintainers: You can change the defaults by editing the action.yml file and updating the server and owner default values. This allows you to fork the action and point it to your own package registry without requiring users to specify these inputs.

Conditional caching

Only enable caching for certain workflow types:

- name: Setup sccache for development builds
  if: github.event_name != 'release'
  uses: your-forgejo-instance/owner/sccache-action@v1

- name: Configure Rust to use sccache
  if: github.event_name != 'release'
  run: |
    echo "SCCACHE_GHA_ENABLED=true" >> $GITHUB_ENV
    echo "RUSTC_WRAPPER=sccache" >> $GITHUB_ENV

View compilation statistics

The action automatically creates a post-run step to show stats. You can also check stats manually:

- name: Show sccache statistics
  run: ${SCCACHE_PATH} --show-stats

Disable automatic stats reporting

- name: Setup sccache
  uses: your-forgejo-instance/owner/sccache-action@v1
  with:
    disable_annotations: true

Language-specific configuration

Rust projects

Enable sccache for Rust compilation:

env:
  SCCACHE_GHA_ENABLED: "true"
  RUSTC_WRAPPER: "sccache"

C/C++ projects

For C/C++ projects, enable the cache and configure your build system:

env:
  SCCACHE_GHA_ENABLED: "true"

With CMake:

cmake -DCMAKE_C_COMPILER_LAUNCHER=sccache -DCMAKE_CXX_COMPILER_LAUNCHER=sccache

With configure scripts:

# Using GCC
./configure CC="sccache gcc" CXX="sccache g++"
# Using Clang
./configure CC="sccache clang" CXX="sccache clang++"

Setting up the mirroring workflow

To use this action, you'll need the mirroring workflow that downloads sccache releases and stores them in your package registry. The workflow is included in this repository at .forgejo/workflows/mirror-sccache.yml.

  1. Fork this repository to your Forgejo instance
  2. The mirroring workflow runs automatically daily and whenever you push changes
  3. It checks for new sccache releases and mirrors missing versions to your package registry
  4. Your workflows can then use the action with automatic version detection

The mirroring workflow requires a FORGEJO_TOKEN secret with package write permissions.

License

Apache-2.0 (just like sccache)