- Add better secret configuration documentation with required status - Include clear setup instructions for DOCKER_IMAGE_NAME secret - Add validation check for missing DOCKER_IMAGE_NAME secret - Improve troubleshooting section with Docker push errors - Add helpful error messages for configuration issues 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com> |
||
---|---|---|
.. | ||
workflows | ||
README.md |
Forgejo Actions Configuration
This directory contains Forgejo Actions workflows for the Baktainer project. Forgejo Actions provides Continuous Integration similar to GitHub Actions but runs on Forgejo instances.
Directory Structure
.forgejo/
├── workflows/
│ └── ci.yml # Complete CI/CD pipeline
└── README.md # This file
Workflow
ci.yml
- Complete CI/CD Pipeline
- Triggers:
- Push to main branch → Test + Build + Deploy
- Version tags (v*..) → Test + Build + Deploy with version tag
- Pull requests → Test only
- Jobs: Test → Build → Notify
- Container: Ruby 3.3 Alpine (with auto-detection)
- Features:
- Test Job: Installs dependencies, runs RSpec tests
- Build Job: Builds Docker image, pushes to Docker Hub as
:latest
and:version
(for tags) - Notify Job: Reports pipeline status
- Pure Shell Commands: No GitHub Actions dependencies for maximum compatibility
- Auto-Detection: Supports multiple package managers (apk, apt-get, yum, dnf)
- Robust: Manual git cloning and Docker operations work with any Forgejo runner
Key Differences from GitHub Actions
1. Directory Location
- GitHub:
.github/workflows/
- Forgejo:
.forgejo/workflows/
2. Runner Types
- Uses
runs-on: docker
for containerized jobs - Can specify custom container images with
container:
3. Action Compatibility
- Most GitHub Actions work with Forgejo Actions
- Actions are sourced from configured action repositories
- Uses same syntax for
actions/checkout@v4
,docker/build-push-action@v5
, etc.
4. Environment Variables
- Same
${{ github.* }}
variables available - Same secret management with
${{ secrets.* }}
Required Secrets
Configure these secrets in your Forgejo repository settings (/{owner}/{repository}/settings
→ Repository → Secrets):
Secret | Description | Example | Required |
---|---|---|---|
DOCKER_USERNAME |
Docker Hub username | jamez001 |
✅ Yes |
DOCKER_PASSWORD |
Docker Hub password or token | dckr_pat_... |
✅ Yes |
DOCKER_IMAGE_NAME |
Docker image name | jamez001/baktainer |
✅ Yes |
Important: All three secrets must be configured for the workflow to succeed. Missing secrets will cause the build to fail with clear error messages.
Configuration Requirements
1. Enable Repository Actions
- Go to
/{owner}/{repository}/settings
- Click on "Repository" tab
- Check "Enable Repository Actions"
2. Forgejo Runner Setup
- Forgejo Actions requires a separate Forgejo Runner
- Runner must be configured by the Forgejo administrator
- Runner supports Docker, LXC, or host-based execution
3. Action Repository Configuration
- Actions are sourced from configured repositories
- Default actions available at https://data.forgejo.org
- Administrator can configure custom action sources
Workflow Features
Testing
- Ruby 3.3 with Alpine Linux
- RSpec test suite with progress format
- Automatic dependency installation with package manager detection
Building
- Docker builds from Alpine Ruby base
- Automatic tagging with
:latest
and version tags (:v1.2.3
) - Docker Hub integration with secure authentication
- Build status reporting
Compatibility
- Pure shell commands for maximum Forgejo runner compatibility
- Package manager auto-detection (apk, apt-get, yum, dnf)
- No external action dependencies
Usage Examples
Manual Workflow Trigger
# Push to main (triggers full CI/CD: test → build → deploy)
git push origin main
# Create and push version tag (triggers test → build → deploy with version tag)
git tag v0.1.1
git push origin v0.1.1
# Create pull request (triggers test only)
git push origin feature-branch
# Then create PR in Forgejo UI
Monitoring Workflow Status
- Navigate to repository in Forgejo
- Click on "Actions" tab
- View workflow runs and logs
- Check artifact downloads
Troubleshooting
Common Issues
-
Package manager not found / Node.js executable not found error
/var/run/act/workflow/0: line 2: apk: command not found OCI runtime exec failed: exec failed: unable to start container process: exec: "node": executable file not found in $PATH: unknown
Solutions:
- Current workflow uses pure shell commands - no GitHub Actions dependencies
- Auto-detects package manager (apk, apt-get, yum, dnf) for maximum compatibility
- If still experiencing issues: Check your Forgejo runner configuration and container image support
-
Docker push reference format error
Error parsing reference: ":latest" is not a valid repository/tag: invalid reference format
Solutions:
- Missing secret: Configure
DOCKER_IMAGE_NAME
secret in repository settings - Example value:
jamez001/baktainer
(your Docker Hub username/repository) - Path: Go to
/{owner}/{repository}/settings
→ Repository → Secrets - Verify: All three Docker secrets must be configured (USERNAME, PASSWORD, IMAGE_NAME)
- Missing secret: Configure
-
Working directory not found error
OCI runtime exec failed: exec failed: unable to start container process: chdir to cwd ("/workspace/james/baktainer/./app") set in config.json failed: no such file or directory: unknown
Solutions:
- Fixed: Workflow uses explicit
cd app
commands instead ofworking-directory
defaults - The error occurred because
working-directory
was set before repository checkout - Repository must be cloned before changing to subdirectories
- Fixed: Workflow uses explicit
-
Actions not running
- Check if Repository Actions are enabled
- Verify Forgejo Runner is installed and running
- Check workflow file syntax
-
Docker build failures
- Verify Docker Hub credentials in secrets
- Check Dockerfile syntax
- Ensure runner has Docker access
-
Test failures
- Check Ruby version compatibility
- Verify system dependencies in Alpine
- Review test output in workflow logs
-
GitHub Actions compatibility
- Not applicable: Current workflow uses only shell commands
- No external actions: Maximum compatibility with any Forgejo runner
Debugging Steps
-
Check workflow syntax:
# Validate YAML syntax yamllint .forgejo/workflows/ci.yml
-
Test locally:
# Run tests in similar environment docker run --rm -v $(pwd):/app -w /app ruby:3.3-alpine sh -c \ "apk add --no-cache build-base libffi-dev linux-headers postgresql-dev git && \ cd app && bundle install && bundle exec rspec"
-
Check logs:
- View detailed logs in Forgejo Actions UI
- Check runner logs on server
- Verify secret configuration
Migration from GitHub Actions
This workflow is designed to be compatible with the existing GitHub Actions in .github/workflows/
. Key adaptations made:
- Pure shell commands: No external action dependencies for maximum compatibility
- Runner specification: Uses
docker
with Ruby 3.3 Alpine container - Package manager detection: Auto-detects apk, apt-get, yum, or dnf
- Manual operations: Git clone and Docker commands work with any runner setup
Both GitHub Actions and Forgejo Actions can coexist in the same repository, allowing for gradual migration or dual CI/CD setup.
Simplified Design
This single workflow replaces multiple complex workflows with one simple, reliable pipeline that:
- Tests your Ruby application with RSpec
- Builds a Docker image
- Deploys by pushing to Docker Hub with proper tagging
- Works with any Forgejo runner configuration