Compare commits

..

22 Commits

Author SHA1 Message Date
Jonathan Miller a66f88e0bf feat(notify): native ntfy push notification integration (#41)
Add ntfy as a native notification channel via the Notifier interface.

Events notified:
- NewIssue — new issue created
- IssueChangeStatus — issue closed/reopened
- NewPullRequest — new PR opened
- MergePullRequest — PR merged
- NewRelease — new release published
- WorkflowRunStatusUpdate — CI success/failure

Implementation:
- modules/setting/ntfy.go — [ntfy] config section
- services/ntfy/ntfy.go — HTTP POST sender with 5s timeout
- services/ntfy/notifier.go — Notifier implementation (async, non-blocking)

Config:
  [ntfy]
  ENABLED = true
  SERVER_URL = https://ntfy.mokoconsulting.tech
  DEFAULT_TOPIC = mokogitea

Closes #41

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-05-20 20:06:50 -05:00
jmiller 58782a3920 Merge pull request 'feat(api): native SVG badge engine (#103)' (#127) from feat/badge-engine into dev 2026-05-21 01:04:47 +00:00
jmiller 53b7e378d1 Merge pull request 'feat(metrics): Prometheus app metrics (#42)' (#126) from feat/prometheus-metrics into dev 2026-05-21 01:04:41 +00:00
jmiller ad78bb7c27 Merge pull request 'feat(admin): MokoGitea update checker (#74)' (#125) from feat/update-checker into dev 2026-05-21 01:04:36 +00:00
Jonathan Miller ff016ed888 fix: restore .mokogitea support for issue/PR templates and file icons
These were lost during the src/ revert. Re-add .mokogitea as
first-priority search path for:
- Issue template directories (services/issue/template.go)
- Issue template config candidates
- Single-file issue template candidates (routers/web/repo/issue.go)
- PR template candidates (routers/web/repo/pull.go)
- File icon rules (options/fileicon/material-icon-rules.json)

Already preserved from the revert:
- Workflow dirs (modules/setting/actions.go)
- Repo template file (services/repository/generate.go)
- Vendor analysis (modules/analyze/vendor.go)
- README view (routers/web/repo/view_readme.go)

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-05-20 19:16:20 -05:00
Jonathan Miller 33fd9c5620 test: add .mokogitea test fixtures for workflow and template discovery
Add test workflow and issue template under .mokogitea/ to verify
the dot-folder feature works end-to-end on the live server.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-05-20 18:27:31 -05:00
Jonathan Miller 6f1b83eb74 feat(api): native SVG badge engine (#103)
Branch Policy Check / Verify merge target (pull_request) Successful in 1s
Self-hosted badge generation at /api/v1/repos/{owner}/{repo}/badge/{type}.svg

Badge types:
- version: latest release tag
- build: commit status (passing/failing/pending)
- license: repo license
- health: composite score (wiki + license + description)

Renders shields.io-compatible flat-style SVG badges with caching.
No external dependencies — uses stdlib html/template.

Closes #103

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-05-20 04:43:23 -05:00
Jonathan Miller d300cde639 feat(metrics): add active users, actions queue/running to Prometheus (#42)
Branch Policy Check / Verify merge target (pull_request) Successful in 1s
Extend the existing /metrics endpoint with 3 new application metrics:
- gitea_active_users_30d: users active in last 30 days
- gitea_actions_queue_length: pending action jobs
- gitea_actions_running_jobs: currently running jobs

No new dependencies — extends existing collector and statistic model.

Closes #42

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-05-19 21:44:37 -05:00
Jonathan Miller 05f1ac1a12 feat(admin): add MokoGitea update checker (#74)
Branch Policy Check / Verify merge target (pull_request) Successful in 1s
Replace removed upstream Gitea update checker with MokoGitea-native
version that checks our own releases API.

- New module: modules/updatechecker/ — fetches latest release from
  git.mokoconsulting.tech, compares semver, caches result
- Cron task: runs every 24h (and at startup)
- Admin dashboard: shows green banner when update available
- Configurable via [update_checker] in app.ini

Closes #74

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-05-19 21:41:10 -05:00
Jonathan Miller 5d84da9ae8 feat(ci): deploy workflow pushes Docker images to container registry
Updated deploy workflow:
- Builds image, pushes to git.mokoconsulting.tech container registry
- Supports dev and production environments via input selector
- Tags: v1.26.1-moko.N (production) or v1.26.1-moko.N-dev (dev)
- Always pushes :latest alongside versioned tag
- Images pullable from any machine via docker pull

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-05-19 21:18:16 -05:00
Jonathan Miller a8a01ed978 Merge branch 'dev' 2026-05-19 20:32:22 -05:00
jmiller b441b0a350 chore: add issue templates [skip ci] 2026-05-20 00:37:37 +00:00
jmiller fcbc28735e chore: add issue templates [skip ci] 2026-05-20 00:37:31 +00:00
jmiller 5c3a36a225 chore: add issue templates [skip ci] 2026-05-20 00:37:25 +00:00
jmiller 8936883a40 chore: add issue templates [skip ci] 2026-05-20 00:37:19 +00:00
jmiller c3af273401 chore: add issue templates [skip ci] 2026-05-20 00:37:14 +00:00
jmiller 77f3a522eb chore: add issue templates [skip ci] 2026-05-20 00:37:08 +00:00
jmiller de2a2c9013 chore: add issue templates [skip ci] 2026-05-20 00:37:03 +00:00
jmiller a78e610040 chore: add issue templates [skip ci] 2026-05-20 00:36:58 +00:00
jmiller 707eec0098 chore: add issue templates [skip ci] 2026-05-20 00:36:53 +00:00
jmiller 8c89a33ecf Merge pull request 'feat(branding): replace all Gitea logos with Moko Consulting branding' (#124) from feat/custom-logo into main 2026-05-20 00:36:17 +00:00
Jonathan Miller 6f82c6af7f feat(branding): replace all Gitea logos with Moko Consulting branding
Branch Policy Check / Verify merge target (pull_request) Failing after 1s
Replace default Gitea logo.svg/logo.png with Moko Consulting logo:
- Home/login page (large logo)
- Navbar (top-left icon)
- OpenID sign-in page
- OpenGraph meta image
- 500 error page

Logo URL: https://mokoconsulting.tech/images/branding/logo.png

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-05-19 19:32:37 -05:00
34 changed files with 1261 additions and 146 deletions
+110
View File
@@ -0,0 +1,110 @@
---
name: Architecture Decision Record (ADR)
about: Propose or document an architectural decision
title: '[ADR] '
labels: 'architecture, decision'
assignees: ''
---
## ADR Number
ADR-XXXX
## Status
- [ ] Proposed
- [ ] Accepted
- [ ] Deprecated
- [ ] Superseded by ADR-XXXX
## Context
Describe the issue or problem that motivates this decision.
## Decision
State the architecture decision and provide rationale.
## Consequences
### Positive
- List positive consequences
### Negative
- List negative consequences or trade-offs
### Neutral
- List neutral aspects
## Alternatives Considered
### Alternative 1
- Description
- Pros
- Cons
- Why not chosen
### Alternative 2
- Description
- Pros
- Cons
- Why not chosen
## Implementation Plan
1. Step 1
2. Step 2
3. Step 3
## Stakeholders
- **Decision Makers**: @user1, @user2
- **Consulted**: @user3, @user4
- **Informed**: team-name
## Technical Details
### Architecture Diagram
```
[Add diagram or link]
```
### Dependencies
- Dependency 1
- Dependency 2
### Impact Analysis
- **Performance**: [Impact description]
- **Security**: [Impact description]
- **Scalability**: [Impact description]
- **Maintainability**: [Impact description]
## Testing Strategy
- [ ] Unit tests
- [ ] Integration tests
- [ ] Performance tests
- [ ] Security tests
## Documentation
- [ ] Architecture documentation updated
- [ ] API documentation updated
- [ ] Developer guide updated
- [ ] Runbook created
## Migration Path
Describe how to migrate from current state to new architecture.
## Rollback Plan
Describe how to rollback if issues occur.
## Timeline
- **Proposal Date**:
- **Decision Date**:
- **Implementation Start**:
- **Expected Completion**:
## References
- Related ADRs:
- External resources:
- RFCs:
## Review Checklist
- [ ] Aligns with enterprise architecture principles
- [ ] Security implications reviewed
- [ ] Performance implications reviewed
- [ ] Cost implications reviewed
- [ ] Compliance requirements met
- [ ] Team consensus achieved
+48
View File
@@ -0,0 +1,48 @@
---
name: Bug Report
about: Report a bug or issue with the project
title: '[BUG] '
labels: 'bug'
assignees: ''
---
## Bug Description
A clear and concise description of what the bug is.
## Steps to Reproduce
1. Go to '...'
2. Click on '...'
3. Scroll down to '...'
4. See error
## Expected Behavior
A clear and concise description of what you expected to happen.
## Actual Behavior
A clear and concise description of what actually happened.
## Screenshots
If applicable, add screenshots to help explain your problem.
## Environment
- **Project**: [e.g., MokoDoliTools, moko-cassiopeia]
- **Version**: [e.g., 1.2.3]
- **Platform**: [e.g., Dolibarr 18.0, Joomla 5.0]
- **PHP Version**: [e.g., 8.1]
- **Database**: [e.g., MySQL 8.0, PostgreSQL 14]
- **Browser** (if applicable): [e.g., Chrome 120, Firefox 121]
- **OS**: [e.g., Ubuntu 22.04, Windows 11]
## Additional Context
Add any other context about the problem here.
## Possible Solution
If you have suggestions on how to fix the issue, please describe them here.
## Checklist
- [ ] I have searched for similar issues before creating this one
- [ ] I have provided all the requested information
- [ ] I have tested this on the latest stable version
- [ ] I have checked the documentation and couldn't find a solution
+18
View File
@@ -0,0 +1,18 @@
---
blank_issues_enabled: true
contact_links:
- name: 💼 Enterprise Support
url: https://mokoconsulting.tech/enterprise
about: Enterprise-level support and consultation services
- name: 💬 Ask a Question
url: https://mokoconsulting.tech/
about: Get help or ask questions through our website
- name: 📚 MokoStandards Documentation
url: https://git.mokoconsulting.tech/MokoConsulting/moko-platform
about: View our coding standards and best practices
- name: 🔒 Report a Security Vulnerability
url: https://git.mokoconsulting.tech/mokoconsulting-tech/.github-private/security/advisories/new
about: Report security vulnerabilities privately (for critical issues)
- name: 💡 Community Discussions
url: https://github.com/orgs/mokoconsulting-tech/discussions
about: Join community discussions and Q&A
+52
View File
@@ -0,0 +1,52 @@
---
name: Documentation Issue
about: Report an issue with documentation
title: '[DOCS] '
labels: 'documentation'
assignees: ''
---
## Documentation Issue
**Location**:
<!-- Specify the file, page, or section with the issue -->
## Issue Type
<!-- Mark the relevant option with an "x" -->
- [ ] Typo or grammar error
- [ ] Outdated information
- [ ] Missing documentation
- [ ] Unclear explanation
- [ ] Broken links
- [ ] Missing examples
- [ ] Other (specify below)
## Description
<!-- Clearly describe the documentation issue -->
## Current Content
<!-- Quote or describe the current documentation (if applicable) -->
```
Current text here
```
## Suggested Improvement
<!-- Provide your suggestion for how to improve the documentation -->
```
Suggested text here
```
## Additional Context
<!-- Add any other context, screenshots, or references -->
## Standards Alignment
- [ ] Follows MokoStandards documentation guidelines
- [ ] Uses en_US/en_GB localization
- [ ] Includes proper SPDX headers where applicable
## Checklist
- [ ] I have searched for similar documentation issues
- [ ] I have provided a clear description
- [ ] I have suggested an improvement (if applicable)
+51
View File
@@ -0,0 +1,51 @@
---
name: Feature Request
about: Suggest a new feature or enhancement
title: '[FEATURE] '
labels: 'enhancement'
assignees: ''
---
## Feature Description
A clear and concise description of the feature you'd like to see.
## Problem or Use Case
Describe the problem this feature would solve or the use case it addresses.
Ex. I'm always frustrated when [...]
## Proposed Solution
A clear and concise description of what you want to happen.
## Alternative Solutions
A clear and concise description of any alternative solutions or features you've considered.
## Benefits
Describe how this feature would benefit users:
- Who would use this feature?
- What problems does it solve?
- What value does it add?
## Implementation Details (Optional)
If you have ideas about how this could be implemented, share them here:
- Technical approach
- Files/components that might need changes
- Any concerns or challenges you foresee
## Additional Context
Add any other context, mockups, or screenshots about the feature request here.
## Relevant Standards
Does this relate to any standards in [MokoStandards](https://git.mokoconsulting.tech/MokoConsulting/MokoStandards)?
- [ ] Accessibility (WCAG 2.1 AA)
- [ ] Localization (en_US/en_GB)
- [ ] Security best practices
- [ ] Code quality standards
- [ ] Other: [specify]
## Checklist
- [ ] I have searched for similar feature requests before creating this one
- [ ] I have clearly described the use case and benefits
- [ ] I have considered alternative solutions
- [ ] This feature aligns with the project's goals and scope
+82
View File
@@ -0,0 +1,82 @@
---
name: Question
about: Ask a question about usage, features, or best practices
title: '[QUESTION] '
labels: ['question']
assignees: ['jmiller']
---
## Question
**Your question:**
## Context
**What are you trying to accomplish?**
**What have you already tried?**
**Category**:
- [ ] Script usage
- [ ] Configuration
- [ ] Workflow setup
- [ ] Documentation interpretation
- [ ] Best practices
- [ ] Integration
- [ ] Other: __________
## Environment (if relevant)
**Your setup**:
- Operating System:
- Version:
## What You've Researched
**Documentation reviewed**:
- [ ] README.md
- [ ] Project documentation
- [ ] Other (specify): __________
**Similar issues/questions found**:
- #
- #
## Expected Outcome
**What result are you hoping for?**
## Code/Configuration Samples
**Relevant code or configuration** (if applicable):
```bash
# Your code here
```
## Additional Context
**Any other relevant information:**
**Screenshots** (if helpful):
## Urgency
- [ ] Urgent (blocking work)
- [ ] Normal (can work on other things meanwhile)
- [ ] Low priority (just curious)
## Checklist
- [ ] I have searched existing issues and discussions
- [ ] I have reviewed relevant documentation
- [ ] I have provided sufficient context
- [ ] I have included code/configuration samples if relevant
- [ ] This is a genuine question (not a bug report or feature request)
+126
View File
@@ -0,0 +1,126 @@
---
name: Request for Comments (RFC)
about: Propose a significant change for community discussion
title: '[RFC] '
labels: 'rfc, discussion'
assignees: ''
---
## RFC Summary
One-paragraph summary of the proposal.
## Motivation
Why are we doing this? What use cases does it support? What is the expected outcome?
## Detailed Design
### Overview
Provide a detailed explanation of the proposed change.
### API Changes (if applicable)
```php
// Before
function oldApi($param1) { }
// After
function newApi($param1, $param2) { }
```
### User Experience Changes
Describe how users will interact with this change.
### Implementation Approach
High-level implementation strategy.
## Drawbacks
Why should we *not* do this?
## Alternatives
What other designs have been considered? What is the impact of not doing this?
### Alternative 1
- Description
- Trade-offs
### Alternative 2
- Description
- Trade-offs
## Adoption Strategy
How will existing users adopt this? Is this a breaking change?
### Migration Guide
```bash
# Steps to migrate
```
### Deprecation Timeline
- **Announcement**:
- **Deprecation**:
- **Removal**:
## Unresolved Questions
- Question 1
- Question 2
## Future Possibilities
What future work does this enable?
## Impact Assessment
### Performance
Expected performance impact.
### Security
Security considerations and implications.
### Compatibility
- **Backward Compatible**: [Yes / No]
- **Breaking Changes**: [List]
### Maintenance
Long-term maintenance considerations.
## Community Input
### Stakeholders
- [ ] Core team
- [ ] Module developers
- [ ] End users
- [ ] Enterprise customers
### Feedback Period
**Duration**: [e.g., 2 weeks]
**Deadline**: [date]
## Implementation Timeline
### Phase 1: Design
- [ ] RFC discussion
- [ ] Design finalization
- [ ] Approval
### Phase 2: Implementation
- [ ] Core implementation
- [ ] Tests
- [ ] Documentation
### Phase 3: Release
- [ ] Beta release
- [ ] Feedback collection
- [ ] Stable release
## Success Metrics
How will we measure success?
- Metric 1
- Metric 2
## References
- Related RFCs:
- External documentation:
- Prior art:
## Open Questions for Community
1. Question 1?
2. Question 2?
---
**Note**: This RFC is open for community discussion. Please provide feedback in the comments below.
+51
View File
@@ -0,0 +1,51 @@
---
name: Security Vulnerability Report
about: Report a security vulnerability (use only for non-critical issues)
title: '[SECURITY] '
labels: 'security'
assignees: ''
---
## ⚠️ IMPORTANT: Private Disclosure Required
**For critical security vulnerabilities, DO NOT use this template.**
Follow the process in [SECURITY.md](../SECURITY.md) for responsible disclosure.
Use this template only for:
- Security improvements
- Non-critical security suggestions
- Security documentation updates
---
## Security Issue
**Severity**:
<!-- Low, Medium, or informational only -->
## Description
<!-- Describe the security concern or improvement suggestion -->
## Affected Components
<!-- List the affected files, features, or components -->
## Suggested Mitigation
<!-- Describe how this could be addressed -->
## Standards Reference
Does this relate to security standards in [MokoStandards](https://git.mokoconsulting.tech/MokoConsulting/MokoStandards)?
- [ ] SPDX license identifiers
- [ ] Secret management
- [ ] Dependency security
- [ ] Access control
- [ ] Other: [specify]
## Additional Context
<!-- Add any other context about the security concern -->
## Checklist
- [ ] This is NOT a critical vulnerability requiring private disclosure
- [ ] I have reviewed the SECURITY.md policy
- [ ] I have provided sufficient detail for evaluation
+24
View File
@@ -0,0 +1,24 @@
---
name: Version Bump
about: Request or track a version change
title: '[VERSION] '
labels: 'version, type: version'
assignees: 'jmiller'
---
## Version Change
**Current version**: <!-- e.g., 01.02.03 -->
**Requested version**: <!-- e.g., 01.03.00 -->
**Change type**: <!-- patch / minor / major -->
## Reason
<!-- Why is this version bump needed? -->
## Checklist
- [ ] README.md `VERSION:` field updated
- [ ] CHANGELOG.md entry added
- [ ] Module descriptor version updated (Dolibarr: `$this->version`, Joomla: `<version>`)
- [ ] All file headers will be auto-propagated by `sync-version-on-merge` workflow
+60 -28
View File
@@ -1,6 +1,6 @@
# Copyright (C) 2026 Moko Consulting <hello@mokoconsulting.tech>
# SPDX-License-Identifier: GPL-3.0-or-later
# BRIEF: Build and deploy MokoGitea via SSH to production server
# BRIEF: Build MokoGitea Docker image, push to registry, and deploy
name: Deploy MokoGitea
@@ -8,9 +8,17 @@ on:
workflow_dispatch:
inputs:
version:
description: 'Version tag (e.g. v05.00.00)'
description: 'Version tag (e.g. v1.26.1-moko.2)'
required: true
default: 'latest'
environment:
description: 'Target environment'
required: true
default: 'dev'
type: choice
options:
- dev
- production
concurrency:
group: deploy-mokogitea
@@ -22,22 +30,39 @@ env:
DEPLOY_HOST: git.mokoconsulting.tech
DEPLOY_PORT: 2918
DEPLOY_USER: mokoconsulting
COMPOSE_DIR: /opt/gitea
SOURCE_DIR: /opt/gitea/source
jobs:
deploy:
runs-on: ubuntu-latest
steps:
- name: Determine version tag
id: version
- name: Determine settings
id: config
run: |
echo "tag=${{ github.event.inputs.version }}" >> $GITHUB_OUTPUT
VERSION="${{ github.event.inputs.version }}"
ENV="${{ github.event.inputs.environment }}"
- name: Deploy via SSH
if [ "$ENV" = "production" ]; then
echo "compose_dir=/opt/gitea" >> $GITHUB_OUTPUT
echo "container=mokogitea" >> $GITHUB_OUTPUT
echo "source_dir=/opt/gitea/source" >> $GITHUB_OUTPUT
echo "branch=main" >> $GITHUB_OUTPUT
echo "tag=${VERSION}" >> $GITHUB_OUTPUT
else
echo "compose_dir=/opt/gitea-dev" >> $GITHUB_OUTPUT
echo "container=mokogitea-dev" >> $GITHUB_OUTPUT
echo "source_dir=/opt/gitea-dev/source" >> $GITHUB_OUTPUT
echo "branch=dev" >> $GITHUB_OUTPUT
echo "tag=${VERSION}-dev" >> $GITHUB_OUTPUT
fi
- name: Build, push, and deploy via SSH
env:
SSH_PRIVATE_KEY: ${{ secrets.DEPLOY_SSH_KEY }}
VERSION_TAG: ${{ steps.version.outputs.tag }}
TAG: ${{ steps.config.outputs.tag }}
BRANCH: ${{ steps.config.outputs.branch }}
SOURCE_DIR: ${{ steps.config.outputs.source_dir }}
COMPOSE_DIR: ${{ steps.config.outputs.compose_dir }}
CONTAINER: ${{ steps.config.outputs.container }}
run: |
mkdir -p ~/.ssh
echo "$SSH_PRIVATE_KEY" > ~/.ssh/deploy_key
@@ -47,56 +72,63 @@ jobs:
$SSH_CMD "echo 'SSH connected'"
# Clone or update source
# Pull latest source
$SSH_CMD "
set -e
if [ ! -d ${{ env.SOURCE_DIR }}/.git ]; then
git clone https://git.mokoconsulting.tech/MokoConsulting/MokoGitea.git ${{ env.SOURCE_DIR }}
if [ ! -d ${SOURCE_DIR}/.git ]; then
git clone -b ${BRANCH} https://git.mokoconsulting.tech/MokoConsulting/MokoGitea.git ${SOURCE_DIR}
fi
cd ${{ env.SOURCE_DIR }}
git fetch origin main
git reset --hard origin/main
cd ${SOURCE_DIR}
git fetch origin ${BRANCH}
git reset --hard origin/${BRANCH}
"
# Build Docker image on server (standard root layout, -p 1 for 12GB server)
# Build Docker image
$SSH_CMD "
set -e
cd ${{ env.SOURCE_DIR }}
docker build \
--build-arg GOFLAGS='-p 1' \
--tag ${{ env.REGISTRY }}/${{ env.IMAGE }}:${VERSION_TAG} \
cd ${SOURCE_DIR}
docker build --no-cache --build-arg GOFLAGS='-p 1' \
--tag ${{ env.REGISTRY }}/${{ env.IMAGE }}:${TAG} \
--tag ${{ env.REGISTRY }}/${{ env.IMAGE }}:latest \
-f Dockerfile .
"
# Push to container registry
$SSH_CMD "
set -e
docker push ${{ env.REGISTRY }}/${{ env.IMAGE }}:${TAG}
docker push ${{ env.REGISTRY }}/${{ env.IMAGE }}:latest
"
# Update compose and restart
$SSH_CMD "
set -e
cd ${{ env.COMPOSE_DIR }}
sed -i 's|${{ env.IMAGE }}:[^ ]*|${{ env.IMAGE }}:${VERSION_TAG}|' docker-compose.yml
docker compose up -d gitea
cd ${COMPOSE_DIR}
sed -i 's|${{ env.IMAGE }}:[^ ]*|${{ env.IMAGE }}:${TAG}|' docker-compose.yml
docker compose up -d ${CONTAINER}
"
# Health check
$SSH_CMD "
for i in 1 2 3 4 5 6 7 8; do
sleep 15
if docker inspect --format='{{.State.Health.Status}}' gitea 2>/dev/null | grep -q healthy; then
echo 'Gitea is healthy!'
if docker inspect --format='{{.State.Health.Status}}' ${CONTAINER} 2>/dev/null | grep -q healthy; then
echo 'Container healthy!'
docker inspect --format='Image: {{.Config.Image}}' ${CONTAINER}
exit 0
fi
echo \"Waiting... (attempt \$i/8)\"
done
echo 'Health check failed'
docker logs gitea --tail 20
docker logs ${CONTAINER} --tail 20
exit 1
"
- name: Verify
run: |
sleep 5
curl -sf https://git.mokoconsulting.tech/api/healthz && echo " — API healthy"
curl -sf https://${{ env.DEPLOY_HOST }}/api/healthz && echo " — API healthy"
- name: Notify on failure
if: failure()
run: echo "::error::Deploy failed for ${{ steps.version.outputs.tag }}"
run: echo "::error::Deploy failed for ${{ steps.config.outputs.tag }}"
@@ -0,0 +1,9 @@
---
name: ".mokogitea Test Template"
about: "Verify .mokogitea issue templates work"
labels: ["test"]
---
This template was loaded from `.mokogitea/ISSUE_TEMPLATE/`.
If you can see this, the `.mokogitea` dot-folder feature is working.
+12
View File
@@ -0,0 +1,12 @@
# Test workflow to verify .mokogitea/ directory is discovered
name: Test .mokogitea workflows
on:
workflow_dispatch:
jobs:
test:
runs-on: ubuntu-latest
steps:
- name: Verify .mokogitea
run: echo "This workflow ran from .mokogitea/workflows/ — feature works!"
+21
View File
@@ -6,6 +6,7 @@ package activities
import (
"context"
actions_model "code.gitea.io/gitea/models/actions"
asymkey_model "code.gitea.io/gitea/models/asymkey"
"code.gitea.io/gitea/models/auth"
"code.gitea.io/gitea/models/db"
@@ -18,6 +19,7 @@ import (
user_model "code.gitea.io/gitea/models/user"
"code.gitea.io/gitea/models/webhook"
"code.gitea.io/gitea/modules/optional"
"code.gitea.io/gitea/modules/timeutil"
"code.gitea.io/gitea/modules/setting"
"code.gitea.io/gitea/modules/structs"
)
@@ -37,6 +39,11 @@ type Statistic struct {
Branches, Tags, CommitStatus int64
IssueByLabel []IssueByLabelCount
IssueByRepository []IssueByRepositoryCount
// MokoGitea extended metrics
ActiveUsers30d int64
ActionsQueueLength int64
ActionsRunningJobs int64
}
}
@@ -131,5 +138,19 @@ func GetStatistic(ctx context.Context) (stats Statistic) {
stats.Counter.Attachment, _ = e.Count(new(repo_model.Attachment))
stats.Counter.Project, _ = e.Count(new(project_model.Project))
stats.Counter.ProjectColumn, _ = e.Count(new(project_model.Column))
// MokoGitea extended metrics
// Active users in last 30 days (users who performed any action)
stats.Counter.ActiveUsers30d, _ = e.Where("last_login_unix > ?",
timeutil.TimeStampNow()-30*24*60*60).Count(new(user_model.User))
// Actions queue and running jobs (if actions enabled)
if setting.Actions.Enabled {
stats.Counter.ActionsQueueLength, _ = e.Where("status = ?", 1). // StatusWaiting
Count(new(actions_model.ActionRunJob))
stats.Counter.ActionsRunningJobs, _ = e.Where("status = ?", 2). // StatusRunning
Count(new(actions_model.ActionRunJob))
}
return stats
}
+61 -111
View File
@@ -1,129 +1,79 @@
// Copyright 2024 The Gitea Authors. All rights reserved.
// SPDX-License-Identifier: MIT
// Copyright 2026 Moko Consulting <hello@mokoconsulting.tech>
// SPDX-License-Identifier: GPL-3.0-or-later
package badge
import (
"strings"
"sync"
"unicode"
actions_model "code.gitea.io/gitea/models/actions"
"bytes"
"fmt"
"html/template"
)
// The Badge layout: |offset|label|message|
// We use 10x scale to calculate more precisely
// Then scale down to normal size in tmpl file
type Text struct {
text string
width int
x int
}
func (t Text) Text() string {
return t.text
}
func (t Text) Width() int {
return t.width
}
func (t Text) X() int {
return t.x
}
func (t Text) TextLength() int {
return int(float64(t.width-defaultOffset) * 10)
}
// Badge holds the data for rendering an SVG badge.
type Badge struct {
IDPrefix string
FontFamily string
Color string
FontSize int
Label Text
Message Text
Label string
Message string
Color string
}
func (b Badge) Width() int {
return b.Label.width + b.Message.width
}
// Style follows https://shields.io/badges
// Color presets
const (
StyleFlat = "flat"
StyleFlatSquare = "flat-square"
ColorGreen = "#4c1"
ColorYellow = "#dfb317"
ColorRed = "#e05d44"
ColorGrey = "#9f9f9f"
ColorBlue = "#007ec6"
ColorOrange = "#fe7d37"
)
const (
defaultOffset = 10
defaultFontSize = 11
DefaultColor = "#9f9f9f" // Grey
DefaultFontFamily = "DejaVu Sans,Verdana,Geneva,sans-serif"
DefaultStyle = StyleFlat
)
const charWidth = 6.8
var GlobalVars = sync.OnceValue(func() (ret struct {
StatusColorMap map[actions_model.Status]string
DejaVuGlyphWidthData map[rune]uint8
AllStyles []string
},
) {
ret.StatusColorMap = map[actions_model.Status]string{
actions_model.StatusSuccess: "#4c1", // Green
actions_model.StatusSkipped: "#dfb317", // Yellow
actions_model.StatusUnknown: "#97ca00", // Light Green
actions_model.StatusFailure: "#e05d44", // Red
actions_model.StatusCancelled: "#fe7d37", // Orange
actions_model.StatusWaiting: "#dfb317", // Yellow
actions_model.StatusRunning: "#dfb317", // Yellow
actions_model.StatusBlocked: "#dfb317", // Yellow
}
ret.DejaVuGlyphWidthData = dejaVuGlyphWidthDataFunc()
ret.AllStyles = []string{StyleFlat, StyleFlatSquare}
return ret
})
// GenerateBadge generates badge with given template
func GenerateBadge(label, message, color string) Badge {
lw := calculateTextWidth(label) + defaultOffset
mw := calculateTextWidth(message) + defaultOffset
lx := lw * 5
mx := lw*10 + mw*5 - 10
return Badge{
FontFamily: DefaultFontFamily,
Label: Text{
text: label,
width: lw,
x: lx,
},
Message: Text{
text: message,
width: mw,
x: mx,
},
FontSize: defaultFontSize * 10,
Color: color,
}
func textWidth(s string) float64 {
return float64(len(s)) * charWidth
}
func calculateTextWidth(text string) int {
width := 0
widthData := GlobalVars().DejaVuGlyphWidthData
for _, char := range strings.TrimSpace(text) {
charWidth, ok := widthData[char]
if !ok {
// use the width of 'm' in case of missing glyph width data for a printable character
if unicode.IsPrint(char) {
charWidth = widthData['m']
} else {
charWidth = 0
}
}
width += int(charWidth)
var svgTemplate = template.Must(template.New("badge").Parse(`<svg xmlns="http://www.w3.org/2000/svg" width="{{.TotalWidth}}" height="20" role="img" aria-label="{{.Label}}: {{.Message}}">
<title>{{.Label}}: {{.Message}}</title>
<linearGradient id="s" x2="0" y2="100%">
<stop offset="0" stop-color="#bbb" stop-opacity=".1"/>
<stop offset="1" stop-opacity=".1"/>
</linearGradient>
<clipPath id="r"><rect width="{{.TotalWidth}}" height="20" rx="3" fill="#fff"/></clipPath>
<g clip-path="url(#r)">
<rect width="{{.LabelWidth}}" height="20" fill="#555"/>
<rect x="{{.LabelWidth}}" width="{{.MessageWidth}}" height="20" fill="{{.Color}}"/>
<rect width="{{.TotalWidth}}" height="20" fill="url(#s)"/>
</g>
<g fill="#fff" text-anchor="middle" font-family="Verdana,Geneva,DejaVu Sans,sans-serif" text-rendering="geometricPrecision" font-size="11">
<text aria-hidden="true" x="{{.LabelX}}" y="15" fill="#010101" fill-opacity=".3">{{.Label}}</text>
<text x="{{.LabelX}}" y="14">{{.Label}}</text>
<text aria-hidden="true" x="{{.MessageX}}" y="15" fill="#010101" fill-opacity=".3">{{.Message}}</text>
<text x="{{.MessageX}}" y="14">{{.Message}}</text>
</g>
</svg>`))
type templateData struct {
Label, Message, Color string
LabelWidth, MessageWidth int
TotalWidth int
LabelX, MessageX float64
}
// Render generates an SVG badge as a byte slice.
func (b Badge) Render() ([]byte, error) {
padding := 12.0
lw := int(textWidth(b.Label) + padding)
mw := int(textWidth(b.Message) + padding)
data := templateData{
Label: b.Label, Message: b.Message, Color: b.Color,
LabelWidth: lw, MessageWidth: mw, TotalWidth: lw + mw,
LabelX: float64(lw) / 2, MessageX: float64(lw) + float64(mw)/2,
}
return width
var buf bytes.Buffer
if err := svgTemplate.Execute(&buf, data); err != nil {
return nil, fmt.Errorf("rendering badge: %w", err)
}
return buf.Bytes(), nil
}
+88
View File
@@ -0,0 +1,88 @@
// Copyright 2026 Moko Consulting <hello@mokoconsulting.tech>
// SPDX-License-Identifier: GPL-3.0-or-later
package badge
import (
"context"
"fmt"
"strings"
git_model "code.gitea.io/gitea/models/git"
repo_model "code.gitea.io/gitea/models/repo"
)
// Generate creates a badge for the given repo and badge type.
func Generate(ctx context.Context, repo *repo_model.Repository, badgeType string) (Badge, error) {
switch strings.ToLower(badgeType) {
case "version":
return versionBadge(ctx, repo)
case "build":
return buildBadge(ctx, repo)
case "license":
return licenseBadge(repo)
case "health":
return healthBadge(ctx, repo)
default:
return Badge{Label: "badge", Message: "unknown", Color: ColorGrey},
fmt.Errorf("unknown badge type: %s", badgeType)
}
}
func versionBadge(ctx context.Context, repo *repo_model.Repository) (Badge, error) {
release, err := repo_model.GetLatestReleaseByRepoID(ctx, repo.ID)
if err != nil || release == nil {
return Badge{Label: "version", Message: "none", Color: ColorGrey}, nil
}
return Badge{Label: "version", Message: release.TagName, Color: ColorBlue}, nil
}
func buildBadge(ctx context.Context, repo *repo_model.Repository) (Badge, error) {
status, err := git_model.GetLatestCommitStatus(ctx, repo.ID, repo.DefaultBranch, 1)
if err != nil || len(status) == 0 {
return Badge{Label: "build", Message: "unknown", Color: ColorGrey}, nil
}
switch status[0].State.String() {
case "success":
return Badge{Label: "build", Message: "passing", Color: ColorGreen}, nil
case "failure", "error":
return Badge{Label: "build", Message: "failing", Color: ColorRed}, nil
case "pending":
return Badge{Label: "build", Message: "pending", Color: ColorYellow}, nil
default:
return Badge{Label: "build", Message: status[0].State.String(), Color: ColorGrey}, nil
}
}
func licenseBadge(repo *repo_model.Repository) (Badge, error) {
if len(repo.License) > 0 {
return Badge{Label: "license", Message: repo.License, Color: ColorBlue}, nil
}
return Badge{Label: "license", Message: "none", Color: ColorGrey}, nil
}
func healthBadge(ctx context.Context, repo *repo_model.Repository) (Badge, error) {
score := 0
if repo.HasWiki() {
score++
}
if len(repo.License) > 0 {
score++
}
if repo.Description != "" {
score++
}
var color string
var msg string
switch {
case score >= 3:
color, msg = ColorGreen, "healthy"
case score >= 2:
color, msg = ColorYellow, "fair"
default:
color, msg = ColorRed, "needs work"
}
return Badge{Label: "health", Message: msg, Color: color}, nil
}
+40
View File
@@ -46,6 +46,11 @@ type Collector struct {
Users *prometheus.Desc
Watches *prometheus.Desc
Webhooks *prometheus.Desc
// MokoGitea extended metrics
ActiveUsers30d *prometheus.Desc
ActionsQueueLength *prometheus.Desc
ActionsRunningJobs *prometheus.Desc
}
// NewCollector returns a new Collector with all prometheus.Desc initialized
@@ -196,6 +201,21 @@ func NewCollector() Collector {
"Number of Webhooks",
nil, nil,
),
ActiveUsers30d: prometheus.NewDesc(
namespace+"active_users_30d",
"Number of active users in the last 30 days",
nil, nil,
),
ActionsQueueLength: prometheus.NewDesc(
namespace+"actions_queue_length",
"Number of actions jobs waiting to run",
nil, nil,
),
ActionsRunningJobs: prometheus.NewDesc(
namespace+"actions_running_jobs",
"Number of actions jobs currently running",
nil, nil,
),
}
}
@@ -229,6 +249,9 @@ func (c Collector) Describe(ch chan<- *prometheus.Desc) {
ch <- c.Users
ch <- c.Watches
ch <- c.Webhooks
ch <- c.ActiveUsers30d
ch <- c.ActionsQueueLength
ch <- c.ActionsRunningJobs
}
// Collect returns the metrics with values
@@ -392,4 +415,21 @@ func (c Collector) Collect(ch chan<- prometheus.Metric) {
prometheus.GaugeValue,
float64(stats.Counter.Webhook),
)
// MokoGitea extended metrics
ch <- prometheus.MustNewConstMetric(
c.ActiveUsers30d,
prometheus.GaugeValue,
float64(stats.Counter.ActiveUsers30d),
)
ch <- prometheus.MustNewConstMetric(
c.ActionsQueueLength,
prometheus.GaugeValue,
float64(stats.Counter.ActionsQueueLength),
)
ch <- prometheus.MustNewConstMetric(
c.ActionsRunningJobs,
prometheus.GaugeValue,
float64(stats.Counter.ActionsRunningJobs),
)
}
+24
View File
@@ -0,0 +1,24 @@
// Copyright 2026 Moko Consulting <hello@mokoconsulting.tech>
// SPDX-License-Identifier: GPL-3.0-or-later
package setting
// Ntfy holds ntfy push notification settings.
var Ntfy = struct {
Enabled bool
ServerURL string
DefaultTopic string
Token string
}{
Enabled: false,
ServerURL: "https://ntfy.mokoconsulting.tech",
DefaultTopic: "mokogitea",
}
func loadNtfyFrom(cfg ConfigProvider) {
sec := cfg.Section("ntfy")
Ntfy.Enabled = sec.Key("ENABLED").MustBool(false)
Ntfy.ServerURL = sec.Key("SERVER_URL").MustString(Ntfy.ServerURL)
Ntfy.DefaultTopic = sec.Key("DEFAULT_TOPIC").MustString(Ntfy.DefaultTopic)
Ntfy.Token = sec.Key("TOKEN").String()
}
+17
View File
@@ -28,6 +28,15 @@ var (
CfgProvider ConfigProvider
IsWindows bool
// UpdateChecker configuration for MokoGitea version checking
UpdateChecker = struct {
Enabled bool
Endpoint string
}{
Enabled: true,
Endpoint: "https://git.mokoconsulting.tech/api/v1/repos/MokoConsulting/MokoGitea/releases/latest",
}
// IsInTesting indicates whether the testing is running (unit test or integration test). It can be used for:
// * Skip nonsense error logs during testing caused by unreliable code (TODO: this is only a temporary solution, we should make the test code more reliable)
// * Panic in dev or testing mode to make the problem more obvious and easier to debug
@@ -158,9 +167,17 @@ func loadCommonSettingsFrom(cfg ConfigProvider) error {
loadMarkupFrom(cfg)
loadGlobalLockFrom(cfg)
loadOtherFrom(cfg)
loadUpdateCheckerFrom(cfg)
loadNtfyFrom(cfg)
return nil
}
func loadUpdateCheckerFrom(cfg ConfigProvider) {
sec := cfg.Section("update_checker")
UpdateChecker.Enabled = sec.Key("ENABLED").MustBool(true)
UpdateChecker.Endpoint = sec.Key("ENDPOINT").MustString(UpdateChecker.Endpoint)
}
func loadRunModeFrom(rootCfg ConfigProvider) {
rootSec := rootCfg.Section("")
RunUser = rootSec.Key("RUN_USER").MustString(user.CurrentUsername())
+106
View File
@@ -0,0 +1,106 @@
// Copyright 2026 Moko Consulting <hello@mokoconsulting.tech>
// SPDX-License-Identifier: GPL-3.0-or-later
package updatechecker
import (
"encoding/json"
"fmt"
"io"
"net/http"
"strings"
"sync"
"time"
"code.gitea.io/gitea/modules/log"
"code.gitea.io/gitea/modules/setting"
)
// UpdateInfo holds the result of the latest update check.
type UpdateInfo struct {
UpdateAvailable bool
LatestVersion string
ReleaseURL string
CheckedAt time.Time
}
var (
cachedInfo *UpdateInfo
mu sync.RWMutex
)
// giteaRelease is the subset of Gitea's release API response we need.
type giteaRelease struct {
TagName string `json:"tag_name"`
HTMLURL string `json:"html_url"`
Draft bool `json:"draft"`
}
// CheckForUpdate fetches the latest release from the configured endpoint
// and compares it to the running version.
func CheckForUpdate() error {
if !setting.UpdateChecker.Enabled || setting.UpdateChecker.Endpoint == "" {
return nil
}
client := &http.Client{Timeout: 15 * time.Second}
resp, err := client.Get(setting.UpdateChecker.Endpoint)
if err != nil {
return fmt.Errorf("update check failed: %w", err)
}
defer resp.Body.Close()
if resp.StatusCode != http.StatusOK {
return fmt.Errorf("update check returned status %d", resp.StatusCode)
}
body, err := io.ReadAll(resp.Body)
if err != nil {
return fmt.Errorf("reading update response: %w", err)
}
var release giteaRelease
if err := json.Unmarshal(body, &release); err != nil {
return fmt.Errorf("parsing update response: %w", err)
}
if release.Draft || release.TagName == "" {
return nil
}
latestVersion := strings.TrimPrefix(release.TagName, "v")
currentVersion := setting.AppVer
info := &UpdateInfo{
LatestVersion: latestVersion,
ReleaseURL: release.HTMLURL,
CheckedAt: time.Now(),
}
// Simple comparison: if latest != current, update is available.
// This handles both upgrades and the case where versions differ
// in any way (patch, upstream bump, etc.)
info.UpdateAvailable = latestVersion != "" && !strings.HasPrefix(currentVersion, latestVersion)
mu.Lock()
cachedInfo = info
mu.Unlock()
if info.UpdateAvailable {
log.Info("MokoGitea update available: %s (current: %s)", latestVersion, currentVersion)
} else {
log.Debug("MokoGitea is up to date: %s", currentVersion)
}
return nil
}
// GetUpdateInfo returns the cached update check result.
func GetUpdateInfo() *UpdateInfo {
mu.RLock()
defer mu.RUnlock()
if cachedInfo == nil {
return &UpdateInfo{}
}
return cachedInfo
}
+2
View File
@@ -617,6 +617,7 @@
"__github/workflows__": "folder-gh-workflows",
"gitea/workflows": "folder-gitea-workflows",
".gitea/workflows": "folder-gitea-workflows",
".mokogitea/workflows": "folder-gitea-workflows",
"_gitea/workflows": "folder-gitea-workflows",
"-gitea/workflows": "folder-gitea-workflows",
"__gitea/workflows__": "folder-gitea-workflows",
@@ -5237,6 +5238,7 @@
"__github/workflows__": "folder-gh-workflows-open",
"gitea/workflows": "folder-gitea-workflows-open",
".gitea/workflows": "folder-gitea-workflows-open",
".mokogitea/workflows": "folder-gitea-workflows-open",
"_gitea/workflows": "folder-gitea-workflows-open",
"-gitea/workflows": "folder-gitea-workflows-open",
"__gitea/workflows__": "folder-gitea-workflows-open",
+3 -1
View File
@@ -1430,7 +1430,9 @@ func Routes() *web.Router {
Delete(reqToken(), repo.DeleteTopic)
}, reqAdmin())
}, reqAnyRepoReader())
m.Get("/issue_templates", context.ReferencesGitRepo(), repo.GetIssueTemplates)
// MokoGitea badge engine
m.Get("/badge/{type}.svg", repo.GetRepoBadge)
m.Get("/issue_templates", context.ReferencesGitRepo(), repo.GetIssueTemplates)
m.Get("/issue_config", context.ReferencesGitRepo(), repo.GetIssueConfig)
m.Get("/issue_config/validate", context.ReferencesGitRepo(), repo.ValidateIssueConfig)
m.Get("/languages", reqRepoReader(unit.TypeCode), repo.GetLanguages)
+34
View File
@@ -0,0 +1,34 @@
// Copyright 2026 Moko Consulting <hello@mokoconsulting.tech>
// SPDX-License-Identifier: GPL-3.0-or-later
package repo
import (
"fmt"
"net/http"
"code.gitea.io/gitea/modules/badge"
"code.gitea.io/gitea/services/context"
)
// GetRepoBadge returns an SVG badge for the repository.
func GetRepoBadge(ctx *context.APIContext) {
badgeType := ctx.PathParam("type")
b, err := badge.Generate(ctx, ctx.Repo.Repository, badgeType)
if err != nil {
b = badge.Badge{Label: "badge", Message: "error", Color: badge.ColorGrey}
}
svg, err := b.Render()
if err != nil {
ctx.APIErrorInternal(fmt.Errorf("rendering badge: %w", err))
return
}
ctx.Resp.Header().Set("Content-Type", "image/svg+xml")
ctx.Resp.Header().Set("Cache-Control", "public, max-age=300")
ctx.Resp.Header().Set("ETag", fmt.Sprintf(`"%s-%s"`, b.Label, b.Message))
ctx.Resp.WriteHeader(http.StatusOK)
_, _ = ctx.Resp.Write(svg)
}
+8 -2
View File
@@ -21,6 +21,7 @@ import (
"code.gitea.io/gitea/modules/json"
"code.gitea.io/gitea/modules/log"
"code.gitea.io/gitea/modules/setting"
"code.gitea.io/gitea/modules/updatechecker"
"code.gitea.io/gitea/modules/templates"
"code.gitea.io/gitea/modules/web"
"code.gitea.io/gitea/services/context"
@@ -135,8 +136,13 @@ func prepareStartupProblemsAlert(ctx *context.Context) {
func Dashboard(ctx *context.Context) {
ctx.Data["Title"] = ctx.Tr("admin.dashboard")
ctx.Data["PageIsAdminDashboard"] = true
// MokoGitea: upstream update checker removed — this is an independent fork
ctx.Data["NeedUpdate"] = false
// MokoGitea update checker
info := updatechecker.GetUpdateInfo()
ctx.Data["NeedUpdate"] = info.UpdateAvailable
ctx.Data["LatestVersion"] = info.LatestVersion
ctx.Data["ReleaseURL"] = info.ReleaseURL
updateSystemStatus()
ctx.Data["SysStatus"] = sysStatus
ctx.Data["SSH"] = setting.SSH
+6
View File
@@ -58,6 +58,12 @@ var IssueTemplateCandidates = []string{
"issue_template.md",
"issue_template.yaml",
"issue_template.yml",
".mokogitea/ISSUE_TEMPLATE.md",
".mokogitea/ISSUE_TEMPLATE.yaml",
".mokogitea/ISSUE_TEMPLATE.yml",
".mokogitea/issue_template.md",
".mokogitea/issue_template.yaml",
".mokogitea/issue_template.yml",
".gitea/ISSUE_TEMPLATE.md",
".gitea/ISSUE_TEMPLATE.yaml",
".gitea/ISSUE_TEMPLATE.yml",
+6
View File
@@ -71,6 +71,12 @@ var pullRequestTemplateCandidates = []string{
"pull_request_template.md",
"pull_request_template.yaml",
"pull_request_template.yml",
".mokogitea/PULL_REQUEST_TEMPLATE.md",
".mokogitea/PULL_REQUEST_TEMPLATE.yaml",
".mokogitea/PULL_REQUEST_TEMPLATE.yml",
".mokogitea/pull_request_template.md",
".mokogitea/pull_request_template.yaml",
".mokogitea/pull_request_template.yml",
".gitea/PULL_REQUEST_TEMPLATE.md",
".gitea/PULL_REQUEST_TEMPLATE.yaml",
".gitea/PULL_REQUEST_TEMPLATE.yml",
+14
View File
@@ -13,6 +13,7 @@ import (
"code.gitea.io/gitea/models/webhook"
"code.gitea.io/gitea/modules/git/gitcmd"
"code.gitea.io/gitea/modules/setting"
"code.gitea.io/gitea/modules/updatechecker"
"code.gitea.io/gitea/services/auth"
"code.gitea.io/gitea/services/migrations"
mirror_service "code.gitea.io/gitea/services/mirror"
@@ -183,4 +184,17 @@ func initBasicTasks() {
registerCleanupPackages()
}
registerSyncRepoLicenses()
if setting.UpdateChecker.Enabled {
registerUpdateChecker()
}
}
func registerUpdateChecker() {
RegisterTaskFatal("update_checker", &BaseConfig{
Enabled: true,
RunAtStart: true,
Schedule: "@every 24h",
}, func(ctx context.Context, _ *user_model.User, _ Config) error {
return updatechecker.CheckForUpdate()
})
}
+4
View File
@@ -23,6 +23,8 @@ import (
var templateDirCandidates = []string{
"ISSUE_TEMPLATE",
"issue_template",
".mokogitea/ISSUE_TEMPLATE",
".mokogitea/issue_template",
".gitea/ISSUE_TEMPLATE",
".gitea/issue_template",
".github/ISSUE_TEMPLATE",
@@ -32,6 +34,8 @@ var templateDirCandidates = []string{
}
var templateConfigCandidates = []string{
".mokogitea/ISSUE_TEMPLATE/config",
".mokogitea/issue_template/config",
".gitea/ISSUE_TEMPLATE/config",
".gitea/issue_template/config",
".github/ISSUE_TEMPLATE/config",
+107
View File
@@ -0,0 +1,107 @@
// Copyright 2026 Moko Consulting <hello@mokoconsulting.tech>
// SPDX-License-Identifier: GPL-3.0-or-later
package ntfy
import (
"context"
"fmt"
actions_model "code.gitea.io/gitea/models/actions"
issues_model "code.gitea.io/gitea/models/issues"
repo_model "code.gitea.io/gitea/models/repo"
user_model "code.gitea.io/gitea/models/user"
"code.gitea.io/gitea/modules/setting"
notify_service "code.gitea.io/gitea/services/notify"
)
func init() {
if setting.Ntfy.Enabled {
notify_service.RegisterNotifier(NewNotifier())
}
}
type ntfyNotifier struct {
notify_service.NullNotifier
}
// NewNotifier creates a new ntfy notifier.
func NewNotifier() notify_service.Notifier {
return &ntfyNotifier{}
}
func (*ntfyNotifier) Run() {}
func repoTopic(repo *repo_model.Repository) string {
if repo == nil {
return setting.Ntfy.DefaultTopic
}
return setting.Ntfy.DefaultTopic
}
func (*ntfyNotifier) NewIssue(_ context.Context, issue *issues_model.Issue, _ []*user_model.User) {
_ = issue.LoadRepo(context.Background())
SendAsync(repoTopic(issue.Repo),
fmt.Sprintf("New Issue: %s", issue.Title),
fmt.Sprintf("#%d in %s\n%s", issue.Index, issue.Repo.FullName(), issue.Content),
"default",
"issue,new")
}
func (*ntfyNotifier) IssueChangeStatus(_ context.Context, doer *user_model.User, _ string, issue *issues_model.Issue, _ *issues_model.Comment, closeOrReopen bool) {
_ = issue.LoadRepo(context.Background())
action := "reopened"
if !closeOrReopen {
action = "closed"
}
SendAsync(repoTopic(issue.Repo),
fmt.Sprintf("Issue %s: %s", action, issue.Title),
fmt.Sprintf("#%d %s by %s", issue.Index, action, doer.Name),
"low",
"issue,"+action)
}
func (*ntfyNotifier) NewPullRequest(_ context.Context, pr *issues_model.PullRequest, _ []*user_model.User) {
_ = pr.LoadIssue(context.Background())
_ = pr.Issue.LoadRepo(context.Background())
SendAsync(repoTopic(pr.Issue.Repo),
fmt.Sprintf("New PR: %s", pr.Issue.Title),
fmt.Sprintf("#%d in %s\n%s → %s", pr.Issue.Index, pr.Issue.Repo.FullName(), pr.HeadBranch, pr.BaseBranch),
"default",
"git-pull-request,new")
}
func (*ntfyNotifier) MergePullRequest(_ context.Context, doer *user_model.User, pr *issues_model.PullRequest) {
_ = pr.LoadIssue(context.Background())
_ = pr.Issue.LoadRepo(context.Background())
SendAsync(repoTopic(pr.Issue.Repo),
fmt.Sprintf("PR Merged: %s", pr.Issue.Title),
fmt.Sprintf("#%d merged by %s", pr.Issue.Index, doer.Name),
"default",
"git-merge,merged")
}
func (*ntfyNotifier) NewRelease(_ context.Context, rel *repo_model.Release) {
SendAsync(repoTopic(rel.Repo),
fmt.Sprintf("New Release: %s", rel.TagName),
fmt.Sprintf("%s in %s\n%s", rel.TagName, rel.Repo.FullName(), rel.Note),
"high",
"rocket,release")
}
func (*ntfyNotifier) WorkflowRunStatusUpdate(_ context.Context, repo *repo_model.Repository, _ *user_model.User, run *actions_model.ActionRun) {
if run.Status.String() != "success" && run.Status.String() != "failure" {
return // only notify on completion
}
priority := "default"
tags := "white_check_mark,ci"
if run.Status.String() == "failure" {
priority = "high"
tags = "x,ci-fail"
}
SendAsync(repoTopic(repo),
fmt.Sprintf("CI %s: %s", run.Status.String(), run.Title),
fmt.Sprintf("Workflow in %s", repo.FullName()),
priority,
tags)
}
+66
View File
@@ -0,0 +1,66 @@
// Copyright 2026 Moko Consulting <hello@mokoconsulting.tech>
// SPDX-License-Identifier: GPL-3.0-or-later
package ntfy
import (
"fmt"
"net/http"
"strings"
"time"
"code.gitea.io/gitea/modules/log"
"code.gitea.io/gitea/modules/setting"
)
// Send publishes a notification to the ntfy server.
func Send(topic, title, message, priority, tags string) error {
if !setting.Ntfy.Enabled || setting.Ntfy.ServerURL == "" {
return nil
}
if topic == "" {
topic = setting.Ntfy.DefaultTopic
}
url := fmt.Sprintf("%s/%s", strings.TrimRight(setting.Ntfy.ServerURL, "/"), topic)
req, err := http.NewRequest("POST", url, strings.NewReader(message))
if err != nil {
return fmt.Errorf("ntfy request: %w", err)
}
req.Header.Set("Title", title)
if priority != "" {
req.Header.Set("Priority", priority)
}
if tags != "" {
req.Header.Set("Tags", tags)
}
if setting.Ntfy.Token != "" {
req.Header.Set("Authorization", "Bearer "+setting.Ntfy.Token)
}
client := &http.Client{Timeout: 5 * time.Second}
resp, err := client.Do(req)
if err != nil {
return fmt.Errorf("ntfy send: %w", err)
}
defer resp.Body.Close()
if resp.StatusCode >= 400 {
return fmt.Errorf("ntfy returned status %d", resp.StatusCode)
}
log.Debug("ntfy notification sent: %s — %s", topic, title)
return nil
}
// SendAsync sends a notification in a goroutine (non-blocking).
func SendAsync(topic, title, message, priority, tags string) {
go func() {
if err := Send(topic, title, message, priority, tags); err != nil {
log.Error("ntfy async send failed: %v", err)
}
}()
}
+7
View File
@@ -1,5 +1,12 @@
{{template "admin/layout_head" (dict "pageClass" "admin dashboard")}}
<div class="admin-setting-content">
{{if .NeedUpdate}}
<div class="ui positive message">
<div class="header">{{svg "octicon-info"}} MokoGitea Update Available</div>
<p>A new version <strong>{{.LatestVersion}}</strong> is available.
{{if .ReleaseURL}}<a href="{{.ReleaseURL}}" target="_blank" rel="noopener noreferrer">View release notes</a>{{end}}</p>
</div>
{{end}}
<h4 class="ui top attached header">
{{ctx.Locale.Tr "admin.dashboard.maintenance_operations"}}
</h4>
+1 -1
View File
@@ -2,7 +2,7 @@
<div class="navbar-left">
<!-- the logo -->
<a class="item" id="navbar-logo" href="{{AppSubUrl}}/" aria-label="{{if .IsSigned}}{{ctx.Locale.Tr "dashboard"}}{{else}}{{ctx.Locale.Tr "home_title"}}{{end}}">
<img width="30" height="30" src="{{AssetUrlPrefix}}/img/logo.svg" alt="{{ctx.Locale.Tr "logo"}}" aria-hidden="true">
<img width="30" height="30" src="https://mokoconsulting.tech/images/branding/logo.png" alt="{{ctx.Locale.Tr "logo"}}" aria-hidden="true">
</a>
<!-- mobile right menu, it must be here because in mobile view, each item is a flex column, the first item is a full row column -->
+1 -1
View File
@@ -39,7 +39,7 @@
{{else}}
<meta property="og:title" content="{{AppName}}">
<meta property="og:type" content="website">
<meta property="og:image" content="{{AssetUrlPrefix}}/img/logo.png">
<meta property="og:image" content="https://mokoconsulting.tech/images/branding/logo.png">
<meta property="og:url" content="{{ctx.AppFullLink}}">
<meta property="og:description" content="{{MetaDescription}}">
{{end}}
+1 -1
View File
@@ -21,7 +21,7 @@
<div class="ui container tw-flex">
<div class="item tw-flex-1">
<a href="{{AppSubUrl}}/" aria-label="{{ctx.Locale.Tr "home_title"}}">
<img width="30" height="30" src="{{AssetUrlPrefix}}/img/logo.svg" alt="{{ctx.Locale.Tr "logo"}}" aria-hidden="true">
<img width="30" height="30" src="https://mokoconsulting.tech/images/branding/logo.png" alt="{{ctx.Locale.Tr "logo"}}" aria-hidden="true">
</a>
</div>
<div class="item">
+1 -1
View File
@@ -3,7 +3,7 @@
<div class="ui middle very relaxed page grid">
<div class="column tw-flex tw-flex-col tw-gap-4 tw-max-w-2xl tw-m-auto">
<a href="{{AppSubUrl}}/user/login" class="tw-mx-auto">
<img width="100" height="100" src="{{AssetUrlPrefix}}/img/logo.svg" alt="{{ctx.Locale.Tr "logo"}}">
<img width="100" height="100" src="https://mokoconsulting.tech/images/branding/logo.png" alt="{{ctx.Locale.Tr "logo"}}">
</a>
<div class="ui container fluid">