Compare commits
1 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 4dc8ca7223 |
+1
-1
@@ -1 +1 @@
|
||||
custom: ["https://mokoconsulting.tech/enterprise"]
|
||||
open_collective: gitea
|
||||
|
||||
@@ -1,17 +1,17 @@
|
||||
blank_issues_enabled: true
|
||||
blank_issues_enabled: false
|
||||
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: 📚 MokoCLI Documentation
|
||||
url: https://git.mokoconsulting.tech/MokoConsulting/mokocli
|
||||
about: View our coding standards and best practices
|
||||
- name: 🔒 Report a Security Vulnerability
|
||||
url: https://git.mokoconsulting.tech/MokoConsulting/.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
|
||||
- name: Security Concern
|
||||
url: https://tinyurl.com/security-gitea
|
||||
about: For security concerns, please send a mail to security@gitea.io instead of opening a public issue.
|
||||
- name: Discord Server
|
||||
url: https://discord.gg/Gitea
|
||||
about: Please ask questions and discuss configuration or deployment problems here.
|
||||
- name: Discourse Forum
|
||||
url: https://forum.gitea.com
|
||||
about: Questions and configuration or deployment problems can also be discussed on our forum.
|
||||
- name: Frequently Asked Questions
|
||||
url: https://docs.gitea.com/help/faq
|
||||
about: Please check if your question isn't mentioned here.
|
||||
- name: Crowdin Translations
|
||||
url: https://translate.gitea.com
|
||||
about: Translations are managed here.
|
||||
|
||||
@@ -2,8 +2,8 @@
|
||||
Please check the following:
|
||||
1. Make sure you are targeting the `main` branch, pull requests on release branches are only allowed for backports.
|
||||
2. Use a Conventional Commits PR title, for example `fix(repo): handle empty branch names`.
|
||||
3. Make sure you have read contributing guidelines: https://git.mokoconsulting.tech/MokoConsulting/MokoGIT/src/branch/main/CONTRIBUTING.md .
|
||||
4. For documentation contributions, please open a PR against this repository.
|
||||
3. Make sure you have read contributing guidelines: https://github.com/go-gitea/gitea/blob/main/CONTRIBUTING.md .
|
||||
4. For documentations contribution, please go to https://gitea.com/gitea/docs
|
||||
5. Describe what your pull request does and which issue you're targeting (if any).
|
||||
6. It is recommended to enable "Allow edits by maintainers", so maintainers can help more easily.
|
||||
7. Your input here will be included in the commit message when this PR has been merged. If you don't want some content to be included, please separate them with a line like `---`.
|
||||
|
||||
@@ -7,11 +7,11 @@ contact_links:
|
||||
- name: 💬 Ask a Question
|
||||
url: https://mokoconsulting.tech/
|
||||
about: Get help or ask questions through our website
|
||||
- name: 📚 MokoCLI Documentation
|
||||
url: https://git.mokoconsulting.tech/MokoConsulting/mokocli
|
||||
- name: 📚 MokoStandards Documentation
|
||||
url: https://code.mokoconsulting.tech/MokoConsulting/mokoplatform
|
||||
about: View our coding standards and best practices
|
||||
- name: 🔒 Report a Security Vulnerability
|
||||
url: https://git.mokoconsulting.tech/MokoConsulting/.github-private/security/advisories/new
|
||||
url: https://code.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
|
||||
|
||||
@@ -42,7 +42,7 @@ Suggested text here
|
||||
<!-- Add any other context, screenshots, or references -->
|
||||
|
||||
## Standards Alignment
|
||||
- [ ] Follows MokoCLI documentation guidelines
|
||||
- [ ] Follows MokoStandards documentation guidelines
|
||||
- [ ] Uses en_US/en_GB localization
|
||||
- [ ] Includes proper SPDX headers where applicable
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
---
|
||||
name: Feature Request
|
||||
about: Suggest a new feature or enhancement
|
||||
title: '[FEATURE] '
|
||||
title: '(feat) '
|
||||
labels: 'enhancement'
|
||||
assignees: ''
|
||||
|
||||
@@ -37,7 +37,7 @@ If you have ideas about how this could be implemented, share them here:
|
||||
Add any other context, mockups, or screenshots about the feature request here.
|
||||
|
||||
## Relevant Standards
|
||||
Does this relate to any standards in [MokoCLI](https://git.mokoconsulting.tech/MokoConsulting/mokocli)?
|
||||
Does this relate to any standards in [MokoStandards](https://code.mokoconsulting.tech/MokoConsulting/MokoStandards)?
|
||||
- [ ] Accessibility (WCAG 2.1 AA)
|
||||
- [ ] Localization (en_US/en_GB)
|
||||
- [ ] Security best practices
|
||||
|
||||
@@ -35,7 +35,7 @@ Use this template only for:
|
||||
<!-- Describe how this could be addressed -->
|
||||
|
||||
## Standards Reference
|
||||
Does this relate to security standards in [MokoCLI](https://git.mokoconsulting.tech/MokoConsulting/mokocli)?
|
||||
Does this relate to security standards in [MokoStandards](https://code.mokoconsulting.tech/MokoConsulting/MokoStandards)?
|
||||
- [ ] SPDX license identifiers
|
||||
- [ ] Secret management
|
||||
- [ ] Dependency security
|
||||
|
||||
@@ -0,0 +1,9 @@
|
||||
---
|
||||
name: ".mokogit Test Template"
|
||||
about: "Verify .mokogit issue templates work"
|
||||
labels: ["test"]
|
||||
---
|
||||
|
||||
This template was loaded from `.mokogit/ISSUE_TEMPLATE/`.
|
||||
|
||||
If you can see this, the `.mokogit` dot-folder feature is working.
|
||||
@@ -42,8 +42,8 @@ on:
|
||||
default: ''
|
||||
|
||||
env:
|
||||
MOKOGIT_URL: https://code.mokoconsulting.tech
|
||||
MOKOGIT_ORG: MokoConsulting
|
||||
GITEA_URL: https://code.mokoconsulting.tech
|
||||
GITEA_ORG: MokoConsulting
|
||||
|
||||
permissions:
|
||||
contents: read
|
||||
@@ -57,9 +57,9 @@ jobs:
|
||||
- name: Determine target repos
|
||||
id: repos
|
||||
env:
|
||||
MOKOGIT_TOKEN: ${{ secrets.MOKOGIT_TOKEN }}
|
||||
MOKOGITEA_TOKEN: ${{ secrets.MOKOGITEA_TOKEN }}
|
||||
run: |
|
||||
API="${MOKOGIT_URL}/api/v1"
|
||||
API="${GITEA_URL}/api/v1"
|
||||
|
||||
# Platform/standards/infra repos to exclude
|
||||
EXCLUDE="gitea-org-config org-profile gitea-private .mokogit-private MokoStandards mokoplatform MokoTesting"
|
||||
@@ -74,8 +74,8 @@ jobs:
|
||||
REPOS=""
|
||||
while true; do
|
||||
BATCH=$(curl -sS \
|
||||
-H "Authorization: token ${MOKOGIT_TOKEN}" \
|
||||
"${API}/orgs/${MOKOGIT_ORG}/repos?page=${PAGE}&limit=50" \
|
||||
-H "Authorization: token ${MOKOGITEA_TOKEN}" \
|
||||
"${API}/orgs/${GITEA_ORG}/repos?page=${PAGE}&limit=50" \
|
||||
| jq -r '.[].name // empty')
|
||||
[ -z "$BATCH" ] && break
|
||||
REPOS="$REPOS $BATCH"
|
||||
@@ -105,10 +105,10 @@ jobs:
|
||||
|
||||
- name: Apply protection rules
|
||||
env:
|
||||
MOKOGIT_TOKEN: ${{ secrets.MOKOGIT_TOKEN }}
|
||||
MOKOGITEA_TOKEN: ${{ secrets.MOKOGITEA_TOKEN }}
|
||||
DRY_RUN: ${{ inputs.dry_run || 'false' }}
|
||||
run: |
|
||||
API="${MOKOGIT_URL}/api/v1"
|
||||
API="${GITEA_URL}/api/v1"
|
||||
REPOS="${{ steps.repos.outputs.repos }}"
|
||||
|
||||
SUCCESS=0
|
||||
@@ -214,16 +214,16 @@ jobs:
|
||||
ENCODED_NAME=$(echo "$NAME" | sed 's|/|%2F|g')
|
||||
curl -sS -o /dev/null -w "" \
|
||||
-X DELETE \
|
||||
-H "Authorization: token ${MOKOGIT_TOKEN}" \
|
||||
"${API}/repos/${MOKOGIT_ORG}/${REPO}/branch_protections/${ENCODED_NAME}" 2>/dev/null || true
|
||||
-H "Authorization: token ${MOKOGITEA_TOKEN}" \
|
||||
"${API}/repos/${GITEA_ORG}/${REPO}/branch_protections/${ENCODED_NAME}" 2>/dev/null || true
|
||||
|
||||
# Create rule
|
||||
RESPONSE=$(curl -sS -w "\n%{http_code}" \
|
||||
-X POST \
|
||||
-H "Authorization: token ${MOKOGIT_TOKEN}" \
|
||||
-H "Authorization: token ${MOKOGITEA_TOKEN}" \
|
||||
-H "Content-Type: application/json" \
|
||||
-d "$RULE" \
|
||||
"${API}/repos/${MOKOGIT_ORG}/${REPO}/branch_protections")
|
||||
"${API}/repos/${GITEA_ORG}/${REPO}/branch_protections")
|
||||
|
||||
HTTP=$(echo "$RESPONSE" | tail -1)
|
||||
BODY=$(echo "$RESPONSE" | sed '$d')
|
||||
|
||||
@@ -4,8 +4,8 @@
|
||||
#
|
||||
# FILE INFORMATION
|
||||
# DEFGROUP: MokoGIT.Workflow
|
||||
# INGROUP: MokoCLI.Release
|
||||
# REPO: https://git.mokoconsulting.tech/MokoConsulting/Template-Generic
|
||||
# INGROUP: mokocli.Release
|
||||
# REPO: https://git.mokoconsulting.tech/MokoConsulting/mokocli
|
||||
# PATH: /.mokogit/workflows/auto-bump.yml
|
||||
# VERSION: 09.02.00
|
||||
# BRIEF: Auto patch-bump version on every push to dev (skips merge commits)
|
||||
@@ -34,8 +34,7 @@ jobs:
|
||||
if: >-
|
||||
!contains(github.event.head_commit.message, '[skip ci]') &&
|
||||
!contains(github.event.head_commit.message, '[skip bump]') &&
|
||||
!startsWith(github.event.head_commit.message, 'Merge pull request') &&
|
||||
!startsWith(github.event.repository.name, 'Template-')
|
||||
!startsWith(github.event.head_commit.message, 'Merge pull request')
|
||||
|
||||
steps:
|
||||
- name: Checkout
|
||||
@@ -44,7 +43,7 @@ jobs:
|
||||
token: ${{ secrets.MOKOGIT_TOKEN }}
|
||||
fetch-depth: 1
|
||||
|
||||
- name: Setup MokoCLI tools
|
||||
- name: Setup mokocli tools
|
||||
run: |
|
||||
if ! command -v composer &> /dev/null; then
|
||||
sudo apt-get update -qq && sudo apt-get install -y -qq php-cli php-mbstring php-xml php-zip php-curl composer >/dev/null 2>&1
|
||||
|
||||
@@ -4,17 +4,17 @@
|
||||
#
|
||||
# FILE INFORMATION
|
||||
# DEFGROUP: MokoGIT.Workflow
|
||||
# INGROUP: MokoCLI.Release
|
||||
# REPO: https://git.mokoconsulting.tech/MokoConsulting/Template-Generic
|
||||
# PATH: /.mokogit/workflows/auto-release.yml
|
||||
# VERSION: 05.01.02
|
||||
# BRIEF: Universal build & release � detects platform from metadata API
|
||||
# INGROUP: mokocli.Release
|
||||
# REPO: https://git.mokoconsulting.tech/mokoconsulting-tech/mokocli
|
||||
# PATH: /templates/workflows/universal/auto-release.yml.template
|
||||
# VERSION: 05.00.00
|
||||
# BRIEF: Universal build & release � detects platform from manifest.xml
|
||||
#
|
||||
# +=======================================================================+
|
||||
# | UNIVERSAL BUILD & RELEASE PIPELINE |
|
||||
# +=======================================================================+
|
||||
# | |
|
||||
# | Reads metadata API (joomla|dolibarr|generic) to branch logic. |
|
||||
# | Reads manifest.xml (joomla|dolibarr|generic) to branch logic. |
|
||||
# | |
|
||||
# | Platform-specific: |
|
||||
# | joomla: XML manifest, type-prefixed packages |
|
||||
@@ -64,14 +64,10 @@ jobs:
|
||||
promote-rc:
|
||||
name: Promote to RC
|
||||
runs-on: release
|
||||
# Skip on template repos (Template-*) — they scaffold other repos and do not release.
|
||||
if: >-
|
||||
!startsWith(github.event.repository.name, 'Template-') &&
|
||||
(
|
||||
(github.event.action == 'opened' && github.event.pull_request.merged != true) ||
|
||||
(github.event.action == 'synchronize' && github.event.pull_request.merged != true) ||
|
||||
(github.event_name == 'workflow_dispatch' && inputs.action == 'promote-rc')
|
||||
)
|
||||
(github.event.action == 'opened' && github.event.pull_request.merged != true) ||
|
||||
(github.event.action == 'synchronize' && github.event.pull_request.merged != true) ||
|
||||
(github.event_name == 'workflow_dispatch' && inputs.action == 'promote-rc')
|
||||
|
||||
steps:
|
||||
- name: Checkout repository
|
||||
@@ -79,9 +75,8 @@ jobs:
|
||||
with:
|
||||
token: ${{ secrets.MOKOGIT_TOKEN }}
|
||||
fetch-depth: 1
|
||||
submodules: recursive
|
||||
|
||||
- name: Setup MokoCLI tools
|
||||
- name: Setup mokocli tools
|
||||
env:
|
||||
MOKO_CLONE_TOKEN: ${{ secrets.MOKOGIT_TOKEN }}
|
||||
MOKO_CLONE_HOST: git.mokoconsulting.tech/MokoConsulting
|
||||
@@ -144,7 +139,7 @@ jobs:
|
||||
- name: Trigger RC deploy
|
||||
run: |
|
||||
# Workflow-token pushes do NOT wake downstream workflows; dispatch deploy-rc explicitly.
|
||||
curl -sf -X POST -H "Authorization: token ${{ secrets.MOKOGIT_TOKEN }}" \n -H "Content-Type: application/json" \n "${MOKOGIT_URL}/api/v1/repos/${GIT_ORG}/${GIT_REPO}/actions/workflows/deploy-rc.yml/dispatches" \n -d '{"ref":"rc"}' \n && echo "Dispatched deploy-rc on rc" \n || echo "::warning::deploy-rc dispatch failed (no deploy-rc.yml on rc? non-go platform)"
|
||||
curl -sf -X POST -H "Authorization: token ${{ secrets.MOKOGIT_TOKEN }}" \n -H "Content-Type: application/json" \n "${MOKOGIT_URL}/api/v1/repos/${GIT_ORG}/${GIT_REPO}/actions/workflows/deploy-rc.yml/dispatches" \n -d '{"ref":"rc"}' \n && echo "Dispatched deploy-rc on rc" \n || echo "::warning::deploy-rc dispatch failed (no deploy-rc.yml on rc?)"
|
||||
|
||||
- name: Checkout rc and configure git
|
||||
run: |
|
||||
@@ -167,13 +162,10 @@ jobs:
|
||||
API_BASE="${MOKOGIT_URL}/api/v1/repos/${GIT_ORG}/${GIT_REPO}"
|
||||
TOKEN="${{ secrets.MOKOGIT_TOKEN }}"
|
||||
|
||||
# Extract [Unreleased] section via the shared mokocli command (#364 centralization).
|
||||
# Extract [Unreleased] section from changelog
|
||||
NOTES=""
|
||||
if [ -f "CHANGELOG.md" ]; then
|
||||
NOTES=$(php ${MOKO_CLI}/release_notes.php --path . --version Unreleased 2>/dev/null || true)
|
||||
# release_notes.php echoes "Release Unreleased" when the section is empty; normalize
|
||||
# to empty so the platform fallback below applies.
|
||||
[ "$NOTES" = "Release Unreleased" ] && NOTES=""
|
||||
NOTES=$(awk '/^## \[Unreleased\]/{found=1; next} /^## \[/{if(found) exit} found{print}' CHANGELOG.md)
|
||||
fi
|
||||
[ -z "$NOTES" ] && NOTES="Release candidate"
|
||||
|
||||
@@ -209,13 +201,9 @@ jobs:
|
||||
release:
|
||||
name: Build & Release Pipeline
|
||||
runs-on: release
|
||||
# Skip on template repos (Template-*) — they scaffold other repos and do not release.
|
||||
if: >-
|
||||
!startsWith(github.event.repository.name, 'Template-') &&
|
||||
(
|
||||
github.event.pull_request.merged == true ||
|
||||
(github.event_name == 'workflow_dispatch' && inputs.action != 'promote-rc')
|
||||
)
|
||||
github.event.pull_request.merged == true ||
|
||||
(github.event_name == 'workflow_dispatch' && inputs.action != 'promote-rc')
|
||||
|
||||
steps:
|
||||
- name: Checkout repository
|
||||
@@ -223,7 +211,6 @@ jobs:
|
||||
with:
|
||||
token: ${{ secrets.MOKOGIT_TOKEN }}
|
||||
fetch-depth: 0
|
||||
submodules: recursive
|
||||
|
||||
- name: Configure git for bot pushes
|
||||
run: |
|
||||
@@ -244,7 +231,7 @@ jobs:
|
||||
fi
|
||||
echo "No conflict markers found"
|
||||
|
||||
- name: Setup MokoCLI tools
|
||||
- name: Setup mokocli tools
|
||||
env:
|
||||
MOKO_CLONE_TOKEN: ${{ secrets.MOKOGIT_TOKEN }}
|
||||
MOKO_CLONE_HOST: git.mokoconsulting.tech/MokoConsulting
|
||||
@@ -361,13 +348,10 @@ jobs:
|
||||
print(m.group(1) if m else '')
|
||||
" <<< "$RELEASE_JSON" 2>/dev/null || true)
|
||||
|
||||
# Extract [Unreleased] section via the shared mokocli command (#364 centralization).
|
||||
# Extract [Unreleased] section from changelog
|
||||
NOTES=""
|
||||
if [ -f "CHANGELOG.md" ]; then
|
||||
NOTES=$(php ${MOKO_CLI}/release_notes.php --path . --version Unreleased 2>/dev/null || true)
|
||||
# release_notes.php echoes "Release Unreleased" when the section is empty; normalize
|
||||
# to empty so the platform fallback below applies.
|
||||
[ "$NOTES" = "Release Unreleased" ] && NOTES=""
|
||||
NOTES=$(awk '/^## \[Unreleased\]/{found=1; next} /^## \[/{if(found) exit} found{print}' CHANGELOG.md)
|
||||
fi
|
||||
[ -z "$NOTES" ] && NOTES="Stable release"
|
||||
|
||||
@@ -389,12 +373,18 @@ jobs:
|
||||
echo "Release notes updated from CHANGELOG.md"
|
||||
fi
|
||||
|
||||
# Promote [Unreleased] → [version] in CHANGELOG.md via the shared mokocli command (#364).
|
||||
# changelog_promote.php is idempotent (won't re-promote an existing version), merges
|
||||
# duplicate headings, drops blank release sections, and collapses whitespace — verified
|
||||
# byte-identical to the former inline promoter across 8 fixtures.
|
||||
# Promote [Unreleased] → [version] in CHANGELOG.md and reset
|
||||
if [ -n "$VERSION" ] && [ -f "CHANGELOG.md" ]; then
|
||||
php ${MOKO_CLI}/changelog_promote.php --path . --version "$VERSION"
|
||||
DATE=$(date +%Y-%m-%d)
|
||||
python3 -c "
|
||||
import sys
|
||||
version, date = sys.argv[1], sys.argv[2]
|
||||
content = open('CHANGELOG.md').read()
|
||||
old = '## [Unreleased]'
|
||||
new = f'## [Unreleased]\n\n## [{version}] --- {date}'
|
||||
content = content.replace(old, new, 1)
|
||||
open('CHANGELOG.md', 'w').write(content)
|
||||
" "$VERSION" "$DATE"
|
||||
git add CHANGELOG.md
|
||||
git commit -m "chore: promote changelog [Unreleased] → [${VERSION}]" || true
|
||||
git push origin main || true
|
||||
@@ -436,7 +426,7 @@ jobs:
|
||||
&& echo "main branch pushed to GitHub mirror" \
|
||||
|| echo "WARNING: GitHub mirror push failed"
|
||||
|
||||
- name: "Step 11: Delete rc branch (dev reset moved to cascade-dev.yml)"
|
||||
- name: "Step 11: Delete rc branch and recreate dev from main"
|
||||
if: steps.version.outputs.skip != 'true'
|
||||
continue-on-error: true
|
||||
run: |
|
||||
@@ -448,9 +438,17 @@ jobs:
|
||||
"${API_BASE}/branches/rc" 2>/dev/null \
|
||||
&& echo "Deleted rc branch" || echo "rc branch not found"
|
||||
|
||||
# dev is reset from main by the dedicated "Cascade Main -> Dev" workflow
|
||||
# (cascade-dev.yml), which runs after this release completes.
|
||||
echo "rc cleaned; dev reset handled by cascade-dev.yml" >> $GITHUB_STEP_SUMMARY
|
||||
# Delete dev branch
|
||||
curl -sf -X DELETE -H "Authorization: token ${TOKEN}" \
|
||||
"${API_BASE}/branches/dev" 2>/dev/null && echo "Deleted dev branch"
|
||||
|
||||
# Recreate dev from main (now includes version bump + changelog promotion)
|
||||
curl -sf -X POST -H "Authorization: token ${TOKEN}" \
|
||||
-H "Content-Type: application/json" \
|
||||
"${API_BASE}/branches" \
|
||||
-d '{"new_branch_name":"dev","old_branch_name":"main"}' 2>/dev/null && echo "Recreated dev from main"
|
||||
|
||||
echo "Pre-release branches cleaned, dev reset from main" >> $GITHUB_STEP_SUMMARY
|
||||
|
||||
- name: "Step 12: Create version branch from main"
|
||||
if: steps.version.outputs.skip != 'true'
|
||||
|
||||
@@ -1,190 +1,10 @@
|
||||
# Copyright (C) 2026 Moko Consulting <hello@mokoconsulting.tech>
|
||||
#
|
||||
# SPDX-License-Identifier: GPL-3.0-or-later
|
||||
#
|
||||
# FILE INFORMATION
|
||||
# DEFGROUP: MokoGIT.Workflow
|
||||
# INGROUP: MokoCLI.Cascade
|
||||
# REPO: https://git.mokoconsulting.tech/MokoConsulting/Template-Generic
|
||||
# PATH: /.mokogit/workflows/cascade-dev.yml
|
||||
# VERSION: 02.01.00
|
||||
# BRIEF: Cascade main -> dev; auto-merge clean, auto-resolve VERSION-stamp-only conflicts, else notify
|
||||
|
||||
name: "Cascade Main -> Dev"
|
||||
|
||||
on:
|
||||
push:
|
||||
branches:
|
||||
- main
|
||||
# Daily safety net: catches drift even when main only received [skip ci] pushes
|
||||
# (which never fire the push trigger above). Off-round minute to avoid a fleet-wide spike.
|
||||
schedule:
|
||||
- cron: '23 7 * * *'
|
||||
workflow_dispatch:
|
||||
|
||||
permissions:
|
||||
contents: write
|
||||
pull-requests: write
|
||||
|
||||
env:
|
||||
MOKOGIT_URL: ${{ vars.MOKOGIT_URL || 'https://git.mokoconsulting.tech' }}
|
||||
# ntfy destination is configured via repo or org variables (org vars are inherited).
|
||||
NTFY_URL: ${{ vars.NTFY_URL || 'https://ntfy.mokoconsulting.tech' }}
|
||||
NTFY_TOPIC: ${{ vars.CASCADE_NTFY_TOPIC || vars.NTFY_TOPIC || 'git-releases' }}
|
||||
|
||||
# DISABLED — auto-release Step 11 recreates dev from main after every release.
|
||||
# Cascade-dev is redundant and causes version conflicts when both main and dev
|
||||
# have different version numbers in templateDetails.xml / manifest.xml.
|
||||
name: "Cascade Main → Dev (DISABLED)"
|
||||
on: workflow_dispatch
|
||||
jobs:
|
||||
cascade:
|
||||
name: Cascade main -> dev
|
||||
noop:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Checkout (full history for merge/resolve)
|
||||
uses: actions/checkout@v4
|
||||
with:
|
||||
fetch-depth: 0
|
||||
token: ${{ secrets.MOKOGIT_TOKEN }}
|
||||
|
||||
- name: Cascade main -> dev (auto-resolve version stamps, else notify)
|
||||
env:
|
||||
TOKEN: ${{ secrets.MOKOGIT_TOKEN }}
|
||||
REPO: ${{ github.repository }}
|
||||
run: |
|
||||
set -uo pipefail
|
||||
API="${MOKOGIT_URL}/api/v1/repos/${REPO}"
|
||||
AUTH="Authorization: token ${TOKEN}"
|
||||
jqget() { python3 -c "import sys,json; d=json.load(sys.stdin); print(d.get('$1',''))" 2>/dev/null; }
|
||||
|
||||
# 0. dev must exist
|
||||
if ! curl -sf -H "$AUTH" "${API}/branches/dev" >/dev/null 2>&1; then
|
||||
echo "No dev branch - nothing to cascade."; exit 0
|
||||
fi
|
||||
|
||||
# 1. is main ahead of dev?
|
||||
AHEAD=$(curl -sf -H "$AUTH" "${API}/compare/dev...main" \
|
||||
| python3 -c "import sys,json; print(json.load(sys.stdin).get('total_commits',0))" 2>/dev/null || echo 0)
|
||||
if [ "${AHEAD:-0}" -eq 0 ]; then
|
||||
echo "dev already up to date with main."; exit 0
|
||||
fi
|
||||
echo "main is ${AHEAD} commit(s) ahead of dev."
|
||||
|
||||
# 2. reuse an open main->dev PR, else create one
|
||||
PR=$(curl -sf -H "$AUTH" "${API}/pulls?state=open&base=dev" \
|
||||
| python3 -c "import sys,json; d=json.load(sys.stdin); print(next((str(p['number']) for p in d if p.get('head',{}).get('ref')=='main'), ''))" 2>/dev/null || echo "")
|
||||
if [ -z "$PR" ]; then
|
||||
RESP=$(curl -s -H "$AUTH" -H "Content-Type: application/json" -X POST "${API}/pulls" \
|
||||
-d '{"head":"main","base":"dev","title":"chore(sync): cascade main -> dev","body":"Automated cascade of main into dev. Auto-merges when conflict-free, auto-resolves VERSION-stamp-only conflicts, otherwise left open for manual resolution."}')
|
||||
PR=$(printf '%s' "$RESP" | jqget number)
|
||||
if [ -z "$PR" ]; then
|
||||
echo "::warning::Could not open cascade PR: $RESP"; exit 0
|
||||
fi
|
||||
echo "Opened cascade PR #${PR}"
|
||||
else
|
||||
echo "Reusing open cascade PR #${PR}"
|
||||
fi
|
||||
|
||||
notify() {
|
||||
curl -sS \
|
||||
-H "Title: ${REPO}: dev cascade needs manual merge" \
|
||||
-H "Tags: warning,twisted_rightwards_arrows" \
|
||||
-H "Priority: high" \
|
||||
-H "Click: ${MOKOGIT_URL}/${REPO}/pulls/${PR}" \
|
||||
-d "main -> dev cascade PR #${PR} $1 It was NOT auto-merged; resolve it manually." \
|
||||
"${NTFY_URL}/${NTFY_TOPIC}" || true
|
||||
}
|
||||
|
||||
# 3. wait for MokoGIT to compute mergeability (conflict detection)
|
||||
MERGEABLE=""
|
||||
for _ in 1 2 3 4 5 6; do
|
||||
MERGEABLE=$(curl -sf -H "$AUTH" "${API}/pulls/${PR}" | jqget mergeable)
|
||||
case "$MERGEABLE" in True|False) break ;; esac
|
||||
sleep 3
|
||||
done
|
||||
echo "mergeable=${MERGEABLE}"
|
||||
|
||||
# 4a. conflict-free -> merge via API (existing behaviour)
|
||||
if [ "$MERGEABLE" = "True" ]; then
|
||||
CODE=$(curl -s -o /tmp/merge.json -w "%{http_code}" -H "$AUTH" -H "Content-Type: application/json" \
|
||||
-X POST "${API}/pulls/${PR}/merge" -d '{"Do":"merge","merge_when_checks_succeed":true}')
|
||||
if [ "$CODE" -ge 200 ] && [ "$CODE" -lt 300 ]; then
|
||||
echo "Cascade PR #${PR} merged (or scheduled to merge when checks pass)."
|
||||
exit 0
|
||||
fi
|
||||
echo "::warning::Auto-merge returned HTTP ${CODE}: $(cat /tmp/merge.json)"
|
||||
notify "could not be auto-merged (HTTP ${CODE})."
|
||||
exit 0
|
||||
fi
|
||||
|
||||
# 4b. conflicts -> try to auto-resolve if they are ONLY VERSION-stamp lines.
|
||||
echo "PR not cleanly mergeable; checking whether conflicts are VERSION-stamp-only..."
|
||||
git config user.name "MokoGIT Cascade"
|
||||
git config user.email "actions@mokoconsulting.tech"
|
||||
git fetch --quiet origin main dev
|
||||
git checkout -B dev origin/dev
|
||||
|
||||
if git merge --no-ff --no-commit origin/main >/dev/null 2>&1; then
|
||||
# Became clean at git level (e.g. mergeability was still computing) -> commit + push.
|
||||
git commit -m "chore(sync): cascade main -> dev [skip ci]" >/dev/null
|
||||
git push origin dev
|
||||
echo "Cascade merged cleanly at git level and pushed to dev."
|
||||
exit 0
|
||||
fi
|
||||
|
||||
CONFLICTS=$(git diff --name-only --diff-filter=U)
|
||||
echo "Conflicted files:"; echo "${CONFLICTS}"
|
||||
|
||||
# A conflict is "stamp-only" when every line inside every conflict block matches
|
||||
# a version-stamp pattern (VERSION: header, <version> element, or CHANGELOG title).
|
||||
is_stamp_only() {
|
||||
awk '
|
||||
/^<<<<<<< / { inc=1; next }
|
||||
inc && /^=======$/ { next }
|
||||
/^>>>>>>> / { inc=0; next }
|
||||
inc { if ($0 !~ /(VERSION:|<version>|# Changelog)/) { bad=1 } }
|
||||
END { exit(bad ? 1 : 0) }
|
||||
' "$1"
|
||||
}
|
||||
# Resolve a stamp-only file by keeping dev (ours) for the conflicting lines,
|
||||
# preserving all auto-merged content around them.
|
||||
keep_ours() {
|
||||
awk '
|
||||
/^<<<<<<< / { inc=1; side="ours"; next }
|
||||
inc && /^=======$/ { side="theirs"; next }
|
||||
/^>>>>>>> / { inc=0; next }
|
||||
{ if (!inc) { print; next } if (side=="ours") print }
|
||||
' "$1" > "$1.resolved" && mv "$1.resolved" "$1"
|
||||
}
|
||||
|
||||
ALL_STAMP=1
|
||||
for f in ${CONFLICTS}; do
|
||||
if ! is_stamp_only "$f"; then
|
||||
echo "::notice::$f has non-stamp conflicts -> manual resolution required."
|
||||
ALL_STAMP=0; break
|
||||
fi
|
||||
done
|
||||
|
||||
if [ "$ALL_STAMP" != "1" ]; then
|
||||
git merge --abort || true
|
||||
notify "has non-version-stamp conflicts and cannot be auto-resolved."
|
||||
exit 0
|
||||
fi
|
||||
|
||||
echo "All conflicts are VERSION-stamp-only; resolving in favour of dev."
|
||||
for f in ${CONFLICTS}; do
|
||||
keep_ours "$f"
|
||||
git add "$f"
|
||||
done
|
||||
|
||||
# Best-effort: normalise stamps to dev's version if mokocli is available.
|
||||
if [ -f /opt/mokocli/cli/version_check.php ]; then
|
||||
php /opt/mokocli/cli/version_check.php --fix || true
|
||||
git add -A
|
||||
fi
|
||||
|
||||
git commit -m "chore(sync): cascade main -> dev (auto-resolved version stamps) [skip ci]" >/dev/null
|
||||
git push origin dev
|
||||
echo "Cascade auto-resolved and pushed to dev."
|
||||
|
||||
# Close the now-redundant PR (its changes are in dev) with an explanatory comment.
|
||||
curl -s -H "$AUTH" -H "Content-Type: application/json" -X POST "${API}/issues/${PR}/comments" \
|
||||
-d '{"body":"Auto-resolved VERSION-stamp-only conflicts and pushed the merge to dev. Closing."}' >/dev/null || true
|
||||
curl -s -H "$AUTH" -H "Content-Type: application/json" -X PATCH "${API}/pulls/${PR}" \
|
||||
-d '{"state":"closed"}' >/dev/null || true
|
||||
- run: echo "Cascade disabled — auto-release handles dev recreation"
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
#
|
||||
# FILE INFORMATION
|
||||
# DEFGROUP: MokoGIT.Workflow
|
||||
# INGROUP: MokoCLI.CI
|
||||
# INGROUP: MokoStandards.CI
|
||||
# REPO: https://git.mokoconsulting.tech/MokoConsulting/Template-Generic
|
||||
# PATH: /.mokogit/workflows/ci-generic.yml
|
||||
# VERSION: 01.00.00
|
||||
@@ -32,8 +32,6 @@ jobs:
|
||||
lint:
|
||||
name: Lint & Validate
|
||||
runs-on: ubuntu-latest
|
||||
# Skip on template repos (Template-*) — they hold placeholder scaffolding, not buildable source.
|
||||
if: ${{ !startsWith(github.event.repository.name, 'Template-') }}
|
||||
|
||||
steps:
|
||||
- name: Checkout
|
||||
@@ -131,11 +129,7 @@ jobs:
|
||||
test:
|
||||
name: Tests
|
||||
runs-on: ubuntu-latest
|
||||
# Independent job (no `needs: lint`): the MokoGIT Actions scheduler does not
|
||||
# offer the dependent 2nd job of a needs-chain to runners, so it stalls in
|
||||
# "waiting" and is reaped by ABANDONED_JOB_TIMEOUT. Guard template repos
|
||||
# directly (same condition lint uses) instead of gating on lint's result.
|
||||
if: ${{ !startsWith(github.event.repository.name, 'Template-') }}
|
||||
needs: lint
|
||||
|
||||
steps:
|
||||
- name: Checkout
|
||||
|
||||
@@ -4,8 +4,8 @@
|
||||
#
|
||||
# FILE INFORMATION
|
||||
# DEFGROUP: MokoGIT.Workflow
|
||||
# INGROUP: MokoCLI.Maintenance
|
||||
# REPO: https://git.mokoconsulting.tech/MokoConsulting/mokocli
|
||||
# INGROUP: MokoStandards.Maintenance
|
||||
# REPO: https://git.mokoconsulting.tech/MokoConsulting/MokoStandards
|
||||
# PATH: /.mokogit/workflows/cleanup.yml
|
||||
# VERSION: 01.00.00
|
||||
# BRIEF: Scheduled cleanup — delete merged branches and old workflow runs
|
||||
@@ -50,7 +50,7 @@ jobs:
|
||||
for BRANCH in $BRANCHES; do
|
||||
# Skip protected branches
|
||||
case "$BRANCH" in
|
||||
main|master|dev|develop|rc|beta|alpha|release|release/*|production|stable|staging|hotfix/*|version/*) continue ;;
|
||||
main|master|develop|release/*|hotfix/*) continue ;;
|
||||
esac
|
||||
|
||||
# Check if branch is merged into main
|
||||
|
||||
@@ -1,22 +1,24 @@
|
||||
# Copyright (C) 2026 Moko Consulting <hello@mokoconsulting.tech>
|
||||
# SPDX-License-Identifier: GPL-3.0-or-later
|
||||
# BRIEF: Deploy to the Dev environment on push to the dev branch via the
|
||||
# restricted per-repo deploy pattern. This is a THIN trigger: it only
|
||||
# validates the tier+tag and hands "<tier> <tag>" to the forced-command
|
||||
# deploy-mokogit user over SSH (mokocli cli/deploy.php). The server-side
|
||||
# forced command sudo's to a root-owned deployer that builds, pushes,
|
||||
# recreates and health-checks — the runner never builds, holds a registry
|
||||
# token, or runs the health check. See `.vault system/deploy` and runbook
|
||||
# 16-restricted-deploy-pattern.
|
||||
# BRIEF: Build and deploy to the Dev environment on push to the dev branch.
|
||||
# Portable across Go server repos: ALL deployment config comes from repo
|
||||
# Actions variables (vars.*) and secrets (secrets.*), nothing hardcoded.
|
||||
# The dev branch is the ongoing integration branch.
|
||||
# OWNER: Template-Go (canonical source; syncs to the root workflows dir). See Template-Go#3.
|
||||
# NOTE: deploy-*.yml are repo-managed (per-repo deploy user + secrets/vars)
|
||||
# and excluded from template sync — see mokocli workflow_sync PLATFORM_EXCLUDES['go'].
|
||||
#
|
||||
# Required repo VARIABLES:
|
||||
# Required repo VARIABLES (all tier-scoped so each environment is independent —
|
||||
# a repo may host its rc/dev/prod tiers on different machines):
|
||||
# DEV_SSH_HOST, DEV_SSH_PORT, DEV_SSH_USERNAME - SSH deploy target for the dev tier
|
||||
# (DEV_SSH_USERNAME = deploy-mokogit, the forced-command deploy user)
|
||||
# Required SECRETS (already configured; reused, not re-set):
|
||||
# DEPLOY_SSH_KEY - deploy-mokogit private key (repo secret)
|
||||
# DEV_REGISTRY, DEV_REGISTRY_USER, DEV_IMAGE - container registry + login user + image
|
||||
# DEV_CONTAINER - compose service/container to recreate
|
||||
# DEV_COMPOSE_PROJECT - docker compose -p project name
|
||||
# DEV_COMPOSE_DIR - dir containing docker-compose.yml on host
|
||||
# DEV_SOURCE_DIR - build source checkout on host
|
||||
# DEV_TAG_ENV - compose env-var name that pins the image tag
|
||||
# DEV_HEALTH_URL - external URL to verify after deploy
|
||||
# Required SECRETS (already configured org-wide; reused, not re-set):
|
||||
# DEPLOY_SSH_KEY - deploy private key (repo/org secret)
|
||||
# MOKOGIT_TOKEN - registry/API token (org secret)
|
||||
|
||||
name: Deploy (Dev)
|
||||
|
||||
@@ -28,16 +30,16 @@ on:
|
||||
# Runs on the ref it is dispatched from.
|
||||
workflow_dispatch:
|
||||
|
||||
# No `concurrency:` block: it triggers a MokoGIT Actions run-creation bug that
|
||||
# silently drops deploys on rapid pushes to the branch. Do not re-add until the
|
||||
# upstream bug is confirmed fixed.
|
||||
concurrency:
|
||||
group: deploy-dev
|
||||
cancel-in-progress: true
|
||||
|
||||
env:
|
||||
FORCE_JAVASCRIPT_ACTIONS_TO_NODE24: true
|
||||
|
||||
jobs:
|
||||
deploy-dev:
|
||||
name: "Deploy to Dev"
|
||||
name: "Build & Deploy to Dev"
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Checkout source
|
||||
@@ -60,29 +62,75 @@ jobs:
|
||||
echo "$DEPLOY_KEY" > ~/.ssh/deploy_key
|
||||
chmod 600 ~/.ssh/deploy_key
|
||||
|
||||
- name: Setup MokoCLI tools
|
||||
- name: Build and deploy to RC via SSH
|
||||
env:
|
||||
MOKO_CLONE_TOKEN: ${{ secrets.MOKOGIT_TOKEN }}
|
||||
MOKO_CLONE_HOST: git.mokoconsulting.tech/MokoConsulting
|
||||
REGISTRY_TOKEN: ${{ secrets.MOKOGIT_TOKEN }}
|
||||
TAG: ${{ steps.config.outputs.tag }}
|
||||
run: |
|
||||
# Use pre-installed /opt/mokocli if available (updated by cron every 6h)
|
||||
if [ -f /opt/mokocli/cli/deploy.php ] && [ -f /opt/mokocli/vendor/autoload.php ]; then
|
||||
echo Using pre-installed /opt/mokocli
|
||||
echo MOKO_CLI=/opt/mokocli/cli >> $GITHUB_ENV
|
||||
else
|
||||
echo Falling back to fresh clone
|
||||
if ! command -v composer > /dev/null 2>&1; then
|
||||
sudo apt-get update -qq && sudo apt-get install -y -qq php-cli php-mbstring php-xml php-zip php-curl composer > /dev/null 2>&1
|
||||
fi
|
||||
rm -rf /tmp/mokocli
|
||||
CLONE_URL=https://x-access-token:${MOKO_CLONE_TOKEN}@${MOKO_CLONE_HOST}/mokocli.git
|
||||
git clone --depth 1 --branch main --quiet $CLONE_URL /tmp/mokocli
|
||||
cd /tmp/mokocli && composer install --no-dev --no-interaction --quiet
|
||||
echo MOKO_CLI=/tmp/mokocli/cli >> $GITHUB_ENV
|
||||
# Runner-side values (TAG, REGISTRY_TOKEN) are injected into the remote shell
|
||||
# via an env prefix; a *quoted* heredoc keeps every $var expanding once, on the
|
||||
# remote. Repo variables (vars.*) are substituted inline by Actions before ssh.
|
||||
ssh -i ~/.ssh/deploy_key -p ${{ vars.DEV_SSH_PORT }} \
|
||||
-o ConnectTimeout=30 -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null \
|
||||
-o ServerAliveInterval=30 -o ServerAliveCountMax=10 \
|
||||
${{ vars.DEV_SSH_USERNAME }}@${{ vars.DEV_SSH_HOST }} \
|
||||
"TAG='$TAG' REGISTRY_TOKEN='$REGISTRY_TOKEN' bash -s" <<'DEPLOY_EOF'
|
||||
set -e
|
||||
echo 'SSH connected to Dev environment'
|
||||
|
||||
if [ -z "$TAG" ]; then
|
||||
echo 'ERROR: TAG is empty; refusing to build an untagged image' >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
- name: Deploy (dev)
|
||||
HEALTH_FMT='{{.State.Health.Status}}'
|
||||
|
||||
echo 'Cleaning Docker build cache...'
|
||||
docker builder prune -af 2>/dev/null || true
|
||||
docker image prune -af 2>/dev/null || true
|
||||
|
||||
echo 'Pulling source...'
|
||||
SOURCE_DIR='${{ vars.DEV_SOURCE_DIR }}'
|
||||
if [ ! -d "$SOURCE_DIR/.git" ]; then
|
||||
git clone -b dev https://x-access-token:${REGISTRY_TOKEN}@git.mokoconsulting.tech/${{ github.repository }}.git "$SOURCE_DIR"
|
||||
fi
|
||||
cd "$SOURCE_DIR"
|
||||
git remote set-url origin https://x-access-token:${REGISTRY_TOKEN}@git.mokoconsulting.tech/${{ github.repository }}.git 2>/dev/null || true
|
||||
git fetch origin dev
|
||||
git reset --hard origin/dev
|
||||
|
||||
echo "Building image: ${{ vars.DEV_REGISTRY }}/${{ vars.DEV_IMAGE }}:$TAG"
|
||||
docker build --no-cache --build-arg GOFLAGS='-p 1' \
|
||||
--tag "${{ vars.DEV_REGISTRY }}/${{ vars.DEV_IMAGE }}:$TAG" \
|
||||
-f Dockerfile .
|
||||
|
||||
echo 'Pushing to registry...'
|
||||
echo "$REGISTRY_TOKEN" | docker login ${{ vars.DEV_REGISTRY }} -u ${{ vars.DEV_REGISTRY_USER }} --password-stdin
|
||||
docker push "${{ vars.DEV_REGISTRY }}/${{ vars.DEV_IMAGE }}:$TAG"
|
||||
|
||||
echo 'Restarting Dev container...'
|
||||
cd '${{ vars.DEV_COMPOSE_DIR }}'
|
||||
# Drive the rc service image tag via its compose env-var (no sed on the shared
|
||||
# file); remove any lingering fixed-name container first, then force-recreate.
|
||||
docker rm -f '${{ vars.DEV_CONTAINER }}' 2>/dev/null || true
|
||||
${{ vars.DEV_TAG_ENV }}="$TAG" docker compose -p '${{ vars.DEV_COMPOSE_PROJECT }}' up -d --force-recreate '${{ vars.DEV_CONTAINER }}'
|
||||
|
||||
echo 'Health check...'
|
||||
for i in 1 2 3 4 5 6 7 8; do
|
||||
sleep 15
|
||||
if docker inspect --format="$HEALTH_FMT" '${{ vars.DEV_CONTAINER }}' 2>/dev/null | grep -q healthy; then
|
||||
echo 'Dev container healthy!'
|
||||
exit 0
|
||||
fi
|
||||
echo "Waiting... (attempt $i/8)"
|
||||
done
|
||||
echo 'Health check failed'
|
||||
docker logs '${{ vars.DEV_CONTAINER }}' --tail 20
|
||||
exit 1
|
||||
DEPLOY_EOF
|
||||
|
||||
- name: Verify Dev instance
|
||||
continue-on-error: true
|
||||
run: |
|
||||
php ${MOKO_CLI}/deploy.php --tier dev --tag "${{ steps.config.outputs.tag }}" \
|
||||
--ssh-host ${{ vars.DEV_SSH_HOST }} --ssh-port ${{ vars.DEV_SSH_PORT }} \
|
||||
--ssh-user ${{ vars.DEV_SSH_USERNAME }} --ssh-key ~/.ssh/deploy_key
|
||||
sleep 5
|
||||
ssh -i ~/.ssh/deploy_key -p ${{ vars.DEV_SSH_PORT }} -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null ${{ vars.DEV_SSH_USERNAME }}@${{ vars.DEV_SSH_HOST }} "curl -sf '${{ vars.DEV_HEALTH_URL }}'" && echo " Dev API healthy"
|
||||
|
||||
@@ -1,23 +1,24 @@
|
||||
# Copyright (C) 2026 Moko Consulting <hello@mokoconsulting.tech>
|
||||
# SPDX-License-Identifier: GPL-3.0-or-later
|
||||
# BRIEF: Deploy to the Prod environment on push to the main branch via the
|
||||
# restricted per-repo deploy pattern. This is a THIN trigger: it only
|
||||
# validates the tier+tag and hands "<tier> <tag>" to the forced-command
|
||||
# deploy-mokogit user over SSH (mokocli cli/deploy.php). The server-side
|
||||
# forced command sudo's to a root-owned deployer that builds, pushes,
|
||||
# recreates and health-checks — the runner never builds, holds a registry
|
||||
# token, or runs the health check. See `.vault system/deploy` and runbook
|
||||
# 16-restricted-deploy-pattern.
|
||||
# BRIEF: Build and deploy to the Prod environment on push to the main branch.
|
||||
# Portable across Go server repos: ALL deployment config comes from repo
|
||||
# Actions variables (vars.*) and secrets (secrets.*), nothing hardcoded.
|
||||
# Prod deploys on merge to main (dev -> rc -> main pipeline).
|
||||
# OWNER: Template-Go (canonical source; syncs to the root workflows dir). See Template-Go#3.
|
||||
# NOTE: deploy-*.yml are repo-managed (per-repo deploy user + secrets/vars)
|
||||
# and excluded from template sync — see mokocli workflow_sync PLATFORM_EXCLUDES['go'].
|
||||
#
|
||||
# Required repo VARIABLES:
|
||||
# Required repo VARIABLES (all tier-scoped so each environment is independent —
|
||||
# a repo may host its rc/dev/prod tiers on different machines):
|
||||
# PROD_SSH_HOST, PROD_SSH_PORT, PROD_SSH_USERNAME - SSH deploy target for the prod tier
|
||||
# (PROD_SSH_USERNAME = deploy-mokogit, the forced-command deploy user)
|
||||
# Required SECRETS (already configured; reused, not re-set):
|
||||
# DEPLOY_SSH_KEY - deploy-mokogit private key (repo secret)
|
||||
# PROD_REGISTRY, PROD_REGISTRY_USER, PROD_IMAGE - container registry + login user + image
|
||||
# PROD_CONTAINER - compose service/container to recreate
|
||||
# PROD_COMPOSE_PROJECT - docker compose -p project name
|
||||
# PROD_COMPOSE_DIR - dir containing docker-compose.yml on host
|
||||
# PROD_SOURCE_DIR - build source checkout on host
|
||||
# PROD_TAG_ENV - compose env-var name that pins the image tag
|
||||
# PROD_HEALTH_URL - external URL to verify after deploy
|
||||
# Required SECRETS (already configured org-wide; reused, not re-set):
|
||||
# DEPLOY_SSH_KEY - deploy private key (repo/org secret)
|
||||
# MOKOGIT_TOKEN - registry/API token (org secret)
|
||||
|
||||
name: Deploy (Prod)
|
||||
|
||||
@@ -29,16 +30,16 @@ on:
|
||||
# Runs on the ref it is dispatched from (use main).
|
||||
workflow_dispatch:
|
||||
|
||||
# No `concurrency:` block: it triggers a MokoGIT Actions run-creation bug that
|
||||
# silently drops deploys on rapid pushes to the branch. Do not re-add until the
|
||||
# upstream bug is confirmed fixed.
|
||||
concurrency:
|
||||
group: deploy-prod
|
||||
cancel-in-progress: false
|
||||
|
||||
env:
|
||||
FORCE_JAVASCRIPT_ACTIONS_TO_NODE24: true
|
||||
|
||||
jobs:
|
||||
deploy-prod:
|
||||
name: "Deploy to Prod"
|
||||
name: "Build & Deploy to Prod"
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Checkout source
|
||||
@@ -61,29 +62,75 @@ jobs:
|
||||
echo "$DEPLOY_KEY" > ~/.ssh/deploy_key
|
||||
chmod 600 ~/.ssh/deploy_key
|
||||
|
||||
- name: Setup MokoCLI tools
|
||||
- name: Build and deploy to RC via SSH
|
||||
env:
|
||||
MOKO_CLONE_TOKEN: ${{ secrets.MOKOGIT_TOKEN }}
|
||||
MOKO_CLONE_HOST: git.mokoconsulting.tech/MokoConsulting
|
||||
REGISTRY_TOKEN: ${{ secrets.MOKOGIT_TOKEN }}
|
||||
TAG: ${{ steps.config.outputs.tag }}
|
||||
run: |
|
||||
# Use pre-installed /opt/mokocli if available (updated by cron every 6h)
|
||||
if [ -f /opt/mokocli/cli/deploy.php ] && [ -f /opt/mokocli/vendor/autoload.php ]; then
|
||||
echo Using pre-installed /opt/mokocli
|
||||
echo MOKO_CLI=/opt/mokocli/cli >> $GITHUB_ENV
|
||||
else
|
||||
echo Falling back to fresh clone
|
||||
if ! command -v composer > /dev/null 2>&1; then
|
||||
sudo apt-get update -qq && sudo apt-get install -y -qq php-cli php-mbstring php-xml php-zip php-curl composer > /dev/null 2>&1
|
||||
fi
|
||||
rm -rf /tmp/mokocli
|
||||
CLONE_URL=https://x-access-token:${MOKO_CLONE_TOKEN}@${MOKO_CLONE_HOST}/mokocli.git
|
||||
git clone --depth 1 --branch main --quiet $CLONE_URL /tmp/mokocli
|
||||
cd /tmp/mokocli && composer install --no-dev --no-interaction --quiet
|
||||
echo MOKO_CLI=/tmp/mokocli/cli >> $GITHUB_ENV
|
||||
# Runner-side values (TAG, REGISTRY_TOKEN) are injected into the remote shell
|
||||
# via an env prefix; a *quoted* heredoc keeps every $var expanding once, on the
|
||||
# remote. Repo variables (vars.*) are substituted inline by Actions before ssh.
|
||||
ssh -i ~/.ssh/deploy_key -p ${{ vars.PROD_SSH_PORT }} \
|
||||
-o ConnectTimeout=30 -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null \
|
||||
-o ServerAliveInterval=30 -o ServerAliveCountMax=10 \
|
||||
${{ vars.PROD_SSH_USERNAME }}@${{ vars.PROD_SSH_HOST }} \
|
||||
"TAG='$TAG' REGISTRY_TOKEN='$REGISTRY_TOKEN' bash -s" <<'DEPLOY_EOF'
|
||||
set -e
|
||||
echo 'SSH connected to Prod environment'
|
||||
|
||||
if [ -z "$TAG" ]; then
|
||||
echo 'ERROR: TAG is empty; refusing to build an untagged image' >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
- name: Deploy (prod)
|
||||
HEALTH_FMT='{{.State.Health.Status}}'
|
||||
|
||||
echo 'Cleaning Docker build cache...'
|
||||
docker builder prune -af 2>/dev/null || true
|
||||
docker image prune -af 2>/dev/null || true
|
||||
|
||||
echo 'Pulling source...'
|
||||
SOURCE_DIR='${{ vars.PROD_SOURCE_DIR }}'
|
||||
if [ ! -d "$SOURCE_DIR/.git" ]; then
|
||||
git clone -b main https://x-access-token:${REGISTRY_TOKEN}@git.mokoconsulting.tech/${{ github.repository }}.git "$SOURCE_DIR"
|
||||
fi
|
||||
cd "$SOURCE_DIR"
|
||||
git remote set-url origin https://x-access-token:${REGISTRY_TOKEN}@git.mokoconsulting.tech/${{ github.repository }}.git 2>/dev/null || true
|
||||
git fetch origin main
|
||||
git reset --hard origin/main
|
||||
|
||||
echo "Building image: ${{ vars.PROD_REGISTRY }}/${{ vars.PROD_IMAGE }}:$TAG"
|
||||
docker build --no-cache --build-arg GOFLAGS='-p 1' \
|
||||
--tag "${{ vars.PROD_REGISTRY }}/${{ vars.PROD_IMAGE }}:$TAG" \
|
||||
-f Dockerfile .
|
||||
|
||||
echo 'Pushing to registry...'
|
||||
echo "$REGISTRY_TOKEN" | docker login ${{ vars.PROD_REGISTRY }} -u ${{ vars.PROD_REGISTRY_USER }} --password-stdin
|
||||
docker push "${{ vars.PROD_REGISTRY }}/${{ vars.PROD_IMAGE }}:$TAG"
|
||||
|
||||
echo 'Restarting Prod container...'
|
||||
cd '${{ vars.PROD_COMPOSE_DIR }}'
|
||||
# Drive the rc service image tag via its compose env-var (no sed on the shared
|
||||
# file); remove any lingering fixed-name container first, then force-recreate.
|
||||
docker rm -f '${{ vars.PROD_CONTAINER }}' 2>/dev/null || true
|
||||
${{ vars.PROD_TAG_ENV }}="$TAG" docker compose -p '${{ vars.PROD_COMPOSE_PROJECT }}' up -d --force-recreate '${{ vars.PROD_CONTAINER }}'
|
||||
|
||||
echo 'Health check...'
|
||||
for i in 1 2 3 4 5 6 7 8; do
|
||||
sleep 15
|
||||
if docker inspect --format="$HEALTH_FMT" '${{ vars.PROD_CONTAINER }}' 2>/dev/null | grep -q healthy; then
|
||||
echo 'Prod container healthy!'
|
||||
exit 0
|
||||
fi
|
||||
echo "Waiting... (attempt $i/8)"
|
||||
done
|
||||
echo 'Health check failed'
|
||||
docker logs '${{ vars.PROD_CONTAINER }}' --tail 20
|
||||
exit 1
|
||||
DEPLOY_EOF
|
||||
|
||||
- name: Verify Prod instance
|
||||
continue-on-error: true
|
||||
run: |
|
||||
php ${MOKO_CLI}/deploy.php --tier prod --tag "${{ steps.config.outputs.tag }}" \
|
||||
--ssh-host ${{ vars.PROD_SSH_HOST }} --ssh-port ${{ vars.PROD_SSH_PORT }} \
|
||||
--ssh-user ${{ vars.PROD_SSH_USERNAME }} --ssh-key ~/.ssh/deploy_key
|
||||
sleep 5
|
||||
ssh -i ~/.ssh/deploy_key -p ${{ vars.PROD_SSH_PORT }} -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null ${{ vars.PROD_SSH_USERNAME }}@${{ vars.PROD_SSH_HOST }} "curl -sf '${{ vars.PROD_HEALTH_URL }}'" && echo " Prod API healthy"
|
||||
|
||||
@@ -1,23 +1,24 @@
|
||||
# Copyright (C) 2026 Moko Consulting <hello@mokoconsulting.tech>
|
||||
# SPDX-License-Identifier: GPL-3.0-or-later
|
||||
# BRIEF: Deploy to the RC environment on push to the rc branch via the
|
||||
# restricted per-repo deploy pattern. This is a THIN trigger: it only
|
||||
# validates the tier+tag and hands "<tier> <tag>" to the forced-command
|
||||
# deploy-mokogit user over SSH (mokocli cli/deploy.php). The server-side
|
||||
# forced command sudo's to a root-owned deployer that builds, pushes,
|
||||
# recreates and health-checks — the runner never builds, holds a registry
|
||||
# token, or runs the health check. See `.vault system/deploy` and runbook
|
||||
# 16-restricted-deploy-pattern.
|
||||
# BRIEF: Build and deploy to the RC environment on push to the rc branch.
|
||||
# Portable across Go server repos: ALL deployment config comes from repo
|
||||
# Actions variables (vars.*) and secrets (secrets.*), nothing hardcoded.
|
||||
# The rc branch is created by promote-rc when a PR to main opens.
|
||||
# OWNER: Template-Go (canonical source; syncs to the root workflows dir). See Template-Go#3.
|
||||
# NOTE: deploy-*.yml are repo-managed (per-repo deploy user + secrets/vars)
|
||||
# and excluded from template sync — see mokocli workflow_sync PLATFORM_EXCLUDES['go'].
|
||||
#
|
||||
# Required repo VARIABLES:
|
||||
# Required repo VARIABLES (all tier-scoped so each environment is independent —
|
||||
# a repo may host its rc/dev/prod tiers on different machines):
|
||||
# RC_SSH_HOST, RC_SSH_PORT, RC_SSH_USERNAME - SSH deploy target for the rc tier
|
||||
# (RC_SSH_USERNAME = deploy-mokogit, the forced-command deploy user)
|
||||
# Required SECRETS (already configured; reused, not re-set):
|
||||
# DEPLOY_SSH_KEY - deploy-mokogit private key (repo secret)
|
||||
# RC_REGISTRY, RC_REGISTRY_USER, RC_IMAGE - container registry + login user + image
|
||||
# RC_CONTAINER - compose service/container to recreate
|
||||
# RC_COMPOSE_PROJECT - docker compose -p project name
|
||||
# RC_COMPOSE_DIR - dir containing docker-compose.yml on host
|
||||
# RC_SOURCE_DIR - build source checkout on host
|
||||
# RC_TAG_ENV - compose env-var name that pins the image tag
|
||||
# RC_HEALTH_URL - external URL to verify after deploy
|
||||
# Required SECRETS (already configured org-wide; reused, not re-set):
|
||||
# DEPLOY_SSH_KEY - deploy private key (repo/org secret)
|
||||
# MOKOGIT_TOKEN - registry/API token (org secret)
|
||||
|
||||
name: Deploy (RC)
|
||||
|
||||
@@ -31,16 +32,16 @@ on:
|
||||
# newer DB. Dispatch from `rc` once `rc` is current.
|
||||
workflow_dispatch:
|
||||
|
||||
# No `concurrency:` block: it triggers a MokoGIT Actions run-creation bug that
|
||||
# silently drops deploys on rapid pushes to the branch. Do not re-add until the
|
||||
# upstream bug is confirmed fixed.
|
||||
concurrency:
|
||||
group: deploy-rc
|
||||
cancel-in-progress: true
|
||||
|
||||
env:
|
||||
FORCE_JAVASCRIPT_ACTIONS_TO_NODE24: true
|
||||
|
||||
jobs:
|
||||
deploy-rc:
|
||||
name: "Deploy to RC"
|
||||
name: "Build & Deploy to RC"
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Checkout source
|
||||
@@ -63,29 +64,75 @@ jobs:
|
||||
echo "$DEPLOY_KEY" > ~/.ssh/deploy_key
|
||||
chmod 600 ~/.ssh/deploy_key
|
||||
|
||||
- name: Setup MokoCLI tools
|
||||
- name: Build and deploy to RC via SSH
|
||||
env:
|
||||
MOKO_CLONE_TOKEN: ${{ secrets.MOKOGIT_TOKEN }}
|
||||
MOKO_CLONE_HOST: git.mokoconsulting.tech/MokoConsulting
|
||||
REGISTRY_TOKEN: ${{ secrets.MOKOGIT_TOKEN }}
|
||||
TAG: ${{ steps.config.outputs.tag }}
|
||||
run: |
|
||||
# Use pre-installed /opt/mokocli if available (updated by cron every 6h)
|
||||
if [ -f /opt/mokocli/cli/deploy.php ] && [ -f /opt/mokocli/vendor/autoload.php ]; then
|
||||
echo Using pre-installed /opt/mokocli
|
||||
echo MOKO_CLI=/opt/mokocli/cli >> $GITHUB_ENV
|
||||
else
|
||||
echo Falling back to fresh clone
|
||||
if ! command -v composer > /dev/null 2>&1; then
|
||||
sudo apt-get update -qq && sudo apt-get install -y -qq php-cli php-mbstring php-xml php-zip php-curl composer > /dev/null 2>&1
|
||||
fi
|
||||
rm -rf /tmp/mokocli
|
||||
CLONE_URL=https://x-access-token:${MOKO_CLONE_TOKEN}@${MOKO_CLONE_HOST}/mokocli.git
|
||||
git clone --depth 1 --branch main --quiet $CLONE_URL /tmp/mokocli
|
||||
cd /tmp/mokocli && composer install --no-dev --no-interaction --quiet
|
||||
echo MOKO_CLI=/tmp/mokocli/cli >> $GITHUB_ENV
|
||||
# Runner-side values (TAG, REGISTRY_TOKEN) are injected into the remote shell
|
||||
# via an env prefix; a *quoted* heredoc keeps every $var expanding once, on the
|
||||
# remote. Repo variables (vars.*) are substituted inline by Actions before ssh.
|
||||
ssh -i ~/.ssh/deploy_key -p ${{ vars.RC_SSH_PORT }} \
|
||||
-o ConnectTimeout=30 -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null \
|
||||
-o ServerAliveInterval=30 -o ServerAliveCountMax=10 \
|
||||
${{ vars.RC_SSH_USERNAME }}@${{ vars.RC_SSH_HOST }} \
|
||||
"TAG='$TAG' REGISTRY_TOKEN='$REGISTRY_TOKEN' bash -s" <<'DEPLOY_EOF'
|
||||
set -e
|
||||
echo 'SSH connected to RC environment'
|
||||
|
||||
if [ -z "$TAG" ]; then
|
||||
echo 'ERROR: TAG is empty; refusing to build an untagged image' >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
- name: Deploy (rc)
|
||||
HEALTH_FMT='{{.State.Health.Status}}'
|
||||
|
||||
echo 'Cleaning Docker build cache...'
|
||||
docker builder prune -af 2>/dev/null || true
|
||||
docker image prune -af 2>/dev/null || true
|
||||
|
||||
echo 'Pulling source...'
|
||||
SOURCE_DIR='${{ vars.RC_SOURCE_DIR }}'
|
||||
if [ ! -d "$SOURCE_DIR/.git" ]; then
|
||||
git clone -b rc https://x-access-token:${REGISTRY_TOKEN}@git.mokoconsulting.tech/${{ github.repository }}.git "$SOURCE_DIR"
|
||||
fi
|
||||
cd "$SOURCE_DIR"
|
||||
git remote set-url origin https://x-access-token:${REGISTRY_TOKEN}@git.mokoconsulting.tech/${{ github.repository }}.git 2>/dev/null || true
|
||||
git fetch origin rc
|
||||
git reset --hard origin/rc
|
||||
|
||||
echo "Building image: ${{ vars.RC_REGISTRY }}/${{ vars.RC_IMAGE }}:$TAG"
|
||||
docker build --no-cache --build-arg GOFLAGS='-p 1' \
|
||||
--tag "${{ vars.RC_REGISTRY }}/${{ vars.RC_IMAGE }}:$TAG" \
|
||||
-f Dockerfile .
|
||||
|
||||
echo 'Pushing to registry...'
|
||||
echo "$REGISTRY_TOKEN" | docker login ${{ vars.RC_REGISTRY }} -u ${{ vars.RC_REGISTRY_USER }} --password-stdin
|
||||
docker push "${{ vars.RC_REGISTRY }}/${{ vars.RC_IMAGE }}:$TAG"
|
||||
|
||||
echo 'Restarting RC container...'
|
||||
cd '${{ vars.RC_COMPOSE_DIR }}'
|
||||
# Drive the rc service image tag via its compose env-var (no sed on the shared
|
||||
# file); remove any lingering fixed-name container first, then force-recreate.
|
||||
docker rm -f '${{ vars.RC_CONTAINER }}' 2>/dev/null || true
|
||||
${{ vars.RC_TAG_ENV }}="$TAG" docker compose -p '${{ vars.RC_COMPOSE_PROJECT }}' up -d --force-recreate '${{ vars.RC_CONTAINER }}'
|
||||
|
||||
echo 'Health check...'
|
||||
for i in 1 2 3 4 5 6 7 8; do
|
||||
sleep 15
|
||||
if docker inspect --format="$HEALTH_FMT" '${{ vars.RC_CONTAINER }}' 2>/dev/null | grep -q healthy; then
|
||||
echo 'RC container healthy!'
|
||||
exit 0
|
||||
fi
|
||||
echo "Waiting... (attempt $i/8)"
|
||||
done
|
||||
echo 'Health check failed'
|
||||
docker logs '${{ vars.RC_CONTAINER }}' --tail 20
|
||||
exit 1
|
||||
DEPLOY_EOF
|
||||
|
||||
- name: Verify RC instance
|
||||
continue-on-error: true
|
||||
run: |
|
||||
php ${MOKO_CLI}/deploy.php --tier rc --tag "${{ steps.config.outputs.tag }}" \
|
||||
--ssh-host ${{ vars.RC_SSH_HOST }} --ssh-port ${{ vars.RC_SSH_PORT }} \
|
||||
--ssh-user ${{ vars.RC_SSH_USERNAME }} --ssh-key ~/.ssh/deploy_key
|
||||
sleep 5
|
||||
ssh -i ~/.ssh/deploy_key -p ${{ vars.RC_SSH_PORT }} -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null ${{ vars.RC_SSH_USERNAME }}@${{ vars.RC_SSH_HOST }} "curl -sf '${{ vars.RC_HEALTH_URL }}'" && echo " RC API healthy"
|
||||
|
||||
@@ -4,9 +4,9 @@
|
||||
#
|
||||
# FILE INFORMATION
|
||||
# DEFGROUP: MokoGIT.Workflow
|
||||
# INGROUP: MokoCLI.Security
|
||||
# REPO: https://git.mokoconsulting.tech/MokoConsulting/mokocli
|
||||
# PATH: /.mokogit/workflows/gitleaks.yml
|
||||
# INGROUP: MokoStandards.Security
|
||||
# REPO: https://git.mokoconsulting.tech/mokoconsulting-tech/MokoStandards-API
|
||||
# PATH: /templates/workflows/gitleaks.yml.template
|
||||
# VERSION: 01.00.00
|
||||
# BRIEF: Secret scanning — detect leaked credentials, API keys, and tokens
|
||||
#
|
||||
@@ -34,8 +34,7 @@ permissions:
|
||||
|
||||
env:
|
||||
NTFY_URL: ${{ vars.NTFY_URL || 'https://ntfy.mokoconsulting.tech' }}
|
||||
NTFY_TOPIC: ${{ vars.NTFY_TOPIC || 'mokogit-security' }}
|
||||
NTFY_TOKEN: ${{ secrets.NTFY_TOKEN }}
|
||||
NTFY_TOPIC: ${{ vars.NTFY_TOPIC || 'git-security' }}
|
||||
|
||||
jobs:
|
||||
gitleaks:
|
||||
@@ -90,5 +89,4 @@ jobs:
|
||||
-H "Tags: rotating_light,key" \
|
||||
-H "Priority: urgent" \
|
||||
-d "Gitleaks found potential secrets. Review and rotate credentials immediately." \
|
||||
-H "Authorization: Bearer ${NTFY_TOKEN}" \
|
||||
"${NTFY_URL}/${NTFY_TOPIC}" || true
|
||||
|
||||
@@ -4,8 +4,8 @@
|
||||
#
|
||||
# FILE INFORMATION
|
||||
# DEFGROUP: MokoGIT.Workflow
|
||||
# INGROUP: MokoCLI.Notifications
|
||||
# REPO: https://git.mokoconsulting.tech/MokoConsulting/mokocli
|
||||
# INGROUP: MokoStandards.Notifications
|
||||
# REPO: https://git.mokoconsulting.tech/MokoConsulting/MokoStandards
|
||||
# PATH: /.mokogit/workflows/notify.yml
|
||||
# VERSION: 01.00.00
|
||||
# BRIEF: Push notifications via ntfy on release success or workflow failure
|
||||
@@ -15,9 +15,9 @@ name: "Universal: Notifications"
|
||||
on:
|
||||
workflow_run:
|
||||
workflows:
|
||||
- "Universal: Build & Release"
|
||||
- "Joomla: Extension CI"
|
||||
- "Generic: Project CI"
|
||||
- "Joomla Build & Release"
|
||||
- "Joomla Extension CI"
|
||||
- "Deploy"
|
||||
types:
|
||||
- completed
|
||||
|
||||
@@ -26,8 +26,7 @@ permissions:
|
||||
|
||||
env:
|
||||
NTFY_URL: ${{ vars.NTFY_URL || 'https://ntfy.mokoconsulting.tech' }}
|
||||
NTFY_TOPIC: ${{ vars.NTFY_TOPIC || 'mokogit-releases' }}
|
||||
NTFY_TOKEN: ${{ secrets.NTFY_TOKEN }}
|
||||
NTFY_TOPIC: ${{ vars.NTFY_TOPIC || 'git-releases' }}
|
||||
|
||||
jobs:
|
||||
notify:
|
||||
@@ -47,14 +46,13 @@ jobs:
|
||||
WORKFLOW="${{ github.event.workflow_run.name }}"
|
||||
URL="${{ github.event.workflow_run.html_url }}"
|
||||
|
||||
curl -sS --retry 3 --retry-connrefused --retry-delay 2 --max-time 20 \
|
||||
curl -sS \
|
||||
-H "Title: ${REPO} released" \
|
||||
-H "Tags: white_check_mark,package" \
|
||||
-H "Priority: default" \
|
||||
-H "Click: ${URL}" \
|
||||
-d "${WORKFLOW} completed successfully." \
|
||||
-H "Authorization: Bearer ${NTFY_TOKEN}" \
|
||||
"${NTFY_URL}/${NTFY_TOPIC}" || echo "::warning::ntfy notification could not be delivered (non-fatal)"
|
||||
"${NTFY_URL}/${NTFY_TOPIC}"
|
||||
|
||||
- name: Notify on failure
|
||||
if: github.event.workflow_run.conclusion == 'failure'
|
||||
@@ -63,11 +61,10 @@ jobs:
|
||||
WORKFLOW="${{ github.event.workflow_run.name }}"
|
||||
URL="${{ github.event.workflow_run.html_url }}"
|
||||
|
||||
curl -sS --retry 3 --retry-connrefused --retry-delay 2 --max-time 20 \
|
||||
curl -sS \
|
||||
-H "Title: ${REPO} workflow failed" \
|
||||
-H "Tags: x,warning" \
|
||||
-H "Priority: high" \
|
||||
-H "Click: ${URL}" \
|
||||
-d "${WORKFLOW} failed. Check the run for details." \
|
||||
-H "Authorization: Bearer ${NTFY_TOKEN}" \
|
||||
"${NTFY_URL}/${NTFY_TOPIC}" || echo "::warning::ntfy notification could not be delivered (non-fatal)"
|
||||
"${NTFY_URL}/${NTFY_TOPIC}"
|
||||
|
||||
@@ -4,9 +4,9 @@
|
||||
#
|
||||
# FILE INFORMATION
|
||||
# DEFGROUP: MokoGIT.Workflow
|
||||
# INGROUP: MokoCLI.CI
|
||||
# REPO: https://git.mokoconsulting.tech/MokoConsulting/Template-Generic
|
||||
# PATH: /.mokogit/workflows/pr-check.yml
|
||||
# INGROUP: mokocli.CI
|
||||
# REPO: https://git.mokoconsulting.tech/mokoconsulting-tech/mokocli
|
||||
# PATH: /templates/workflows/universal/pr-check.yml.template
|
||||
# VERSION: 09.23.00
|
||||
# BRIEF: PR gate — branch policy + code validation before merge
|
||||
|
||||
@@ -47,15 +47,15 @@ jobs:
|
||||
fi
|
||||
;;
|
||||
fix/*|bugfix/*)
|
||||
if [ "$BASE" != "dev" ] && [ "$BASE" != "main" ]; then
|
||||
if [ "$BASE" != "dev" ]; then
|
||||
ALLOWED=false
|
||||
REASON="Fix branches must target 'dev' or 'main', not '${BASE}'"
|
||||
REASON="Fix branches must target 'dev', not '${BASE}'"
|
||||
fi
|
||||
;;
|
||||
patch/*)
|
||||
if [ "$BASE" != "dev" ] && [ "$BASE" != "rc" ] && [ "$BASE" != "main" ]; then
|
||||
if [ "$BASE" != "dev" ] && [ "$BASE" != "rc" ]; then
|
||||
ALLOWED=false
|
||||
REASON="Patch branches must target 'dev', 'rc', or 'main', not '${BASE}'"
|
||||
REASON="Patch branches must target 'dev' or 'rc', not '${BASE}'"
|
||||
fi
|
||||
;;
|
||||
hotfix/*)
|
||||
@@ -86,8 +86,7 @@ jobs:
|
||||
echo "" >> $GITHUB_STEP_SUMMARY
|
||||
echo "### Allowed merge paths:" >> $GITHUB_STEP_SUMMARY
|
||||
echo "- \`feature/*\` → \`dev\`" >> $GITHUB_STEP_SUMMARY
|
||||
echo "- \`fix/*\` → \`dev\` or \`main\`" >> $GITHUB_STEP_SUMMARY
|
||||
echo "- \`patch/*\` → \`dev\`, \`rc\`, or \`main\`" >> $GITHUB_STEP_SUMMARY
|
||||
echo "- \`fix/*\` → \`dev\`" >> $GITHUB_STEP_SUMMARY
|
||||
echo "- \`hotfix/*\` → \`dev\` or \`main\`" >> $GITHUB_STEP_SUMMARY
|
||||
echo "- \`dev\` → \`main\`" >> $GITHUB_STEP_SUMMARY
|
||||
echo "- \`rc/*\` → \`main\`" >> $GITHUB_STEP_SUMMARY
|
||||
@@ -97,80 +96,6 @@ jobs:
|
||||
echo "Branch policy: OK (${HEAD} → ${BASE})"
|
||||
echo "## Branch Policy: Passed" >> $GITHUB_STEP_SUMMARY
|
||||
|
||||
# ── Docs Update Gate (main PRs) ─────────────────────────────────────────
|
||||
require-docs:
|
||||
name: Require Docs Update
|
||||
runs-on: ubuntu-latest
|
||||
# Enforce only on PRs merging into main: README.md + CHANGELOG.md must both be updated.
|
||||
if: ${{ github.base_ref == 'main' }}
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v4
|
||||
with:
|
||||
fetch-depth: 0
|
||||
|
||||
- name: Require README.md and CHANGELOG.md in the PR diff
|
||||
run: |
|
||||
BASE="${{ github.event.pull_request.base.sha }}"
|
||||
HEAD="${{ github.event.pull_request.head.sha }}"
|
||||
CHANGED="$(git diff --name-only "$BASE" "$HEAD" 2>/dev/null || true)"
|
||||
if [ -z "$CHANGED" ]; then
|
||||
git fetch -q origin "${{ github.base_ref }}" 2>/dev/null || true
|
||||
CHANGED="$(git diff --name-only "origin/${{ github.base_ref }}...HEAD" 2>/dev/null || true)"
|
||||
fi
|
||||
echo "Changed files in PR:"
|
||||
echo "$CHANGED"
|
||||
MISSING=""
|
||||
echo "$CHANGED" | grep -qxE 'README\.md' || MISSING="README.md"
|
||||
echo "$CHANGED" | grep -qxE 'CHANGELOG\.md' || MISSING="${MISSING:+$MISSING, }CHANGELOG.md"
|
||||
if [ -n "$MISSING" ]; then
|
||||
echo "::error::PRs into main must update: ${MISSING}"
|
||||
{
|
||||
echo "## Docs Update Required"
|
||||
echo ""
|
||||
echo "PRs merging into \`main\` must update both **README.md** and **CHANGELOG.md**."
|
||||
echo ""
|
||||
echo "Not updated in this PR: **${MISSING}**"
|
||||
} >> "$GITHUB_STEP_SUMMARY"
|
||||
exit 1
|
||||
fi
|
||||
echo "Docs update present (README.md + CHANGELOG.md)"
|
||||
echo "## Docs Update: Passed" >> "$GITHUB_STEP_SUMMARY"
|
||||
|
||||
# ── Wiki Update Reminder (main PRs, non-blocking) ───────────────────────
|
||||
wiki-reminder:
|
||||
name: Wiki Update Reminder
|
||||
runs-on: ubuntu-latest
|
||||
if: ${{ github.base_ref == 'main' }}
|
||||
steps:
|
||||
- name: Remind to update the wiki
|
||||
env:
|
||||
TOKEN: ${{ secrets.MOKOGIT_TOKEN }}
|
||||
SERVER: ${{ vars.MOKOGIT_URL || 'https://git.mokoconsulting.tech' }}
|
||||
REPO: ${{ github.repository }}
|
||||
PR: ${{ github.event.pull_request.number }}
|
||||
run: |
|
||||
set -uo pipefail
|
||||
{
|
||||
echo "## Wiki Update Reminder"
|
||||
echo ""
|
||||
echo "Docs are **wiki-first** at MokoConsulting. If this change affects behavior, usage, configuration, or standards, update the repo wiki:"
|
||||
echo ""
|
||||
echo "- ${SERVER}/${REPO}/wiki"
|
||||
echo ""
|
||||
echo "_Non-blocking reminder._"
|
||||
} >> "$GITHUB_STEP_SUMMARY"
|
||||
# Post a single PR comment (idempotent via hidden marker); best-effort, never fails.
|
||||
API="${SERVER}/api/v1/repos/${REPO}/issues/${PR}/comments"
|
||||
if [ -n "${TOKEN:-}" ] && [ -n "${PR:-}" ]; then
|
||||
existing="$(curl -sf -H "Authorization: token ${TOKEN}" "$API" 2>/dev/null | grep -c 'wiki-reminder' || true)"
|
||||
if [ "${existing:-0}" -eq 0 ]; then
|
||||
curl -sf -H "Authorization: token ${TOKEN}" -H "Content-Type: application/json" -X POST "$API" \
|
||||
-d '{"body":"<!-- wiki-reminder -->\n\n**Wiki reminder:** docs are wiki-first -- if this PR changes behavior, usage, config, or standards, please update the repo wiki before/after merge. _(non-blocking)_"}' >/dev/null 2>&1 || true
|
||||
fi
|
||||
fi
|
||||
echo "Wiki reminder emitted (non-blocking)."
|
||||
|
||||
# ── Secret Scanning ──────────────────────────────────────────────────
|
||||
gitleaks:
|
||||
name: Secret Scan
|
||||
@@ -201,8 +126,6 @@ jobs:
|
||||
validate:
|
||||
name: Validate PR
|
||||
runs-on: ubuntu-latest
|
||||
# Skip on template repos (Template-*) — no real manifest/source/changelog to validate.
|
||||
if: ${{ !startsWith(github.event.repository.name, 'Template-') }}
|
||||
|
||||
steps:
|
||||
- name: Checkout
|
||||
@@ -210,7 +133,7 @@ jobs:
|
||||
|
||||
- name: Check for merge conflict markers
|
||||
run: |
|
||||
CONFLICTS=$(grep -rn '<<<<<<< \|>>>>>>> \|^=======$' --exclude-dir='.git' --exclude-dir='.mokogit' --include='*.php' --include='*.xml' --include='*.css' --include='*.js' --include='*.json' --include='*.md' --include='*.yml' --include='*.yaml' --include='*.ini' --include='*.txt' . 2>/dev/null | grep -v '.git/' || true)
|
||||
CONFLICTS=$(grep -rn '<<<<<<< \|>>>>>>> \|^=======$' --include='*.php' --include='*.xml' --include='*.css' --include='*.js' --include='*.json' --include='*.md' --include='*.yml' --include='*.yaml' --include='*.ini' --include='*.txt' . 2>/dev/null | grep -v '.git/' || true)
|
||||
if [ -n "$CONFLICTS" ]; then
|
||||
echo "::error::Merge conflict markers found in source files"
|
||||
echo "## Conflict Markers Found" >> $GITHUB_STEP_SUMMARY
|
||||
@@ -258,9 +181,8 @@ jobs:
|
||||
while IFS= read -r -d '' file; do
|
||||
# Skip vendor, node_modules, and index.html stub files
|
||||
case "$file" in ./vendor/*|./node_modules/*) continue ;; esac
|
||||
# Scan the whole file for the JEXEC/JPATH guard: it is placed after
|
||||
# the SPDX/file-header docblock, which commonly runs past 20 lines.
|
||||
if ! grep -qE "defined\s*\(\s*['\"](_JEXEC|JPATH_BASE|\\\\JPATH_PLATFORM)['\"]" "$file"; then
|
||||
# Check first 10 lines for JEXEC or JPATH guard
|
||||
if ! head -20 "$file" | grep -qE "defined\s*\(\s*['\"](_JEXEC|JPATH_BASE|\\\\JPATH_PLATFORM)['\"]"; then
|
||||
echo "::error file=${file}::Missing JEXEC guard: ${file}"
|
||||
ERRORS=$((ERRORS + 1))
|
||||
fi
|
||||
@@ -351,7 +273,7 @@ jobs:
|
||||
joomla)
|
||||
MANIFEST=$(find . -maxdepth 3 -name "*.xml" ! -path "./.git/*" -exec grep -l '<extension' {} \; 2>/dev/null | head -1)
|
||||
if [ -z "$MANIFEST" ]; then
|
||||
echo "::warning::No Joomla manifest found (MokoSuite site)"
|
||||
echo "::warning::No Joomla manifest found (WaaS site)"
|
||||
exit 0
|
||||
fi
|
||||
echo "Manifest: ${MANIFEST}"
|
||||
@@ -571,9 +493,6 @@ jobs:
|
||||
name: Build RC Package
|
||||
runs-on: ubuntu-latest
|
||||
needs: [branch-policy, validate]
|
||||
# Run only when both gates succeeded; always() forces evaluation so a skipped
|
||||
# validate (e.g. template repos) skips this job cleanly instead of hanging.
|
||||
if: ${{ always() && needs.branch-policy.result == 'success' && needs.validate.result == 'success' }}
|
||||
|
||||
steps:
|
||||
- name: Trigger RC pre-release
|
||||
|
||||
@@ -4,11 +4,11 @@
|
||||
#
|
||||
# FILE INFORMATION
|
||||
# DEFGROUP: MokoGIT.Workflow
|
||||
# INGROUP: MokoCLI.Release
|
||||
# REPO: https://git.mokoconsulting.tech/MokoConsulting/Template-Generic
|
||||
# PATH: /.mokogit/workflows/pre-release.yml
|
||||
# VERSION: 05.02.06
|
||||
# BRIEF: Auto pre-release on push to dev/alpha/beta/rc branches (shared engine: joomla-family + npm/mcp/client)
|
||||
# INGROUP: mokocli.Release
|
||||
# REPO: https://git.mokoconsulting.tech/MokoConsulting/mokocli
|
||||
# PATH: /templates/workflows/universal/pre-release.yml.template
|
||||
# VERSION: 05.02.00
|
||||
# BRIEF: Auto pre-release on push to dev/alpha/beta/rc branches
|
||||
|
||||
name: "Universal: Pre-Release"
|
||||
|
||||
@@ -48,13 +48,9 @@ jobs:
|
||||
build:
|
||||
name: "Build Pre-Release (${{ inputs.stability || github.ref_name }})"
|
||||
runs-on: release
|
||||
# Skip on template repos (Template-*) — they scaffold other repos and do not release.
|
||||
if: >-
|
||||
!startsWith(github.event.repository.name, 'Template-') &&
|
||||
(
|
||||
github.event_name == 'workflow_dispatch' ||
|
||||
github.event_name == 'push'
|
||||
)
|
||||
github.event_name == 'workflow_dispatch' ||
|
||||
github.event_name == 'push'
|
||||
|
||||
steps:
|
||||
- name: Checkout
|
||||
@@ -69,7 +65,7 @@ jobs:
|
||||
run: |
|
||||
git submodule foreach --quiet 'git checkout main && git pull --quiet origin main' 2>/dev/null || true
|
||||
|
||||
- name: Setup MokoCLI tools
|
||||
- name: Setup mokocli tools
|
||||
env:
|
||||
MOKO_CLONE_TOKEN: ${{ secrets.MOKOGIT_TOKEN }}
|
||||
MOKO_CLONE_HOST: git.mokoconsulting.tech/MokoConsulting
|
||||
@@ -93,114 +89,19 @@ jobs:
|
||||
- name: Detect platform
|
||||
id: platform
|
||||
run: |
|
||||
# Authoritative source of truth (#122): the repo's org-customizable
|
||||
# platform lives in the MokoGIT metadata API. Read it FIRST and, when
|
||||
# present, emit it as the single `platform` output. This avoids the
|
||||
# previous clobber where platform_detect.php + manifest_read.php both
|
||||
# appended `platform=` under this same id (last-write-wins), and where
|
||||
# manifest_read.php hit the removed /manifest route (404) and fell back
|
||||
# to generic autodetect — misclassifying an mcp repo as nodejs and
|
||||
# skipping the whole release.
|
||||
PLATFORM=$(curl -sf \
|
||||
-H "Authorization: token ${{ secrets.MOKOGIT_TOKEN }}" \
|
||||
"${GIT_URL}/api/v1/repos/${GIT_ORG}/${GIT_REPO}/metadata" \
|
||||
| python3 -c "import json,sys; print((json.load(sys.stdin).get('platform') or '').strip())" 2>/dev/null || true)
|
||||
# Auto-detect and update platform if not set in manifest
|
||||
php ${MOKO_CLI}/platform_detect.php --path . --github-output 2>/dev/null || true
|
||||
php ${MOKO_CLI}/manifest_read.php --path . --github-output
|
||||
|
||||
if [ -n "$PLATFORM" ]; then
|
||||
# Authoritative metadata wins — do NOT run the file-based detectors,
|
||||
# so nothing can overwrite this value in $GITHUB_OUTPUT.
|
||||
echo "platform=${PLATFORM}" >> "$GITHUB_OUTPUT"
|
||||
echo "::notice::Platform '${PLATFORM}' from authoritative metadata API"
|
||||
else
|
||||
# Fallback (metadata empty/unreachable): retain the existing
|
||||
# detection so repos without metadata still resolve a platform.
|
||||
echo "::notice::No metadata.platform — falling back to file-based detection"
|
||||
php ${MOKO_CLI}/platform_detect.php --path . --github-output 2>/dev/null || true
|
||||
php ${MOKO_CLI}/manifest_read.php --path . --github-output
|
||||
fi
|
||||
|
||||
- name: Check platform eligibility
|
||||
- name: Check platform eligibility (Joomla only)
|
||||
id: eligibility
|
||||
run: |
|
||||
# Shared release engine (#122): the pre-release path runs for every
|
||||
# artifact platform that produces releases — joomla (+ joomla-family
|
||||
# like dolibarr), npm, mcp, and client. Deploy-only platforms (go) are
|
||||
# EXCLUDED: they consume a tag but never bump/release here.
|
||||
#
|
||||
# is_joomla_family selects the Joomla/PHP-specific steps (manifest
|
||||
# element/zip resolution, release_package.php zip, updates.xml). Those
|
||||
# steps stay TRUE for the Joomla family so Joomla behavior is unchanged,
|
||||
# and are skipped for npm/mcp/client, which ride only the platform-
|
||||
# agnostic steps (version, tag, changelog, release-notes, release,
|
||||
# cascade). Build/publish stay in the platform shim (ADR #124).
|
||||
PLATFORM="${{ steps.platform.outputs.platform }}"
|
||||
IS_JOOMLA_FAMILY=false
|
||||
# STEP 1 — Authoritative baseline (unchanged): the hardcoded case gate
|
||||
# remains the source of truth for `proceed` and the default value of
|
||||
# is_joomla_family. Everything below (the registry lookup) is PURELY
|
||||
# ADDITIVE and can only *refine* is_joomla_family for a cleanly-matched
|
||||
# platform — it never flips `proceed`, never downgrades, and any
|
||||
# failure/absence leaves this decision exactly as it is today.
|
||||
case "$PLATFORM" in
|
||||
joomla*|dolibarr*)
|
||||
PROCEED=true
|
||||
IS_JOOMLA_FAMILY=true
|
||||
;;
|
||||
npm*|mcp*|client*)
|
||||
PROCEED=true
|
||||
;;
|
||||
*)
|
||||
PROCEED=false
|
||||
echo "::notice::Platform '$PLATFORM' — not an artifact release platform, skipping pre-release auto-bump"
|
||||
;;
|
||||
esac
|
||||
|
||||
# STEP 2 — Registry enhancement (#125): classify the Joomla family from
|
||||
# the live platform registry (GET /api/v1/platforms) so newly-registered
|
||||
# manifest/packaging platforms get correct family classification without
|
||||
# editing this workflow. We key on the registry `family` field: families
|
||||
# `joomla` and `dolibarr` are exactly the Joomla-style manifest/packaging
|
||||
# path (the manifest_element + release_package steps). We deliberately do
|
||||
# NOT key on `manifest_based`, because npm and mcp are also
|
||||
# manifest_based:true yet must ride the platform-agnostic path (family
|
||||
# `node`) — so `manifest_based` is ambiguous here and `family` is the
|
||||
# clean discriminator.
|
||||
#
|
||||
# Fail-safe contract: the curl is captured into a var (never allowed to
|
||||
# crash the step under set -e -o pipefail), the JSON is parsed with a
|
||||
# guarded python3 one-liner, and the result is only applied when it is
|
||||
# exactly "true"/"false". On ANY of {non-200, curl error, empty/malformed
|
||||
# JSON, parse failure, platform key absent} REGISTRY_FAMILY stays empty
|
||||
# and we keep the STEP 1 hardcoded value untouched.
|
||||
REGISTRY_JSON="$(curl -sf \
|
||||
-H "Authorization: token ${{ secrets.MOKOGIT_TOKEN }}" \
|
||||
"${GIT_URL}/api/v1/platforms" 2>/dev/null || true)"
|
||||
REGISTRY_FAMILY=""
|
||||
if [ -n "$REGISTRY_JSON" ]; then
|
||||
# Single physical line of python3 so we stay safely inside this YAML
|
||||
# block scalar (a column-0 continuation would terminate the scalar).
|
||||
# Emits exactly: "true" -> matched key, family joomla/dolibarr;
|
||||
# "false" -> matched key, some other family;
|
||||
# "" -> key absent (fall back to hardcoded).
|
||||
# On malformed/empty JSON the parse raises, 2>/dev/null hides the
|
||||
# traceback and the trailing "|| true" keeps set -e -o pipefail from
|
||||
# crashing the step, so REGISTRY_FAMILY stays "" and we fall back.
|
||||
REGISTRY_FAMILY="$(printf '%s' "$REGISTRY_JSON" | PLATFORM="$PLATFORM" python3 -c 'import json,os,sys; p=os.environ.get("PLATFORM",""); f=next((x.get("family","") for x in json.load(sys.stdin) if x.get("key")==p), None); sys.stdout.write("true" if f in ("joomla","dolibarr") else ("false" if f is not None else ""))' 2>/dev/null || true)"
|
||||
fi
|
||||
if [ "$REGISTRY_FAMILY" = "true" ]; then
|
||||
IS_JOOMLA_FAMILY=true
|
||||
echo "::notice::Registry classified '$PLATFORM' as Joomla family (via /api/v1/platforms)"
|
||||
elif [ "$REGISTRY_FAMILY" = "false" ]; then
|
||||
IS_JOOMLA_FAMILY=false
|
||||
echo "::notice::Registry classified '$PLATFORM' as non-Joomla family (via /api/v1/platforms)"
|
||||
if [[ "$PLATFORM" == joomla* ]] || [[ "$PLATFORM" == "joomla" ]]; then
|
||||
echo "proceed=true" >> "$GITHUB_OUTPUT"
|
||||
else
|
||||
echo "::notice::Registry lookup unavailable/absent for '$PLATFORM' — using hardcoded family classification"
|
||||
fi
|
||||
|
||||
echo "proceed=${PROCEED}" >> "$GITHUB_OUTPUT"
|
||||
echo "is_joomla_family=${IS_JOOMLA_FAMILY}" >> "$GITHUB_OUTPUT"
|
||||
if [ "$PROCEED" = "true" ]; then
|
||||
echo "::notice::Platform '$PLATFORM' eligible for pre-release (joomla_family=${IS_JOOMLA_FAMILY})"
|
||||
echo "proceed=false" >> "$GITHUB_OUTPUT"
|
||||
echo "::notice::Platform '$PLATFORM' — non-Joomla, skipping pre-release auto-bump"
|
||||
fi
|
||||
|
||||
- name: Resolve metadata and bump version
|
||||
@@ -257,28 +158,17 @@ jobs:
|
||||
git add -A
|
||||
git diff --cached --quiet || {
|
||||
git commit -m "chore(version): pre-release bump to ${VERSION} [skip ci]"
|
||||
# Push the bump commit, but do NOT fail the release if the target branch
|
||||
# is protected and the release identity is not on the push allowlist.
|
||||
# The build proceeds from the in-tree bumped version regardless; if the
|
||||
# push is rejected, the next run simply re-bumps from the same base.
|
||||
if ! git push origin HEAD 2>&1; then
|
||||
echo "::warning::Version-bump commit could not be pushed (protected branch?). Building from in-tree version ${VERSION} anyway."
|
||||
fi
|
||||
git push origin HEAD 2>&1
|
||||
}
|
||||
|
||||
# Auto-detect element via manifest_element.php (Joomla-family only:
|
||||
# element/manifest resolution is Joomla-specific). For npm/mcp/client
|
||||
# the generic fallback below derives ext_element/zip_name from the repo
|
||||
# name — no Joomla manifest is present or required.
|
||||
if [ "${{ steps.eligibility.outputs.is_joomla_family }}" = "true" ]; then
|
||||
php ${MOKO_CLI}/manifest_element.php \
|
||||
--path . --version "$VERSION" --stability "$STABILITY" \
|
||||
--repo "${GIT_REPO}" --github-output
|
||||
fi
|
||||
# Auto-detect element via manifest_element.php
|
||||
php ${MOKO_CLI}/manifest_element.php \
|
||||
--path . --version "$VERSION" --stability "$STABILITY" \
|
||||
--repo "${GIT_REPO}" --github-output
|
||||
|
||||
# Read back element outputs
|
||||
EXT_ELEMENT=$(grep '^ext_element=' "$GITHUB_OUTPUT" | tail -1 | cut -d= -f2 || true)
|
||||
ZIP_NAME=$(grep '^zip_name=' "$GITHUB_OUTPUT" | tail -1 | cut -d= -f2 || true)
|
||||
EXT_ELEMENT=$(grep '^ext_element=' "$GITHUB_OUTPUT" | tail -1 | cut -d= -f2)
|
||||
ZIP_NAME=$(grep '^zip_name=' "$GITHUB_OUTPUT" | tail -1 | cut -d= -f2)
|
||||
[ -z "$EXT_ELEMENT" ] && EXT_ELEMENT=$(echo "${GIT_REPO}" | tr '[:upper:]' '[:lower:]' | tr -d ' -')
|
||||
[ -z "$ZIP_NAME" ] && ZIP_NAME="${EXT_ELEMENT}-${VERSION}.zip"
|
||||
|
||||
@@ -310,11 +200,9 @@ jobs:
|
||||
VERSION="${{ steps.meta.outputs.version }}"
|
||||
API_BASE="${GIT_URL}/api/v1/repos/${GIT_ORG}/${GIT_REPO}"
|
||||
|
||||
# Extract [Unreleased] section via the shared mokocli command (#364 centralization).
|
||||
# Extract [Unreleased] section from changelog (everything between [Unreleased] and next ## heading)
|
||||
if [ -f "CHANGELOG.md" ]; then
|
||||
NOTES=$(php ${MOKO_CLI}/release_notes.php --path . --version Unreleased 2>/dev/null || true)
|
||||
# release_notes.php echoes "Release Unreleased" when the section is empty; normalize.
|
||||
[ "$NOTES" = "Release Unreleased" ] && NOTES=""
|
||||
NOTES=$(awk '/^## \[Unreleased\]/{found=1; next} /^## \[/{if(found) exit} found{print}' CHANGELOG.md)
|
||||
[ -z "$NOTES" ] && NOTES="Release ${VERSION}"
|
||||
else
|
||||
NOTES="Release ${VERSION}"
|
||||
@@ -341,14 +229,9 @@ jobs:
|
||||
echo "Release notes updated from CHANGELOG.md"
|
||||
fi
|
||||
|
||||
# Joomla-family only: mokocli release_package.php builds the extension zip
|
||||
# (+ sha256, attach). npm/mcp/client package/publish in their platform shim
|
||||
# (trust boundary, ADR #124), so this PHP zip step is skipped for them.
|
||||
- name: Build package and upload
|
||||
id: package
|
||||
if: >-
|
||||
steps.eligibility.outputs.proceed == 'true' &&
|
||||
steps.eligibility.outputs.is_joomla_family == 'true'
|
||||
if: steps.eligibility.outputs.proceed == 'true'
|
||||
run: |
|
||||
VERSION="${{ steps.meta.outputs.version }}"
|
||||
TAG="${{ steps.meta.outputs.tag }}"
|
||||
@@ -387,4 +270,4 @@ jobs:
|
||||
echo "| Version | \`${VERSION}\` |" >> $GITHUB_STEP_SUMMARY
|
||||
echo "| Channel | ${STABILITY} |" >> $GITHUB_STEP_SUMMARY
|
||||
echo "| Package | \`${ZIP_NAME}\` |" >> $GITHUB_STEP_SUMMARY
|
||||
echo "| SHA-256 | \`${SHA256:-n/a}\` |" >> $GITHUB_STEP_SUMMARY
|
||||
echo "| SHA-256 | \`${SHA256:-n/a}\` |" >> $GITHUB_STEP_SUMMARY
|
||||
|
||||
@@ -1,43 +0,0 @@
|
||||
# +========================================================================+
|
||||
# | Copyright (C) 2026 Moko Consulting <hello@mokoconsulting.tech> |
|
||||
# | SPDX-License-Identifier: GPL-3.0-or-later |
|
||||
# | |
|
||||
# | BRIEF: Clean, formatted ntfy notification on push to a default branch. |
|
||||
# | Issues use an org-level webhook; releases use notify.yml. |
|
||||
# +========================================================================+
|
||||
name: "Universal: Push Notifications"
|
||||
|
||||
on:
|
||||
push:
|
||||
branches: [main, master]
|
||||
|
||||
permissions:
|
||||
contents: read
|
||||
|
||||
env:
|
||||
NTFY_URL: ${{ vars.NTFY_URL || 'https://ntfy.mokoconsulting.tech' }}
|
||||
NTFY_TOKEN: ${{ secrets.NTFY_TOKEN }}
|
||||
|
||||
jobs:
|
||||
push-notify:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Notify push
|
||||
# Untrusted values (commit message, actor) passed via env — never
|
||||
# interpolated directly into the shell — to avoid command injection.
|
||||
env:
|
||||
REPO: ${{ github.repository }}
|
||||
BRANCH: ${{ github.ref_name }}
|
||||
ACTOR: ${{ github.actor }}
|
||||
MSG: ${{ github.event.head_commit.message }}
|
||||
CLICK: ${{ github.server_url }}/${{ github.repository }}/commit/${{ github.sha }}
|
||||
run: |
|
||||
SUMMARY=$(printf '%s\n' "$MSG" | head -n1)
|
||||
curl -sS --retry 3 --retry-connrefused --retry-delay 2 --max-time 20 \
|
||||
-H "Title: ${REPO}: push to ${BRANCH}" \
|
||||
-H "Tags: package" \
|
||||
-H "Priority: default" \
|
||||
-H "Click: ${CLICK}" \
|
||||
-H "Authorization: Bearer ${NTFY_TOKEN}" \
|
||||
-d "${ACTOR}: ${SUMMARY}" \
|
||||
"${NTFY_URL}/mokogit-push" || echo "::warning::ntfy notification could not be delivered (non-fatal)"
|
||||
@@ -4,8 +4,8 @@
|
||||
#
|
||||
# FILE INFORMATION
|
||||
# DEFGROUP: MokoGIT.Workflow
|
||||
# INGROUP: MokoCLI.Universal
|
||||
# REPO: https://git.mokoconsulting.tech/MokoConsulting/Template-Generic
|
||||
# INGROUP: mokocli.Universal
|
||||
# REPO: https://git.mokoconsulting.tech/MokoConsulting/mokocli
|
||||
# PATH: /.mokogit/workflows/rc-revert.yml
|
||||
# VERSION: 09.23.00
|
||||
# BRIEF: Rename rc/ branch back to dev/ when PR is closed without merge
|
||||
@@ -25,8 +25,7 @@ jobs:
|
||||
runs-on: ubuntu-latest
|
||||
if: >-
|
||||
github.event.pull_request.merged == false &&
|
||||
startsWith(github.event.pull_request.head.ref, 'rc/') &&
|
||||
!startsWith(github.event.repository.name, 'Template-')
|
||||
startsWith(github.event.pull_request.head.ref, 'rc/')
|
||||
|
||||
steps:
|
||||
- name: Rename branch
|
||||
|
||||
@@ -7,9 +7,9 @@
|
||||
#
|
||||
# FILE INFORMATION
|
||||
# DEFGROUP: MokoGIT.Workflow
|
||||
# INGROUP: MokoCLI.Validation
|
||||
# REPO: https://git.mokoconsulting.tech/MokoConsulting/Template-Generic
|
||||
# PATH: /.mokogit/workflows/repo-health.yml
|
||||
# INGROUP: mokocli.Validation
|
||||
# REPO: https://git.mokoconsulting.tech/mokoconsulting-tech/mokocli
|
||||
# PATH: /templates/workflows/joomla/repo_health.yml.template
|
||||
# VERSION: 09.23.00
|
||||
# BRIEF: Enforces repository guardrails by validating scripts governance, tooling availability, and core repository health artifacts.
|
||||
# ============================================================================
|
||||
|
||||
@@ -0,0 +1,96 @@
|
||||
# Copyright (C) 2026 Moko Consulting <hello@mokoconsulting.tech>
|
||||
#
|
||||
# SPDX-License-Identifier: GPL-3.0-or-later
|
||||
#
|
||||
# FILE INFORMATION
|
||||
# DEFGROUP: MokoGIT.Workflow
|
||||
# INGROUP: MokoGIT
|
||||
# REPO: https://git.mokoconsulting.tech/MokoConsulting/MokoGIT
|
||||
# PATH: /.mokogit/workflows/sync-mokoonyx-theme.yml
|
||||
# VERSION: 01.00.00
|
||||
# BRIEF: Import MokoOnyx template CSS + standard light/dark themes into the web UI
|
||||
# theme layer on every push to dev/main (and on demand). MokoGIT-specific
|
||||
# (only this repo has a web UI to theme), so it is NOT a Template-* concern.
|
||||
|
||||
name: "MokoGIT: Sync MokoOnyx Theme"
|
||||
|
||||
on:
|
||||
workflow_dispatch:
|
||||
push:
|
||||
branches:
|
||||
- dev
|
||||
- main
|
||||
|
||||
concurrency:
|
||||
group: mokoonyx-theme-sync-${{ github.ref_name }}
|
||||
cancel-in-progress: false
|
||||
|
||||
jobs:
|
||||
sync:
|
||||
name: Vendor MokoOnyx theme CSS
|
||||
runs-on: ubuntu-latest
|
||||
# [skip ci] on the sync commit prevents this job from re-triggering itself.
|
||||
if: ${{ !contains(github.event.head_commit.message, '[skip ci]') }}
|
||||
steps:
|
||||
- name: Checkout MokoGIT (pushed branch, with push token)
|
||||
uses: actions/checkout@v4
|
||||
with:
|
||||
ref: ${{ github.ref_name }}
|
||||
token: ${{ secrets.MOKOGIT_TOKEN }}
|
||||
fetch-depth: 0
|
||||
|
||||
- name: Clone MokoOnyx (source of truth for the site design)
|
||||
env:
|
||||
MOKOGIT_TOKEN: ${{ secrets.MOKOGIT_TOKEN }}
|
||||
run: |
|
||||
MOKOGIT_URL="${{ vars.GITEA_URL || 'https://git.mokoconsulting.tech' }}"
|
||||
ORG="${{ vars.GITEA_ORG || github.repository_owner }}"
|
||||
git clone --depth 1 "${MOKOGIT_URL}/${ORG}/MokoOnyx.git" /tmp/mokoonyx
|
||||
|
||||
- name: Vendor template CSS + standard/custom themes
|
||||
run: |
|
||||
set -euo pipefail
|
||||
DEST="web_src/css/vendor/mokoonyx"
|
||||
SRC="/tmp/mokoonyx/source"
|
||||
mkdir -p "$DEST"
|
||||
# Raw, verbatim vendored assets (provenance kept; template.css is the full
|
||||
# Bootstrap bundle — vendored for reference, NOT bundled into the UI).
|
||||
cp "$SRC/media/css/template.css" "$DEST/template.css"
|
||||
cp "$SRC/media/css/theme/light.standard.css" "$DEST/light.standard.css"
|
||||
cp "$SRC/media/css/theme/dark.standard.css" "$DEST/dark.standard.css"
|
||||
cp "$SRC/templates/light.custom.css" "$DEST/light.custom.css"
|
||||
cp "$SRC/templates/dark.custom.css" "$DEST/dark.custom.css"
|
||||
|
||||
- name: Extract tokens-only, re-scoped to :root (safe to @import)
|
||||
run: |
|
||||
set -euo pipefail
|
||||
DEST="web_src/css/vendor/mokoonyx"
|
||||
# MokoOnyx custom.css mixes :root[data-bs-theme="X"] token blocks with
|
||||
# Bootstrap component classes (.btn*, etc). We extract ONLY the token block
|
||||
# and rewrite the Bootstrap data-bs-theme selector to :root so the tokens
|
||||
# apply inside the (single) active Gitea theme file — and no Bootstrap
|
||||
# component classes leak in to collide with Fomantic UI.
|
||||
for t in light dark; do
|
||||
awk -v t="$t" '
|
||||
/:root\[data-bs-theme=/ {print "/* Auto-extracted from vendor/mokoonyx/"t".custom.css :root[data-bs-theme] — re-scoped to :root. DO NOT hand-edit. */"; print ":root {"; f=1; next}
|
||||
f && /^\}/ {print "}"; f=0; next}
|
||||
f {print}
|
||||
' "$DEST/$t.custom.css" > "$DEST/$t.tokens.css"
|
||||
done
|
||||
|
||||
- name: Commit if changed
|
||||
env:
|
||||
MOKOGIT_TOKEN: ${{ secrets.MOKOGIT_TOKEN }}
|
||||
run: |
|
||||
set -euo pipefail
|
||||
git config user.name "git-actions[bot]"
|
||||
git config user.email "git-actions[bot]@mokoconsulting.tech"
|
||||
git add web_src/css/vendor/mokoonyx
|
||||
if git diff --cached --quiet; then
|
||||
echo "MokoOnyx theme CSS already up to date — nothing to commit."
|
||||
exit 0
|
||||
fi
|
||||
git commit -m "chore(theme): sync MokoOnyx theme CSS [skip ci]
|
||||
|
||||
Authored-by: Moko Consulting"
|
||||
git push origin "HEAD:${{ github.ref_name }}"
|
||||
@@ -4,7 +4,7 @@
|
||||
#
|
||||
# FILE INFORMATION
|
||||
# DEFGROUP: MokoGIT.Workflow.Template
|
||||
# INGROUP: MokoCLI.CI
|
||||
# INGROUP: MokoStandards.CI
|
||||
# REPO: https://git.mokoconsulting.tech/MokoConsulting/Template-Joomla
|
||||
# PATH: /.mokogit/workflows/version-set.yml
|
||||
# VERSION: 01.00.00
|
||||
@@ -34,7 +34,6 @@ jobs:
|
||||
set-version:
|
||||
name: Set Version to ${{ inputs.version }}
|
||||
runs-on: ubuntu-latest
|
||||
if: ${{ !startsWith(github.event.repository.name, 'Template-') }}
|
||||
|
||||
steps:
|
||||
- name: Validate version format
|
||||
|
||||
+6
-6
@@ -28,7 +28,7 @@ RUN go mod download
|
||||
COPY --exclude=.git/ . .
|
||||
COPY --from=frontend-build /src/public/assets public/assets
|
||||
|
||||
# Build mokogit, .git mount is required for version data
|
||||
# Build gitea, .git mount is required for version data
|
||||
# GOFLAGS=-p 1 serializes compilation to prevent OOM on low-memory servers
|
||||
ARG GOFLAGS="-p 1"
|
||||
RUN --mount=type=cache,target="/root/.cache/go-build" \
|
||||
@@ -40,12 +40,12 @@ COPY docker/root /tmp/local
|
||||
# Set permissions for builds that made under windows which strips the executable bit from file
|
||||
RUN chmod 755 /tmp/local/usr/bin/entrypoint \
|
||||
/tmp/local/usr/local/bin/* \
|
||||
/tmp/local/etc/s6/mokogit/* \
|
||||
/tmp/local/etc/s6/gitea/* \
|
||||
/tmp/local/etc/s6/openssh/* \
|
||||
/tmp/local/etc/s6/.s6-svscan/* \
|
||||
/go/src/code.mokoconsulting.tech/MokoConsulting/MokoGIT/mokogit
|
||||
/go/src/code.mokoconsulting.tech/MokoConsulting/MokoGIT/gitea
|
||||
|
||||
FROM docker.io/library/alpine:3.23 AS mokogit
|
||||
FROM docker.io/library/alpine:3.23 AS gitea
|
||||
|
||||
EXPOSE 22 3000
|
||||
|
||||
@@ -75,13 +75,13 @@ RUN addgroup \
|
||||
echo "git:*" | chpasswd -e
|
||||
|
||||
COPY --from=build-env /tmp/local /
|
||||
COPY --from=build-env /go/src/code.mokoconsulting.tech/MokoConsulting/MokoGIT/mokogit /app/mokogit/mokogit
|
||||
COPY --from=build-env /go/src/code.mokoconsulting.tech/MokoConsulting/MokoGIT/gitea /app/gitea/gitea
|
||||
|
||||
# Disable openssh s6 service — we use external SSH (port 2222 via host).
|
||||
RUN printf '#!/bin/sh\nexec sleep infinity\n' > /etc/s6/openssh/run && chmod 755 /etc/s6/openssh/run
|
||||
|
||||
ENV USER=git
|
||||
ENV MOKOGIT_CUSTOM=/data/mokogit
|
||||
ENV GITEA_CUSTOM=/data/gitea
|
||||
|
||||
VOLUME ["/data"]
|
||||
|
||||
|
||||
+16
-16
@@ -21,14 +21,14 @@ RUN apk --no-cache add \
|
||||
build-base \
|
||||
git
|
||||
|
||||
WORKDIR ${GOPATH}/src/code.mokoconsulting.tech/MokoConsulting/MokoGIT
|
||||
WORKDIR ${GOPATH}/src/code.gitea.io/gitea
|
||||
COPY go.mod go.sum ./
|
||||
RUN go mod download
|
||||
# See the comments in Dockerfile
|
||||
COPY --exclude=.git/ . .
|
||||
COPY --from=frontend-build /src/public/assets public/assets
|
||||
|
||||
# Build mokogit, .git mount is required for version data
|
||||
# Build gitea, .git mount is required for version data
|
||||
RUN --mount=type=cache,target="/root/.cache/go-build" \
|
||||
--mount=type=bind,source=".git/",target=".git/" \
|
||||
make backend
|
||||
@@ -37,9 +37,9 @@ COPY docker/rootless /tmp/local
|
||||
|
||||
# Set permissions for builds that made under windows which strips the executable bit from file
|
||||
RUN chmod 755 /tmp/local/usr/local/bin/* \
|
||||
/go/src/code.mokoconsulting.tech/MokoConsulting/MokoGIT/mokogit
|
||||
/go/src/code.gitea.io/gitea/gitea
|
||||
|
||||
FROM docker.io/library/alpine:3.23 AS mokogit-rootless
|
||||
FROM docker.io/library/alpine:3.23 AS gitea-rootless
|
||||
|
||||
EXPOSE 2222 3000
|
||||
|
||||
@@ -58,30 +58,30 @@ RUN addgroup \
|
||||
git && \
|
||||
adduser \
|
||||
-S -H -D \
|
||||
-h /var/lib/mokogit/git \
|
||||
-h /var/lib/gitea/git \
|
||||
-s /bin/bash \
|
||||
-u 1000 \
|
||||
-G git \
|
||||
git
|
||||
|
||||
RUN mkdir -p /var/lib/mokogit /etc/mokogit
|
||||
RUN chown git:git /var/lib/mokogit /etc/mokogit
|
||||
RUN mkdir -p /var/lib/gitea /etc/gitea
|
||||
RUN chown git:git /var/lib/gitea /etc/gitea
|
||||
|
||||
COPY --from=build-env /tmp/local /
|
||||
COPY --from=build-env --chown=root:root /go/src/code.mokoconsulting.tech/MokoConsulting/MokoGIT/mokogit /app/mokogit/mokogit
|
||||
COPY --from=build-env --chown=root:root /go/src/code.gitea.io/gitea/gitea /app/gitea/gitea
|
||||
|
||||
# git:git
|
||||
USER 1000:1000
|
||||
ENV MOKOGIT_WORK_DIR=/var/lib/mokogit
|
||||
ENV MOKOGIT_CUSTOM=/var/lib/mokogit/custom
|
||||
ENV MOKOGIT_TEMP=/tmp/mokogit
|
||||
ENV TMPDIR=/tmp/mokogit
|
||||
ENV GITEA_WORK_DIR=/var/lib/gitea
|
||||
ENV GITEA_CUSTOM=/var/lib/gitea/custom
|
||||
ENV GITEA_TEMP=/tmp/gitea
|
||||
ENV TMPDIR=/tmp/gitea
|
||||
|
||||
# TODO add to docs the ability to define the ini to load (useful to test and revert a config)
|
||||
ENV MOKOGIT_APP_INI=/etc/mokogit/app.ini
|
||||
ENV HOME="/var/lib/mokogit/git"
|
||||
VOLUME ["/var/lib/mokogit", "/etc/mokogit"]
|
||||
WORKDIR /var/lib/mokogit
|
||||
ENV GITEA_APP_INI=/etc/gitea/app.ini
|
||||
ENV HOME="/var/lib/gitea/git"
|
||||
VOLUME ["/var/lib/gitea", "/etc/gitea"]
|
||||
WORKDIR /var/lib/gitea
|
||||
|
||||
# HINT: HEALTH-CHECK-ENDPOINT: don't use HEALTHCHECK, search this hint keyword for more information
|
||||
ENTRYPOINT ["/usr/bin/dumb-init", "--", "/usr/local/bin/docker-entrypoint.sh"]
|
||||
|
||||
@@ -1,699 +1,3 @@
|
||||
MokoGIT — Licensing
|
||||
|
||||
MokoGIT is a derivative work of Gitea (https://about.gitea.com), which is licensed
|
||||
under the MIT License. Portions of this software derived from Gitea and Gogs remain
|
||||
under the MIT License and their original copyright notices are retained (see the MIT
|
||||
License section below). Moko Consulting's original contributions, and the combined
|
||||
work as a whole, are distributed under the GNU General Public License, version 3 or
|
||||
later (GPL-3.0-or-later).
|
||||
|
||||
The authoritative license for any individual source file is its per-file
|
||||
SPDX-License-Identifier header. Third-party and vendored assets are covered by
|
||||
THIRD-PARTY-NOTICES.md.
|
||||
|
||||
================================================================================
|
||||
GNU GENERAL PUBLIC LICENSE (Version 3, 29 June 2007) — applies to the combined work
|
||||
================================================================================
|
||||
|
||||
GNU GENERAL PUBLIC LICENSE
|
||||
Version 3, 29 June 2007
|
||||
|
||||
Copyright (C) 2007 Free Software Foundation, Inc. <https://fsf.org/>
|
||||
Everyone is permitted to copy and distribute verbatim copies
|
||||
of this license document, but changing it is not allowed.
|
||||
|
||||
Preamble
|
||||
|
||||
The GNU General Public License is a free, copyleft license for
|
||||
software and other kinds of works.
|
||||
|
||||
The licenses for most software and other practical works are designed
|
||||
to take away your freedom to share and change the works. By contrast,
|
||||
the GNU General Public License is intended to guarantee your freedom to
|
||||
share and change all versions of a program--to make sure it remains free
|
||||
software for all its users. We, the Free Software Foundation, use the
|
||||
GNU General Public License for most of our software; it applies also to
|
||||
any other work released this way by its authors. You can apply it to
|
||||
your programs, too.
|
||||
|
||||
When we speak of free software, we are referring to freedom, not
|
||||
price. Our General Public Licenses are designed to make sure that you
|
||||
have the freedom to distribute copies of free software (and charge for
|
||||
them if you wish), that you receive source code or can get it if you
|
||||
want it, that you can change the software or use pieces of it in new
|
||||
free programs, and that you know you can do these things.
|
||||
|
||||
To protect your rights, we need to prevent others from denying you
|
||||
these rights or asking you to surrender the rights. Therefore, you have
|
||||
certain responsibilities if you distribute copies of the software, or if
|
||||
you modify it: responsibilities to respect the freedom of others.
|
||||
|
||||
For example, if you distribute copies of such a program, whether
|
||||
gratis or for a fee, you must pass on to the recipients the same
|
||||
freedoms that you received. You must make sure that they, too, receive
|
||||
or can get the source code. And you must show them these terms so they
|
||||
know their rights.
|
||||
|
||||
Developers that use the GNU GPL protect your rights with two steps:
|
||||
(1) assert copyright on the software, and (2) offer you this License
|
||||
giving you legal permission to copy, distribute and/or modify it.
|
||||
|
||||
For the developers' and authors' protection, the GPL clearly explains
|
||||
that there is no warranty for this free software. For both users' and
|
||||
authors' sake, the GPL requires that modified versions be marked as
|
||||
changed, so that their problems will not be attributed erroneously to
|
||||
authors of previous versions.
|
||||
|
||||
Some devices are designed to deny users access to install or run
|
||||
modified versions of the software inside them, although the manufacturer
|
||||
can do so. This is fundamentally incompatible with the aim of
|
||||
protecting users' freedom to change the software. The systematic
|
||||
pattern of such abuse occurs in the area of products for individuals to
|
||||
use, which is precisely where it is most unacceptable. Therefore, we
|
||||
have designed this version of the GPL to prohibit the practice for those
|
||||
products. If such problems arise substantially in other domains, we
|
||||
stand ready to extend this provision to those domains in future versions
|
||||
of the GPL, as needed to protect the freedom of users.
|
||||
|
||||
Finally, every program is threatened constantly by software patents.
|
||||
States should not allow patents to restrict development and use of
|
||||
software on general-purpose computers, but in those that do, we wish to
|
||||
avoid the special danger that patents applied to a free program could
|
||||
make it effectively proprietary. To prevent this, the GPL assures that
|
||||
patents cannot be used to render the program non-free.
|
||||
|
||||
The precise terms and conditions for copying, distribution and
|
||||
modification follow.
|
||||
|
||||
TERMS AND CONDITIONS
|
||||
|
||||
0. Definitions.
|
||||
|
||||
"This License" refers to version 3 of the GNU General Public License.
|
||||
|
||||
"Copyright" also means copyright-like laws that apply to other kinds of
|
||||
works, such as semiconductor masks.
|
||||
|
||||
"The Program" refers to any copyrightable work licensed under this
|
||||
License. Each licensee is addressed as "you". "Licensees" and
|
||||
"recipients" may be individuals or organizations.
|
||||
|
||||
To "modify" a work means to copy from or adapt all or part of the work
|
||||
in a fashion requiring copyright permission, other than the making of an
|
||||
exact copy. The resulting work is called a "modified version" of the
|
||||
earlier work or a work "based on" the earlier work.
|
||||
|
||||
A "covered work" means either the unmodified Program or a work based
|
||||
on the Program.
|
||||
|
||||
To "propagate" a work means to do anything with it that, without
|
||||
permission, would make you directly or secondarily liable for
|
||||
infringement under applicable copyright law, except executing it on a
|
||||
computer or modifying a private copy. Propagation includes copying,
|
||||
distribution (with or without modification), making available to the
|
||||
public, and in some countries other activities as well.
|
||||
|
||||
To "convey" a work means any kind of propagation that enables other
|
||||
parties to make or receive copies. Mere interaction with a user through
|
||||
a computer network, with no transfer of a copy, is not conveying.
|
||||
|
||||
An interactive user interface displays "Appropriate Legal Notices"
|
||||
to the extent that it includes a convenient and prominently visible
|
||||
feature that (1) displays an appropriate copyright notice, and (2)
|
||||
tells the user that there is no warranty for the work (except to the
|
||||
extent that warranties are provided), that licensees may convey the
|
||||
work under this License, and how to view a copy of this License. If
|
||||
the interface presents a list of user commands or options, such as a
|
||||
menu, a prominent item in the list meets this criterion.
|
||||
|
||||
1. Source Code.
|
||||
|
||||
The "source code" for a work means the preferred form of the work
|
||||
for making modifications to it. "Object code" means any non-source
|
||||
form of a work.
|
||||
|
||||
A "Standard Interface" means an interface that either is an official
|
||||
standard defined by a recognized standards body, or, in the case of
|
||||
interfaces specified for a particular programming language, one that
|
||||
is widely used among developers working in that language.
|
||||
|
||||
The "System Libraries" of an executable work include anything, other
|
||||
than the work as a whole, that (a) is included in the normal form of
|
||||
packaging a Major Component, but which is not part of that Major
|
||||
Component, and (b) serves only to enable use of the work with that
|
||||
Major Component, or to implement a Standard Interface for which an
|
||||
implementation is available to the public in source code form. A
|
||||
"Major Component", in this context, means a major essential component
|
||||
(kernel, window system, and so on) of the specific operating system
|
||||
(if any) on which the executable work runs, or a compiler used to
|
||||
produce the work, or an object code interpreter used to run it.
|
||||
|
||||
The "Corresponding Source" for a work in object code form means all
|
||||
the source code needed to generate, install, and (for an executable
|
||||
work) run the object code and to modify the work, including scripts to
|
||||
control those activities. However, it does not include the work's
|
||||
System Libraries, or general-purpose tools or generally available free
|
||||
programs which are used unmodified in performing those activities but
|
||||
which are not part of the work. For example, Corresponding Source
|
||||
includes interface definition files associated with source files for
|
||||
the work, and the source code for shared libraries and dynamically
|
||||
linked subprograms that the work is specifically designed to require,
|
||||
such as by intimate data communication or control flow between those
|
||||
subprograms and other parts of the work.
|
||||
|
||||
The Corresponding Source need not include anything that users
|
||||
can regenerate automatically from other parts of the Corresponding
|
||||
Source.
|
||||
|
||||
The Corresponding Source for a work in source code form is that
|
||||
same work.
|
||||
|
||||
2. Basic Permissions.
|
||||
|
||||
All rights granted under this License are granted for the term of
|
||||
copyright on the Program, and are irrevocable provided the stated
|
||||
conditions are met. This License explicitly affirms your unlimited
|
||||
permission to run the unmodified Program. The output from running a
|
||||
covered work is covered by this License only if the output, given its
|
||||
content, constitutes a covered work. This License acknowledges your
|
||||
rights of fair use or other equivalent, as provided by copyright law.
|
||||
|
||||
You may make, run and propagate covered works that you do not
|
||||
convey, without conditions so long as your license otherwise remains
|
||||
in force. You may convey covered works to others for the sole purpose
|
||||
of having them make modifications exclusively for you, or provide you
|
||||
with facilities for running those works, provided that you comply with
|
||||
the terms of this License in conveying all material for which you do
|
||||
not control copyright. Those thus making or running the covered works
|
||||
for you must do so exclusively on your behalf, under your direction
|
||||
and control, on terms that prohibit them from making any copies of
|
||||
your copyrighted material outside their relationship with you.
|
||||
|
||||
Conveying under any other circumstances is permitted solely under
|
||||
the conditions stated below. Sublicensing is not allowed; section 10
|
||||
makes it unnecessary.
|
||||
|
||||
3. Protecting Users' Legal Rights From Anti-Circumvention Law.
|
||||
|
||||
No covered work shall be deemed part of an effective technological
|
||||
measure under any applicable law fulfilling obligations under article
|
||||
11 of the WIPO copyright treaty adopted on 20 December 1996, or
|
||||
similar laws prohibiting or restricting circumvention of such
|
||||
measures.
|
||||
|
||||
When you convey a covered work, you waive any legal power to forbid
|
||||
circumvention of technological measures to the extent such circumvention
|
||||
is effected by exercising rights under this License with respect to
|
||||
the covered work, and you disclaim any intention to limit operation or
|
||||
modification of the work as a means of enforcing, against the work's
|
||||
users, your or third parties' legal rights to forbid circumvention of
|
||||
technological measures.
|
||||
|
||||
4. Conveying Verbatim Copies.
|
||||
|
||||
You may convey verbatim copies of the Program's source code as you
|
||||
receive it, in any medium, provided that you conspicuously and
|
||||
appropriately publish on each copy an appropriate copyright notice;
|
||||
keep intact all notices stating that this License and any
|
||||
non-permissive terms added in accord with section 7 apply to the code;
|
||||
keep intact all notices of the absence of any warranty; and give all
|
||||
recipients a copy of this License along with the Program.
|
||||
|
||||
You may charge any price or no price for each copy that you convey,
|
||||
and you may offer support or warranty protection for a fee.
|
||||
|
||||
5. Conveying Modified Source Versions.
|
||||
|
||||
You may convey a work based on the Program, or the modifications to
|
||||
produce it from the Program, in the form of source code under the
|
||||
terms of section 4, provided that you also meet all of these conditions:
|
||||
|
||||
a) The work must carry prominent notices stating that you modified
|
||||
it, and giving a relevant date.
|
||||
|
||||
b) The work must carry prominent notices stating that it is
|
||||
released under this License and any conditions added under section
|
||||
7. This requirement modifies the requirement in section 4 to
|
||||
"keep intact all notices".
|
||||
|
||||
c) You must license the entire work, as a whole, under this
|
||||
License to anyone who comes into possession of a copy. This
|
||||
License will therefore apply, along with any applicable section 7
|
||||
additional terms, to the whole of the work, and all its parts,
|
||||
regardless of how they are packaged. This License gives no
|
||||
permission to license the work in any other way, but it does not
|
||||
invalidate such permission if you have separately received it.
|
||||
|
||||
d) If the work has interactive user interfaces, each must display
|
||||
Appropriate Legal Notices; however, if the Program has interactive
|
||||
interfaces that do not display Appropriate Legal Notices, your
|
||||
work need not make them do so.
|
||||
|
||||
A compilation of a covered work with other separate and independent
|
||||
works, which are not by their nature extensions of the covered work,
|
||||
and which are not combined with it such as to form a larger program,
|
||||
in or on a volume of a storage or distribution medium, is called an
|
||||
"aggregate" if the compilation and its resulting copyright are not
|
||||
used to limit the access or legal rights of the compilation's users
|
||||
beyond what the individual works permit. Inclusion of a covered work
|
||||
in an aggregate does not cause this License to apply to the other
|
||||
parts of the aggregate.
|
||||
|
||||
6. Conveying Non-Source Forms.
|
||||
|
||||
You may convey a covered work in object code form under the terms
|
||||
of sections 4 and 5, provided that you also convey the
|
||||
machine-readable Corresponding Source under the terms of this License,
|
||||
in one of these ways:
|
||||
|
||||
a) Convey the object code in, or embodied in, a physical product
|
||||
(including a physical distribution medium), accompanied by the
|
||||
Corresponding Source fixed on a durable physical medium
|
||||
customarily used for software interchange.
|
||||
|
||||
b) Convey the object code in, or embodied in, a physical product
|
||||
(including a physical distribution medium), accompanied by a
|
||||
written offer, valid for at least three years and valid for as
|
||||
long as you offer spare parts or customer support for that product
|
||||
model, to give anyone who possesses the object code either (1) a
|
||||
copy of the Corresponding Source for all the software in the
|
||||
product that is covered by this License, on a durable physical
|
||||
medium customarily used for software interchange, for a price no
|
||||
more than your reasonable cost of physically performing this
|
||||
conveying of source, or (2) access to copy the
|
||||
Corresponding Source from a network server at no charge.
|
||||
|
||||
c) Convey individual copies of the object code with a copy of the
|
||||
written offer to provide the Corresponding Source. This
|
||||
alternative is allowed only occasionally and noncommercially, and
|
||||
only if you received the object code with such an offer, in accord
|
||||
with subsection 6b.
|
||||
|
||||
d) Convey the object code by offering access from a designated
|
||||
place (gratis or for a charge), and offer equivalent access to the
|
||||
Corresponding Source in the same way through the same place at no
|
||||
further charge. You need not require recipients to copy the
|
||||
Corresponding Source along with the object code. If the place to
|
||||
copy the object code is a network server, the Corresponding Source
|
||||
may be on a different server (operated by you or a third party)
|
||||
that supports equivalent copying facilities, provided you maintain
|
||||
clear directions next to the object code saying where to find the
|
||||
Corresponding Source. Regardless of what server hosts the
|
||||
Corresponding Source, you remain obligated to ensure that it is
|
||||
available for as long as needed to satisfy these requirements.
|
||||
|
||||
e) Convey the object code using peer-to-peer transmission, provided
|
||||
you inform other peers where the object code and Corresponding
|
||||
Source of the work are being offered to the general public at no
|
||||
charge under subsection 6d.
|
||||
|
||||
A separable portion of the object code, whose source code is excluded
|
||||
from the Corresponding Source as a System Library, need not be
|
||||
included in conveying the object code work.
|
||||
|
||||
A "User Product" is either (1) a "consumer product", which means any
|
||||
tangible personal property which is normally used for personal, family,
|
||||
or household purposes, or (2) anything designed or sold for incorporation
|
||||
into a dwelling. In determining whether a product is a consumer product,
|
||||
doubtful cases shall be resolved in favor of coverage. For a particular
|
||||
product received by a particular user, "normally used" refers to a
|
||||
typical or common use of that class of product, regardless of the status
|
||||
of the particular user or of the way in which the particular user
|
||||
actually uses, or expects or is expected to use, the product. A product
|
||||
is a consumer product regardless of whether the product has substantial
|
||||
commercial, industrial or non-consumer uses, unless such uses represent
|
||||
the only significant mode of use of the product.
|
||||
|
||||
"Installation Information" for a User Product means any methods,
|
||||
procedures, authorization keys, or other information required to install
|
||||
and execute modified versions of a covered work in that User Product from
|
||||
a modified version of its Corresponding Source. The information must
|
||||
suffice to ensure that the continued functioning of the modified object
|
||||
code is in no case prevented or interfered with solely because
|
||||
modification has been made.
|
||||
|
||||
If you convey an object code work under this section in, or with, or
|
||||
specifically for use in, a User Product, and the conveying occurs as
|
||||
part of a transaction in which the right of possession and use of the
|
||||
User Product is transferred to the recipient in perpetuity or for a
|
||||
fixed term (regardless of how the transaction is characterized), the
|
||||
Corresponding Source conveyed under this section must be accompanied
|
||||
by the Installation Information. But this requirement does not apply
|
||||
if neither you nor any third party retains the ability to install
|
||||
modified object code on the User Product (for example, the work has
|
||||
been installed in ROM).
|
||||
|
||||
The requirement to provide Installation Information does not include a
|
||||
requirement to continue to provide support service, warranty, or updates
|
||||
for a work that has been modified or installed by the recipient, or for
|
||||
the User Product in which it has been modified or installed. Access to a
|
||||
network may be denied when the modification itself materially and
|
||||
adversely affects the operation of the network or violates the rules and
|
||||
protocols for communication across the network.
|
||||
|
||||
Corresponding Source conveyed, and Installation Information provided,
|
||||
in accord with this section must be in a format that is publicly
|
||||
documented (and with an implementation available to the public in
|
||||
source code form), and must require no special password or key for
|
||||
unpacking, reading or copying.
|
||||
|
||||
7. Additional Terms.
|
||||
|
||||
"Additional permissions" are terms that supplement the terms of this
|
||||
License by making exceptions from one or more of its conditions.
|
||||
Additional permissions that are applicable to the entire Program shall
|
||||
be treated as though they were included in this License, to the extent
|
||||
that they are valid under applicable law. If additional permissions
|
||||
apply only to part of the Program, that part may be used separately
|
||||
under those permissions, but the entire Program remains governed by
|
||||
this License without regard to the additional permissions.
|
||||
|
||||
When you convey a copy of a covered work, you may at your option
|
||||
remove any additional permissions from that copy, or from any part of
|
||||
it. (Additional permissions may be written to require their own
|
||||
removal in certain cases when you modify the work.) You may place
|
||||
additional permissions on material, added by you to a covered work,
|
||||
for which you have or can give appropriate copyright permission.
|
||||
|
||||
Notwithstanding any other provision of this License, for material you
|
||||
add to a covered work, you may (if authorized by the copyright holders of
|
||||
that material) supplement the terms of this License with terms:
|
||||
|
||||
a) Disclaiming warranty or limiting liability differently from the
|
||||
terms of sections 15 and 16 of this License; or
|
||||
|
||||
b) Requiring preservation of specified reasonable legal notices or
|
||||
author attributions in that material or in the Appropriate Legal
|
||||
Notices displayed by works containing it; or
|
||||
|
||||
c) Prohibiting misrepresentation of the origin of that material, or
|
||||
requiring that modified versions of such material be marked in
|
||||
reasonable ways as different from the original version; or
|
||||
|
||||
d) Limiting the use for publicity purposes of names of licensors or
|
||||
authors of the material; or
|
||||
|
||||
e) Declining to grant rights under trademark law for use of some
|
||||
trade names, trademarks, or service marks; or
|
||||
|
||||
f) Requiring indemnification of licensors and authors of that
|
||||
material by anyone who conveys the material (or modified versions of
|
||||
it) with contractual assumptions of liability to the recipient, for
|
||||
any liability that these contractual assumptions directly impose on
|
||||
those licensors and authors.
|
||||
|
||||
All other non-permissive additional terms are considered "further
|
||||
restrictions" within the meaning of section 10. If the Program as you
|
||||
received it, or any part of it, contains a notice stating that it is
|
||||
governed by this License along with a term that is a further
|
||||
restriction, you may remove that term. If a license document contains
|
||||
a further restriction but permits relicensing or conveying under this
|
||||
License, you may add to a covered work material governed by the terms
|
||||
of that license document, provided that the further restriction does
|
||||
not survive such relicensing or conveying.
|
||||
|
||||
If you add terms to a covered work in accord with this section, you
|
||||
must place, in the relevant source files, a statement of the
|
||||
additional terms that apply to those files, or a notice indicating
|
||||
where to find the applicable terms.
|
||||
|
||||
Additional terms, permissive or non-permissive, may be stated in the
|
||||
form of a separately written license, or stated as exceptions;
|
||||
the above requirements apply either way.
|
||||
|
||||
8. Termination.
|
||||
|
||||
You may not propagate or modify a covered work except as expressly
|
||||
provided under this License. Any attempt otherwise to propagate or
|
||||
modify it is void, and will automatically terminate your rights under
|
||||
this License (including any patent licenses granted under the third
|
||||
paragraph of section 11).
|
||||
|
||||
However, if you cease all violation of this License, then your
|
||||
license from a particular copyright holder is reinstated (a)
|
||||
provisionally, unless and until the copyright holder explicitly and
|
||||
finally terminates your license, and (b) permanently, if the copyright
|
||||
holder fails to notify you of the violation by some reasonable means
|
||||
prior to 60 days after the cessation.
|
||||
|
||||
Moreover, your license from a particular copyright holder is
|
||||
reinstated permanently if the copyright holder notifies you of the
|
||||
violation by some reasonable means, this is the first time you have
|
||||
received notice of violation of this License (for any work) from that
|
||||
copyright holder, and you cure the violation prior to 30 days after
|
||||
your receipt of the notice.
|
||||
|
||||
Termination of your rights under this section does not terminate the
|
||||
licenses of parties who have received copies or rights from you under
|
||||
this License. If your rights have been terminated and not permanently
|
||||
reinstated, you do not qualify to receive new licenses for the same
|
||||
material under section 10.
|
||||
|
||||
9. Acceptance Not Required for Having Copies.
|
||||
|
||||
You are not required to accept this License in order to receive or
|
||||
run a copy of the Program. Ancillary propagation of a covered work
|
||||
occurring solely as a consequence of using peer-to-peer transmission
|
||||
to receive a copy likewise does not require acceptance. However,
|
||||
nothing other than this License grants you permission to propagate or
|
||||
modify any covered work. These actions infringe copyright if you do
|
||||
not accept this License. Therefore, by modifying or propagating a
|
||||
covered work, you indicate your acceptance of this License to do so.
|
||||
|
||||
10. Automatic Licensing of Downstream Recipients.
|
||||
|
||||
Each time you convey a covered work, the recipient automatically
|
||||
receives a license from the original licensors, to run, modify and
|
||||
propagate that work, subject to this License. You are not responsible
|
||||
for enforcing compliance by third parties with this License.
|
||||
|
||||
An "entity transaction" is a transaction transferring control of an
|
||||
organization, or substantially all assets of one, or subdividing an
|
||||
organization, or merging organizations. If propagation of a covered
|
||||
work results from an entity transaction, each party to that
|
||||
transaction who receives a copy of the work also receives whatever
|
||||
licenses to the work the party's predecessor in interest had or could
|
||||
give under the previous paragraph, plus a right to possession of the
|
||||
Corresponding Source of the work from the predecessor in interest, if
|
||||
the predecessor has it or can get it with reasonable efforts.
|
||||
|
||||
You may not impose any further restrictions on the exercise of the
|
||||
rights granted or affirmed under this License. For example, you may
|
||||
not impose a license fee, royalty, or other charge for exercise of
|
||||
rights granted under this License, and you may not initiate litigation
|
||||
(including a cross-claim or counterclaim in a lawsuit) alleging that
|
||||
any patent claim is infringed by making, using, selling, offering for
|
||||
sale, or importing the Program or any portion of it.
|
||||
|
||||
11. Patents.
|
||||
|
||||
A "contributor" is a copyright holder who authorizes use under this
|
||||
License of the Program or a work on which the Program is based. The
|
||||
work thus licensed is called the contributor's "contributor version".
|
||||
|
||||
A contributor's "essential patent claims" are all patent claims
|
||||
owned or controlled by the contributor, whether already acquired or
|
||||
hereafter acquired, that would be infringed by some manner, permitted
|
||||
by this License, of making, using, or selling its contributor version,
|
||||
but do not include claims that would be infringed only as a
|
||||
consequence of further modification of the contributor version. For
|
||||
purposes of this definition, "control" includes the right to grant
|
||||
patent sublicenses in a manner consistent with the requirements of
|
||||
this License.
|
||||
|
||||
Each contributor grants you a non-exclusive, worldwide, royalty-free
|
||||
patent license under the contributor's essential patent claims, to
|
||||
make, use, sell, offer for sale, import and otherwise run, modify and
|
||||
propagate the contents of its contributor version.
|
||||
|
||||
In the following three paragraphs, a "patent license" is any express
|
||||
agreement or commitment, however denominated, not to enforce a patent
|
||||
(such as an express permission to practice a patent or covenant not to
|
||||
sue for patent infringement). To "grant" such a patent license to a
|
||||
party means to make such an agreement or commitment not to enforce a
|
||||
patent against the party.
|
||||
|
||||
If you convey a covered work, knowingly relying on a patent license,
|
||||
and the Corresponding Source of the work is not available for anyone
|
||||
to copy, free of charge and under the terms of this License, through a
|
||||
publicly available network server or other readily accessible means,
|
||||
then you must either (1) cause the Corresponding Source to be so
|
||||
available, or (2) arrange to deprive yourself of the benefit of the
|
||||
patent license for this particular work, or (3) arrange, in a manner
|
||||
consistent with the requirements of this License, to extend the patent
|
||||
license to downstream recipients. "Knowingly relying" means you have
|
||||
actual knowledge that, but for the patent license, your conveying the
|
||||
covered work in a country, or your recipient's use of the covered work
|
||||
in a country, would infringe one or more identifiable patents in that
|
||||
country that you have reason to believe are valid.
|
||||
|
||||
If, pursuant to or in connection with a single transaction or
|
||||
arrangement, you convey, or propagate by procuring conveyance of, a
|
||||
covered work, and grant a patent license to some of the parties
|
||||
receiving the covered work authorizing them to use, propagate, modify
|
||||
or convey a specific copy of the covered work, then the patent license
|
||||
you grant is automatically extended to all recipients of the covered
|
||||
work and works based on it.
|
||||
|
||||
A patent license is "discriminatory" if it does not include within
|
||||
the scope of its coverage, prohibits the exercise of, or is
|
||||
conditioned on the non-exercise of one or more of the rights that are
|
||||
specifically granted under this License. You may not convey a covered
|
||||
work if you are a party to an arrangement with a third party that is
|
||||
in the business of distributing software, under which you make payment
|
||||
to the third party based on the extent of your activity of conveying
|
||||
the work, and under which the third party grants, to any of the
|
||||
parties who would receive the covered work from you, a discriminatory
|
||||
patent license (a) in connection with copies of the covered work
|
||||
conveyed by you (or copies made from those copies), or (b) primarily
|
||||
for and in connection with specific products or compilations that
|
||||
contain the covered work, unless you entered into that arrangement,
|
||||
or that patent license was granted, prior to 28 March 2007.
|
||||
|
||||
Nothing in this License shall be construed as excluding or limiting
|
||||
any implied license or other defenses to infringement that may
|
||||
otherwise be available to you under applicable patent law.
|
||||
|
||||
12. No Surrender of Others' Freedom.
|
||||
|
||||
If conditions are imposed on you (whether by court order, agreement or
|
||||
otherwise) that contradict the conditions of this License, they do not
|
||||
excuse you from the conditions of this License. If you cannot convey a
|
||||
covered work so as to satisfy simultaneously your obligations under this
|
||||
License and any other pertinent obligations, then as a consequence you may
|
||||
not convey it at all. For example, if you agree to terms that obligate you
|
||||
to collect a royalty for further conveying from those to whom you convey
|
||||
the Program, the only way you could satisfy both those terms and this
|
||||
License would be to refrain entirely from conveying the Program.
|
||||
|
||||
13. Use with the GNU Affero General Public License.
|
||||
|
||||
Notwithstanding any other provision of this License, you have
|
||||
permission to link or combine any covered work with a work licensed
|
||||
under version 3 of the GNU Affero General Public License into a single
|
||||
combined work, and to convey the resulting work. The terms of this
|
||||
License will continue to apply to the part which is the covered work,
|
||||
but the special requirements of the GNU Affero General Public License,
|
||||
section 13, concerning interaction through a network will apply to the
|
||||
combination as such.
|
||||
|
||||
14. Revised Versions of this License.
|
||||
|
||||
The Free Software Foundation may publish revised and/or new versions of
|
||||
the GNU General Public License from time to time. Such new versions will
|
||||
be similar in spirit to the present version, but may differ in detail to
|
||||
address new problems or concerns.
|
||||
|
||||
Each version is given a distinguishing version number. If the
|
||||
Program specifies that a certain numbered version of the GNU General
|
||||
Public License "or any later version" applies to it, you have the
|
||||
option of following the terms and conditions either of that numbered
|
||||
version or of any later version published by the Free Software
|
||||
Foundation. If the Program does not specify a version number of the
|
||||
GNU General Public License, you may choose any version ever published
|
||||
by the Free Software Foundation.
|
||||
|
||||
If the Program specifies that a proxy can decide which future
|
||||
versions of the GNU General Public License can be used, that proxy's
|
||||
public statement of acceptance of a version permanently authorizes you
|
||||
to choose that version for the Program.
|
||||
|
||||
Later license versions may give you additional or different
|
||||
permissions. However, no additional obligations are imposed on any
|
||||
author or copyright holder as a result of your choosing to follow a
|
||||
later version.
|
||||
|
||||
15. Disclaimer of Warranty.
|
||||
|
||||
THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY
|
||||
APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT
|
||||
HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY
|
||||
OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,
|
||||
THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM
|
||||
IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF
|
||||
ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
|
||||
|
||||
16. Limitation of Liability.
|
||||
|
||||
IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
|
||||
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS
|
||||
THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY
|
||||
GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE
|
||||
USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF
|
||||
DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD
|
||||
PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS),
|
||||
EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF
|
||||
SUCH DAMAGES.
|
||||
|
||||
17. Interpretation of Sections 15 and 16.
|
||||
|
||||
If the disclaimer of warranty and limitation of liability provided
|
||||
above cannot be given local legal effect according to their terms,
|
||||
reviewing courts shall apply local law that most closely approximates
|
||||
an absolute waiver of all civil liability in connection with the
|
||||
Program, unless a warranty or assumption of liability accompanies a
|
||||
copy of the Program in return for a fee.
|
||||
|
||||
END OF TERMS AND CONDITIONS
|
||||
|
||||
How to Apply These Terms to Your New Programs
|
||||
|
||||
If you develop a new program, and you want it to be of the greatest
|
||||
possible use to the public, the best way to achieve this is to make it
|
||||
free software which everyone can redistribute and change under these terms.
|
||||
|
||||
To do so, attach the following notices to the program. It is safest
|
||||
to attach them to the start of each source file to most effectively
|
||||
state the exclusion of warranty; and each file should have at least
|
||||
the "copyright" line and a pointer to where the full notice is found.
|
||||
|
||||
<one line to give the program's name and a brief idea of what it does.>
|
||||
Copyright (C) <year> <name of author>
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
|
||||
Also add information on how to contact you by electronic and paper mail.
|
||||
|
||||
If the program does terminal interaction, make it output a short
|
||||
notice like this when it starts in an interactive mode:
|
||||
|
||||
<program> Copyright (C) <year> <name of author>
|
||||
This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
|
||||
This is free software, and you are welcome to redistribute it
|
||||
under certain conditions; type `show c' for details.
|
||||
|
||||
The hypothetical commands `show w' and `show c' should show the appropriate
|
||||
parts of the General Public License. Of course, your program's commands
|
||||
might be different; for a GUI interface, you would use an "about box".
|
||||
|
||||
You should also get your employer (if you work as a programmer) or school,
|
||||
if any, to sign a "copyright disclaimer" for the program, if necessary.
|
||||
For more information on this, and how to apply and follow the GNU GPL, see
|
||||
<https://www.gnu.org/licenses/>.
|
||||
|
||||
The GNU General Public License does not permit incorporating your program
|
||||
into proprietary programs. If your program is a subroutine library, you
|
||||
may consider it more useful to permit linking proprietary applications with
|
||||
the library. If this is what you want to do, use the GNU Lesser General
|
||||
Public License instead of this License. But first, please read
|
||||
<https://www.gnu.org/licenses/why-not-lgpl.html>.
|
||||
|
||||
================================================================================
|
||||
MIT License — applies to the portions derived from Gitea and Gogs
|
||||
================================================================================
|
||||
|
||||
Copyright (c) 2016 The Gitea Authors
|
||||
Copyright (c) 2015 The Gogs Authors
|
||||
|
||||
|
||||
@@ -62,10 +62,10 @@ endif
|
||||
# GOFLAGS and EXTRA_GOFLAGS are for the 'go build' command only
|
||||
ifeq ($(IS_WINDOWS),yes)
|
||||
GOFLAGS := -v -buildmode=exe
|
||||
EXECUTABLE ?= mokogit.exe
|
||||
EXECUTABLE ?= gitea.exe
|
||||
else
|
||||
GOFLAGS := -v
|
||||
EXECUTABLE ?= mokogit
|
||||
EXECUTABLE ?= gitea
|
||||
endif
|
||||
EXTRA_GOFLAGS ?=
|
||||
|
||||
@@ -110,8 +110,8 @@ LDFLAGS := $(LDFLAGS) -X "main.Version=$(GITEA_VERSION)" -X "main.Tags=$(TAGS)"
|
||||
|
||||
LINUX_ARCHS ?= linux/amd64,linux/386,linux/arm-5,linux/arm-6,linux/arm64,linux/riscv64
|
||||
|
||||
GO_TEST_PACKAGES ?= $(filter-out $(shell $(GO) list code.mokoconsulting.tech/MokoConsulting/MokoGIT/models/migrations/...) code.mokoconsulting.tech/MokoConsulting/MokoGIT/tests/integration/migration-test code.mokoconsulting.tech/MokoConsulting/MokoGIT/tests code.mokoconsulting.tech/MokoConsulting/MokoGIT/tests/integration,$(shell $(GO) list ./... | grep -v /vendor/))
|
||||
MIGRATE_TEST_PACKAGES ?= $(shell $(GO) list code.mokoconsulting.tech/MokoConsulting/MokoGIT/models/migrations/...)
|
||||
GO_TEST_PACKAGES ?= $(filter-out $(shell $(GO) list code.gitea.io/gitea/models/migrations/...) code.gitea.io/gitea/tests/integration/migration-test code.gitea.io/gitea/tests code.gitea.io/gitea/tests/integration,$(shell $(GO) list ./... | grep -v /vendor/))
|
||||
MIGRATE_TEST_PACKAGES ?= $(shell $(GO) list code.gitea.io/gitea/models/migrations/...)
|
||||
|
||||
FRONTEND_SOURCES := $(shell find web_src/js web_src/css -type f)
|
||||
FRONTEND_CONFIGS := vite.config.ts tailwind.config.ts
|
||||
@@ -450,19 +450,19 @@ test-integration:
|
||||
@# Use a compiled binary: testlogger forwards gitea logs to t.Log, so `go test -v`
|
||||
@# would flood output per passing test. testcache can't help these tests anyway —
|
||||
@# they mutate the work directory, so cache inputs change between runs.
|
||||
$(GO) test $(GOTEST_FLAGS) -tags '$(TAGS)' -c code.mokoconsulting.tech/MokoConsulting/MokoGIT/tests/integration -o ./test-integration-$(GITEA_TEST_DATABASE).test
|
||||
$(GO) test $(GOTEST_FLAGS) -tags '$(TAGS)' -c code.gitea.io/gitea/tests/integration -o ./test-integration-$(GITEA_TEST_DATABASE).test
|
||||
./test-integration-$(GITEA_TEST_DATABASE).test
|
||||
|
||||
.PHONY: test-integration\#%
|
||||
test-integration\#%:
|
||||
$(GO) test $(GOTEST_FLAGS) -tags '$(TAGS)' -run $(subst .,/,$*) code.mokoconsulting.tech/MokoConsulting/MokoGIT/tests/integration
|
||||
$(GO) test $(GOTEST_FLAGS) -tags '$(TAGS)' -run $(subst .,/,$*) code.gitea.io/gitea/tests/integration
|
||||
|
||||
.PHONY: test-migration
|
||||
test-migration: migrations.integration.test migrations.individual.test
|
||||
|
||||
.PHONY: migrations.integration.test
|
||||
migrations.integration.test:
|
||||
$(GO) test $(GOTEST_FLAGS) -tags '$(TAGS)' code.mokoconsulting.tech/MokoConsulting/MokoGIT/tests/integration/migration-test
|
||||
$(GO) test $(GOTEST_FLAGS) -tags '$(TAGS)' code.gitea.io/gitea/tests/integration/migration-test
|
||||
|
||||
.PHONY: migrations.individual.test
|
||||
migrations.individual.test:
|
||||
@@ -471,7 +471,7 @@ migrations.individual.test:
|
||||
|
||||
.PHONY: migrations.individual.test\#%
|
||||
migrations.individual.test\#%:
|
||||
$(GO) test $(GOTEST_FLAGS) -tags '$(TAGS)' code.mokoconsulting.tech/MokoConsulting/MokoGIT/models/migrations/$*
|
||||
$(GO) test $(GOTEST_FLAGS) -tags '$(TAGS)' code.gitea.io/gitea/models/migrations/$*
|
||||
|
||||
.PHONY: playwright
|
||||
playwright: deps-frontend
|
||||
@@ -669,10 +669,10 @@ generate-images: | node_modules ## generate images
|
||||
|
||||
.PHONY: generate-manpage
|
||||
generate-manpage: ## generate manpage
|
||||
@[ -f $(EXECUTABLE) ] || make backend
|
||||
@[ -f gitea ] || make backend
|
||||
@mkdir -p man/man1/ man/man5
|
||||
@./$(EXECUTABLE) docs --man > man/man1/mokogit.1
|
||||
@gzip -9 man/man1/mokogit.1 && echo man/man1/mokogit.1.gz created
|
||||
@./gitea docs --man > man/man1/gitea.1
|
||||
@gzip -9 man/man1/gitea.1 && echo man/man1/gitea.1.gz created
|
||||
@#TODO A small script that formats config-cheat-sheet.en-us.md nicely for use as a config man page
|
||||
|
||||
# Disable parallel execution because it would break some targets that don't
|
||||
|
||||
@@ -35,15 +35,7 @@ See the [org wiki](https://git.mokoconsulting.tech/MokoConsulting/.mokogit/wiki/
|
||||
|
||||
## License
|
||||
|
||||
MokoGIT is distributed as a combined work under the GNU General Public License v3.0 or
|
||||
later -- see the [LICENSE](LICENSE) file.
|
||||
|
||||
MokoGIT is a derivative of Gitea; portions derived from Gitea and Gogs remain under the
|
||||
MIT License. Those files carry `SPDX-License-Identifier: MIT`, and the original
|
||||
`Copyright (c) 2016 The Gitea Authors` and `Copyright (c) 2015 The Gogs Authors` notices
|
||||
are retained in [LICENSE](LICENSE) as the MIT License requires. Moko Consulting's own
|
||||
additions carry `SPDX-License-Identifier: GPL-3.0-or-later`. The authoritative license
|
||||
for any given file is its per-file `SPDX-License-Identifier` header.
|
||||
This project is licensed under the GNU General Public License v3.0 or later -- see the [LICENSE](LICENSE) file.
|
||||
|
||||
## Third-Party & Vendored Assets
|
||||
|
||||
|
||||
+74
-7
@@ -1,18 +1,85 @@
|
||||
# Reporting security issues
|
||||
|
||||
The Moko Consulting maintainers take security seriously.
|
||||
The Gitea maintainers take security seriously.
|
||||
|
||||
If you discover a security issue, please bring it to our attention right away!
|
||||
If you discover a security issue, please bring it to their attention right away!
|
||||
|
||||
Previous vulnerabilities are listed at https://about.gitea.com/security.
|
||||
|
||||
## Reporting a Vulnerability
|
||||
|
||||
Please **DO NOT** file a public issue, instead send your report privately to `security@mokoconsulting.tech`.
|
||||
|
||||
Alternatively, you may report a vulnerability privately through the MokoGIT security advisory workflow:
|
||||
https://git.mokoconsulting.tech/MokoConsulting/.github-private/security/advisories/new
|
||||
Please **DO NOT** file a public issue, instead send your report privately to `security@gitea.io`.
|
||||
|
||||
## Protecting Security Information
|
||||
|
||||
Due to the sensitive nature of security information, please avoid including exploit details in any public channel. If you require an encrypted channel for your report, request one in your initial email to `security@mokoconsulting.tech` and we will coordinate a secure method.
|
||||
Due to the sensitive nature of security information, you can use the below GPG public key to encrypt your mail body.
|
||||
|
||||
The PGP key is valid until July 4, 2026.
|
||||
|
||||
```
|
||||
Key ID: 6FCD2D5B
|
||||
Key Type: RSA
|
||||
Expires: 7/4/2026
|
||||
Key Size: 4096/4096
|
||||
Fingerprint: 3DE0 3D1E 144A 7F06 9359 99DC AAFD 2381 6FCD 2D5B
|
||||
```
|
||||
|
||||
UserID: Gitea Security <security@gitea.io>
|
||||
|
||||
```
|
||||
-----BEGIN PGP PUBLIC KEY BLOCK-----
|
||||
|
||||
mQINBGK1Z/4BEADFMqXA9DeeChmSxUjF0Be5sq99ZUhgrZjcN/wOzz0wuCJZC0l8
|
||||
4uC+d6mfv7JpJYlzYzOK97/x5UguKHkYNZ6mm1G9KHaXmoIBDLKDzfPdJopVNv2r
|
||||
OajijaE0uMCnMjadlg5pbhMLRQG8a9J32yyaz7ZEAw72Ab31fvvcA53NkuqO4j2w
|
||||
k7dtFQzhbNOYV0VffQT90WDZdalYHB1JHyEQ+70U9OjVD5ggNYSzX98Eu3Hjn7V7
|
||||
kqFrcAxr5TE1elf0IXJcuBJtFzQSTUGlQldKOHtGTGgGjj9r/FFAE5ioBgVD05bV
|
||||
rEEgIMM/GqYaG/nbNpWE6P3mEc2Mnn3pZaRJL0LuF26TLjnqEcMMDp5iIhLdFzXR
|
||||
3tMdtKgQFu+Mtzs3ipwWARYgHyU09RJsI2HeBx7RmZO/Xqrec763Z7zdJ7SpCn0Z
|
||||
q+pHZl24JYR0Kf3T/ZiOC0cGd2QJqpJtg5J6S/OqfX9NH6MsCczO8pUC1N/aHH2X
|
||||
CTme2nF56izORqDWKoiICteL3GpYsCV9nyCidcCmoQsS+DKvE86YhIhVIVWGRY2F
|
||||
lzpAjnN9/KLtQroutrm+Ft0mdjDiJUeFVl1cOHDhoyfCsQh62HumoyZoZvqzQd6e
|
||||
AbN11nq6aViMe2Q3je1AbiBnRnQSHxt1Tc8X4IshO3MQK1Sk7oPI6LA5oQARAQAB
|
||||
tCJHaXRlYSBTZWN1cml0eSA8c2VjdXJpdHlAZ2l0ZWEuaW8+iQJXBBMBCABBAhsD
|
||||
BQsJCAcCAiICBhUKCQgLAgQWAgMBAh4HAheAFiEEPeA9HhRKfwaTWZncqv0jgW/N
|
||||
LVsFAmhoHmkFCQeT6esACgkQqv0jgW/NLVuFLRAAmjBQSKRAgs2bFIEj7HLAbDp4
|
||||
f+XkdH+GsT3jRPOZ9QZgmtM+TfoE4yNgIVfOl+s4RdjM/W4QzqZuPQ55hbEHd056
|
||||
cJmm7B+6GsHFcdrPmh65sOCEIyh4+t45dUfeWpFsDPqm9j1UHXAJQIpB8vDEVAPH
|
||||
t+3wLCk8GMPJs1o5tIyMmaO23ngvkwn8eG7KgY+rp2PzObrb5g7ppci0ILzILkrp
|
||||
HVjZsEfUWRgSVF7LuU5ppqDKrlcqwUpQq6n3kGMZcLrCp6ACKP04TBmTfUxNwdL7
|
||||
I0N7apI2Pbct9T1Gv/lYAUFWyU2c3gh/EBLbO6BukaLOFRQHrtNfdJV/YnMPlcXr
|
||||
LUJjK9K4eAH9DsrZqrisz/LthsC2BaNIN3KRMTk5YTYgmIh8GXzSgihORmtDFELC
|
||||
RroID3pTuS0zjXh+wpY9GuPTh7UW23p42Daxca4fAT4k5EclvDRUrL21xMopPMiL
|
||||
HuNdELz4FVchRTy05PjzKVyjVInDNojE2KUxnjxZDzYJ6aT/g+coD5yfntYm8BEj
|
||||
+ZzL0ndZES54hzKLpv7zwBQwFzam68clZYmDPILOPTflQDfpGEWmJK4undFU5obz
|
||||
ZsQRz0R3ulspChATbZxO0d5LX2obLpKO9X3b5VoO1KF+R8Vjw1Y0KxrNZ6rIcfqH
|
||||
Z50QVQKSe9dm08K0ON+5Ag0EYrVn/gEQALrFLQjCR3GjuHSindz0rd3Fnx/t7Sen
|
||||
T+p07yCSSoSlmnJHCQmwh4vfg1blyz0zZ4vkIhtpHsEgc+ZAG+WQXSsJ2iRz+eSN
|
||||
GwoOQl4XC3n+QWkc1ws+btr48+6UqXIQU+F8TPQyx/PIgi2nZXJB7f5+mjCqsk46
|
||||
XvH4nTr4kJjuqMSR/++wvre2qNQRa/q/dTsK0OaN/mJsdX6Oi+aGNaQJUhIG7F+E
|
||||
ZDMkn/O6xnwWNzy/+bpg43qH/Gk0eakOmz5NmQLRkV58SZLiJvuCUtkttf6CyhnX
|
||||
03OcWaajv5W8qA39dBYQgDrrPbBWUnwfO3yMveqhwV4JjDoe8sPAyn1NwzakNYqP
|
||||
RzsWyLrLS7R7J9s3FkZXhQw/QQcsaSMcGNQO047dm1P83N8JY5aEpiRo9zSWjoiw
|
||||
qoExANj5lUTZPe8M50lI182FrcjAN7dClO3QI6pg7wy0erMxfFly3j8UQ91ysS9T
|
||||
s+GsP9I3cmWWQcKYxWHtE8xTXnNCVPFZQj2nwhJzae8ypfOtulBRA3dUKWGKuDH/
|
||||
axFENhUsT397aOU3qkP/od4a64JyNIEo4CTTSPVeWd7njsGqli2U3A4xL2CcyYvt
|
||||
D/MWcMBGEoLSNTswwKdom4FaJpn5KThnK/T0bQcmJblJhoCtppXisbexZnCpuS0x
|
||||
Zdlm2T14KJ3LABEBAAGJAjwEGAEIACYCGwwWIQQ94D0eFEp/BpNZmdyq/SOBb80t
|
||||
WwUCaGgeJAUJB5PppgAKCRCq/SOBb80tW/NWEACB6Jrf0gWlk7e+hNCdnbM0ZVWU
|
||||
f2sHNFfXxxsdhpcDgKbNHtkZb8nZgv8AX+5fTtUwMVa3vKcdw30xFiIM5N7cCIPV
|
||||
vg/5z5BtfEaitnabEUG2iiVDIy8IHXIcK10rX+7BosA3QDl2PsiBHwyi5G13lRk8
|
||||
zGTSNDuOalug33h5/lr2dPigamkq74Aoy29q8Rjad6GfWHipL2bFimgtY+Zdi0BH
|
||||
NLk4EJXxj1SgVx5dtkQzWJReBA5M+FQ4QYQZBO+f4TDoOLmjui152uhkoLBQbGAa
|
||||
WWJFTVxm0bG5MXloEL3gA8DfU7XDwuW/sHJC5pBko8RpQViooOhckMepZV3Y83DK
|
||||
bwLYa3JmPgj2rEv4993dvrJbQhpGd082HOxOsllCs8pgNq1SnXpWYfcGTgGKC3ts
|
||||
U8YZUUJUQ7mi2L8Tv3ix20c9EiGmA30JAmA8eZTC3cWup91ZkkVBFRml2czTXajd
|
||||
RWZ6GbHV5503ueDQcB8yBVgF3CSixs67+dGSbD3p86OqGrjAcJzM5TFbNKcnGLdE
|
||||
kGbZpNwAISy750lXzXKmyrh5RTCeTOQerbwCMBvHZO+HAevA/LXDTw2OAiSIQlP5
|
||||
sYA4sFYLQ30OAkgJcmdp/pSgVj/erNtSN07ClrOpDb/uFpQymO6K2h0Pst3feNVK
|
||||
9M2VbqL9C51z/wyHLg==
|
||||
=SfZA
|
||||
-----END PGP PUBLIC KEY BLOCK-----
|
||||
|
||||
```
|
||||
|
||||
Security reports are greatly appreciated and we will publicly thank you for it, although we keep your name confidential if you request it.
|
||||
|
||||
@@ -144,17 +144,17 @@ func TestCliCmd(t *testing.T) {
|
||||
exp: makePathOutput(defaultWorkPath, defaultCustomPath, "/tmp/app.ini"),
|
||||
},
|
||||
{
|
||||
env: map[string]string{"MOKOGIT_WORK_DIR": "/tmp"},
|
||||
env: map[string]string{"GITEA_WORK_DIR": "/tmp"},
|
||||
cmd: "./gitea test-cmd",
|
||||
exp: makePathOutput("/tmp", "/tmp/custom", "/tmp/custom/conf/app.ini"),
|
||||
},
|
||||
{
|
||||
env: map[string]string{"MOKOGIT_WORK_DIR": "/tmp"},
|
||||
env: map[string]string{"GITEA_WORK_DIR": "/tmp"},
|
||||
cmd: "./gitea test-cmd --work-path /tmp/other",
|
||||
exp: makePathOutput("/tmp/other", "/tmp/other/custom", "/tmp/other/custom/conf/app.ini"),
|
||||
},
|
||||
{
|
||||
env: map[string]string{"MOKOGIT_WORK_DIR": "/tmp"},
|
||||
env: map[string]string{"GITEA_WORK_DIR": "/tmp"},
|
||||
cmd: "./gitea test-cmd --config /tmp/app-other.ini",
|
||||
exp: makePathOutput("/tmp", "/tmp/custom", "/tmp/app-other.ini"),
|
||||
},
|
||||
|
||||
+6
-6
@@ -19,7 +19,7 @@ func cmdConfig() *cli.Command {
|
||||
Name: "edit-ini",
|
||||
Usage: "Load an existing INI file, apply environment variables, keep specified keys, and output to a new INI file.",
|
||||
Description: `
|
||||
Help users to edit the MokoGIT configuration INI file.
|
||||
Help users to edit the Gitea configuration INI file.
|
||||
|
||||
# Keep Specified Keys
|
||||
|
||||
@@ -31,15 +31,15 @@ it can use a template file (only keys take effect, values are ignored):
|
||||
[security]
|
||||
SECRET_KEY=
|
||||
|
||||
$ ./mokogit config edit-ini --config app-old.ini --config-keep-keys app-keys.ini --out app-new.ini
|
||||
$ ./gitea config edit-ini --config app-old.ini --config-keep-keys app-keys.ini --out app-new.ini
|
||||
|
||||
# Map Environment Variables to INI Configuration
|
||||
|
||||
Environment variables of the form "MOKOGIT__section_name__KEY_NAME"
|
||||
Environment variables of the form "GITEA__section_name__KEY_NAME"
|
||||
will be mapped to the ini section "[section_name]" and the key
|
||||
"KEY_NAME" with the value as provided.
|
||||
|
||||
Environment variables of the form "MOKOGIT__section_name__KEY_NAME__FILE"
|
||||
Environment variables of the form "GITEA__section_name__KEY_NAME__FILE"
|
||||
will be mapped to the ini section "[section_name]" and the key
|
||||
"KEY_NAME" with the value loaded from the specified file.
|
||||
|
||||
@@ -50,11 +50,11 @@ For example, to apply this config:
|
||||
[git.config]
|
||||
foo.bar=val
|
||||
|
||||
$ export MOKOGIT__git_0x2E_config__foo_0x2E_bar=val
|
||||
$ export GITEA__git_0x2E_config__foo_0x2E_bar=val
|
||||
|
||||
# Put All Together
|
||||
|
||||
$ ./mokogit config edit-ini --config app.ini --config-keep-keys app-keys.ini --apply-env {--in-place|--out app-new.ini}
|
||||
$ ./gitea config edit-ini --config app.ini --config-keep-keys app-keys.ini --apply-env {--in-place|--out app-new.ini}
|
||||
`,
|
||||
Flags: []cli.Flag{
|
||||
// "--config" flag is provided by global flags, and this flag is also used by "environment-to-ini" script wrapper
|
||||
|
||||
@@ -27,7 +27,7 @@ func main() {
|
||||
app := &cli.Command{}
|
||||
app.Name = "backport"
|
||||
app.Usage = "Backport provided PR-number on to the current or previous released version"
|
||||
app.Description = `Backport will look-up the PR in MokoGIT's git log and attempt to cherry-pick it on the current version`
|
||||
app.Description = `Backport will look-up the PR in Gitea's git log and attempt to cherry-pick it on the current version`
|
||||
app.ArgsUsage = "<PR-to-backport>"
|
||||
|
||||
app.Flags = []cli.Flag{
|
||||
@@ -38,7 +38,7 @@ func main() {
|
||||
&cli.StringFlag{
|
||||
Name: "upstream",
|
||||
Value: "origin",
|
||||
Usage: "Upstream remote for the MokoGIT upstream",
|
||||
Usage: "Upstream remote for the Gitea upstream",
|
||||
},
|
||||
&cli.StringFlag{
|
||||
Name: "release-branch",
|
||||
@@ -56,7 +56,7 @@ func main() {
|
||||
&cli.StringFlag{
|
||||
Name: "remote",
|
||||
Value: "",
|
||||
Usage: "Remote for your fork of the MokoGIT upstream",
|
||||
Usage: "Remote for your fork of the Gitea upstream",
|
||||
},
|
||||
&cli.StringFlag{
|
||||
Name: "fork-user",
|
||||
@@ -204,7 +204,7 @@ func runBackport(ctx context.Context, c *cli.Command) error {
|
||||
}
|
||||
|
||||
if !c.Bool("no-push") {
|
||||
url := "https://git.mokoconsulting.tech/MokoConsulting/MokoGIT/compare/" + upstreamReleaseBranch + "..." + forkUser + ":" + backportBranch
|
||||
url := "https://github.com/go-gitea/gitea/compare/" + upstreamReleaseBranch + "..." + forkUser + ":" + backportBranch
|
||||
|
||||
if err := gitPushUp(ctx, remote, backportBranch); err != nil {
|
||||
return err
|
||||
@@ -439,11 +439,6 @@ func determineSHAforPR(ctx context.Context, prStr, accessToken string) (string,
|
||||
client = client.WithAuthToken(accessToken)
|
||||
}
|
||||
|
||||
// NOTE: This PR SHA lookup uses the GitHub API and still points at the
|
||||
// upstream lineage repo (go-gitea/gitea) because MokoGIT is hosted on a
|
||||
// self-hosted forge (git.mokoconsulting.tech), not GitHub. To backport
|
||||
// a MokoGIT PR, pass the merge SHA directly via --cherry-pick instead of
|
||||
// relying on this lookup. Migrating this to the forge API is future work.
|
||||
pr, _, err := client.PullRequests.Get(ctx, "go-gitea", "gitea", prNum)
|
||||
if err != nil {
|
||||
return "", err
|
||||
|
||||
@@ -12,19 +12,19 @@
|
||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
;;
|
||||
;; These values are environment-dependent but form the basis of a lot of values. They will be
|
||||
;; reported as part of the default configuration when running `mokogit help` or on start-up. The order they are emitted there is slightly different but we will list them here in the order they are set-up.
|
||||
;; reported as part of the default configuration when running `gitea help` or on start-up. The order they are emitted there is slightly different but we will list them here in the order they are set-up.
|
||||
;;
|
||||
;; - _`AppPath`_: This is the absolute path of the running mokogit binary.
|
||||
;; - _`AppWorkPath`_: This refers to "working path" of the `mokogit` binary. It is determined by using the first set thing in the following hierarchy:
|
||||
;; - _`AppPath`_: This is the absolute path of the running gitea binary.
|
||||
;; - _`AppWorkPath`_: This refers to "working path" of the `gitea` binary. It is determined by using the first set thing in the following hierarchy:
|
||||
;; - The "WORK_PATH" option in "app.ini" file
|
||||
;; - The `--work-path` flag passed to the binary
|
||||
;; - The environment variable `$MOKOGIT_WORK_DIR`
|
||||
;; - The environment variable `$GITEA_WORK_DIR`
|
||||
;; - A built-in value set at build time (see building from source)
|
||||
;; - Otherwise it defaults to the directory of the _`AppPath`_
|
||||
;; - If any of the above are relative paths then they are made absolute against the directory of the _`AppPath`_
|
||||
;; - _`CustomPath`_: This is the base directory for custom templates and other options. It is determined by using the first set thing in the following hierarchy:
|
||||
;; - The `--custom-path` flag passed to the binary
|
||||
;; - The environment variable `$MOKOGIT_CUSTOM`
|
||||
;; - The environment variable `$GITEA_CUSTOM`
|
||||
;; - A built-in value set at build time (see building from source)
|
||||
;; - Otherwise it defaults to _`AppWorkPath`_`/custom`
|
||||
;; - If any of the above are relative paths then they are made absolute against the directory of the _`AppWorkPath`_
|
||||
@@ -41,7 +41,7 @@
|
||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
;;
|
||||
;; App name that shows in every page title
|
||||
;APP_NAME = MokoGIT
|
||||
;APP_NAME = Gitea: Git with a cup of tea
|
||||
;;
|
||||
;; RUN_USER will automatically detect the current user - but you can set it here change it if you run locally
|
||||
;RUN_USER =
|
||||
@@ -1428,9 +1428,9 @@ LEVEL = Info
|
||||
;[ui.meta]
|
||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
;AUTHOR = MokoGIT
|
||||
;DESCRIPTION = MokoGIT is a painless self-hosted Git service
|
||||
;KEYWORDS = go,git,self-hosted,mokogit
|
||||
;AUTHOR = Gitea - Git with a cup of tea
|
||||
;DESCRIPTION = Gitea (Git with a cup of tea) is a painless self-hosted Git service written in Go
|
||||
;KEYWORDS = go,git,self-hosted,gitea
|
||||
|
||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
@@ -2999,23 +2999,3 @@ LEVEL = Info
|
||||
;SERVICE_TYPE = memory
|
||||
;; Ignored for the "memory" type. For "redis" use something like `redis://127.0.0.1:6379/0`
|
||||
;SERVICE_CONN_STR =
|
||||
|
||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
;; Repository metadata / platform registry
|
||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
;[metadata]
|
||||
;; Comma-separated list of allowed values for the repo metadata "platform" field.
|
||||
;; Also editable via Admin -> Metadata (persisted here). Default taxonomy:
|
||||
;PLATFORM_OPTIONS = joomla,dolibarr,go,npm,generic
|
||||
;;
|
||||
;; Structured platform registry: capability attributes per platform key, read by
|
||||
;; CI, the update server, and workflow sync (exposed at GET /api/v1/platforms).
|
||||
;; Value is EITHER an inline JSON array of platform objects OR a path to a JSON
|
||||
;; file (relative paths resolve against the custom/ dir). When unset, a built-in
|
||||
;; default registry is used (joomla, dolibarr, go, npm, mcp, generic), so
|
||||
;; behavior is unchanged if this is not configured.
|
||||
;; Example (file path):
|
||||
;PLATFORM_REGISTRY = custom/platforms.json
|
||||
;; Example (inline JSON):
|
||||
;;PLATFORM_REGISTRY = [{"key":"joomla","label":"Joomla Extension","family":"joomla","artifact":true,"update_generator":"joomla","feed_format":"xml","template_repo":"Template-Joomla","manifest_based":true}]
|
||||
|
||||
Executable
+6
@@ -0,0 +1,6 @@
|
||||
#!/bin/bash
|
||||
[[ -f ./setup ]] && source ./setup
|
||||
|
||||
pushd /app/gitea >/dev/null
|
||||
exec su-exec $USER /usr/local/bin/gitea web
|
||||
popd
|
||||
@@ -14,16 +14,16 @@ if [ -f /data/git/.ssh/authorized_keys ]; then
|
||||
fi
|
||||
|
||||
if [ ! -f /data/git/.ssh/environment ]; then
|
||||
echo "MOKOGIT_CUSTOM=$MOKOGIT_CUSTOM" >| /data/git/.ssh/environment
|
||||
echo "GITEA_CUSTOM=$GITEA_CUSTOM" >| /data/git/.ssh/environment
|
||||
chmod 600 /data/git/.ssh/environment
|
||||
|
||||
elif ! grep -q "^MOKOGIT_CUSTOM=$MOKOGIT_CUSTOM$" /data/git/.ssh/environment; then
|
||||
sed -i /^MOKOGIT_CUSTOM=/d /data/git/.ssh/environment
|
||||
echo "MOKOGIT_CUSTOM=$MOKOGIT_CUSTOM" >> /data/git/.ssh/environment
|
||||
elif ! grep -q "^GITEA_CUSTOM=$GITEA_CUSTOM$" /data/git/.ssh/environment; then
|
||||
sed -i /^GITEA_CUSTOM=/d /data/git/.ssh/environment
|
||||
echo "GITEA_CUSTOM=$GITEA_CUSTOM" >> /data/git/.ssh/environment
|
||||
fi
|
||||
|
||||
if [ ! -f ${MOKOGIT_CUSTOM}/conf/app.ini ]; then
|
||||
mkdir -p ${MOKOGIT_CUSTOM}/conf
|
||||
if [ ! -f ${GITEA_CUSTOM}/conf/app.ini ]; then
|
||||
mkdir -p ${GITEA_CUSTOM}/conf
|
||||
|
||||
# Set INSTALL_LOCK to true only if SECRET_KEY is not empty and
|
||||
# INSTALL_LOCK is empty
|
||||
@@ -32,7 +32,7 @@ if [ ! -f ${MOKOGIT_CUSTOM}/conf/app.ini ]; then
|
||||
fi
|
||||
|
||||
# Substitute the environment variables in the template
|
||||
APP_NAME=${APP_NAME:-"MokoGIT"} \
|
||||
APP_NAME=${APP_NAME:-"Gitea: Git with a cup of tea"} \
|
||||
RUN_MODE=${RUN_MODE:-"prod"} \
|
||||
DOMAIN=${DOMAIN:-"localhost"} \
|
||||
SSH_DOMAIN=${SSH_DOMAIN:-"localhost"} \
|
||||
@@ -51,16 +51,16 @@ if [ ! -f ${MOKOGIT_CUSTOM}/conf/app.ini ]; then
|
||||
DISABLE_REGISTRATION=${DISABLE_REGISTRATION:-"false"} \
|
||||
REQUIRE_SIGNIN_VIEW=${REQUIRE_SIGNIN_VIEW:-"false"} \
|
||||
SECRET_KEY=${SECRET_KEY:-""} \
|
||||
envsubst < /etc/templates/app.ini > ${MOKOGIT_CUSTOM}/conf/app.ini
|
||||
envsubst < /etc/templates/app.ini > ${GITEA_CUSTOM}/conf/app.ini
|
||||
|
||||
chown ${USER}:git ${MOKOGIT_CUSTOM}/conf/app.ini
|
||||
chown ${USER}:git ${GITEA_CUSTOM}/conf/app.ini
|
||||
fi
|
||||
|
||||
# Replace app.ini settings with env variables in the form MOKOGIT__SECTION_NAME__KEY_NAME
|
||||
environment-to-ini --config ${MOKOGIT_CUSTOM}/conf/app.ini
|
||||
# Replace app.ini settings with env variables in the form GITEA__SECTION_NAME__KEY_NAME
|
||||
environment-to-ini --config ${GITEA_CUSTOM}/conf/app.ini
|
||||
|
||||
# only chown if current owner is not already the mokogit ${USER}. No recursive check to save time
|
||||
if ! [[ $(ls -ld /data/mokogit | awk '{print $3}') = ${USER} ]]; then chown -R ${USER}:git /data/mokogit; fi
|
||||
if ! [[ $(ls -ld /app/mokogit | awk '{print $3}') = ${USER} ]]; then chown -R ${USER}:git /app/mokogit; fi
|
||||
if ! [[ $(ls -ld /data/git | awk '{print $3}') = ${USER} ]]; then chown -R ${USER}:git /data/git; fi
|
||||
chmod 0755 /data/mokogit /app/mokogit /data/git
|
||||
# only chown if current owner is not already the gitea ${USER}. No recursive check to save time
|
||||
if ! [[ $(ls -ld /data/gitea | awk '{print $3}') = ${USER} ]]; then chown -R ${USER}:git /data/gitea; fi
|
||||
if ! [[ $(ls -ld /app/gitea | awk '{print $3}') = ${USER} ]]; then chown -R ${USER}:git /app/gitea; fi
|
||||
if ! [[ $(ls -ld /data/git | awk '{print $3}') = ${USER} ]]; then chown -R ${USER}:git /data/git; fi
|
||||
chmod 0755 /data/gitea /app/gitea /data/git
|
||||
@@ -1,6 +0,0 @@
|
||||
#!/bin/bash
|
||||
[[ -f ./setup ]] && source ./setup
|
||||
|
||||
pushd /app/mokogit >/dev/null
|
||||
exec su-exec $USER /usr/local/bin/mokogit web
|
||||
popd
|
||||
@@ -5,13 +5,13 @@ RUN_MODE = $RUN_MODE
|
||||
ROOT = /data/git/repositories
|
||||
|
||||
[repository.local]
|
||||
LOCAL_COPY_PATH = /data/mokogit/tmp/local-repo
|
||||
LOCAL_COPY_PATH = /data/gitea/tmp/local-repo
|
||||
|
||||
[repository.upload]
|
||||
TEMP_PATH = /data/mokogit/uploads
|
||||
TEMP_PATH = /data/gitea/uploads
|
||||
|
||||
[server]
|
||||
APP_DATA_PATH = /data/mokogit
|
||||
APP_DATA_PATH = /data/gitea
|
||||
DOMAIN = $DOMAIN
|
||||
SSH_DOMAIN = $SSH_DOMAIN
|
||||
HTTP_PORT = $HTTP_PORT
|
||||
@@ -22,7 +22,7 @@ SSH_LISTEN_PORT = $SSH_LISTEN_PORT
|
||||
LFS_START_SERVER = $LFS_START_SERVER
|
||||
|
||||
[database]
|
||||
PATH = /data/mokogit/gitea.db
|
||||
PATH = /data/gitea/gitea.db
|
||||
DB_TYPE = $DB_TYPE
|
||||
HOST = $DB_HOST
|
||||
NAME = $DB_NAME
|
||||
@@ -31,22 +31,22 @@ PASSWD = $DB_PASSWD
|
||||
LOG_SQL = false
|
||||
|
||||
[indexer]
|
||||
ISSUE_INDEXER_PATH = /data/mokogit/indexers/issues.bleve
|
||||
ISSUE_INDEXER_PATH = /data/gitea/indexers/issues.bleve
|
||||
|
||||
[session]
|
||||
PROVIDER_CONFIG = /data/mokogit/sessions
|
||||
PROVIDER_CONFIG = /data/gitea/sessions
|
||||
|
||||
[picture]
|
||||
AVATAR_UPLOAD_PATH = /data/mokogit/avatars
|
||||
REPOSITORY_AVATAR_UPLOAD_PATH = /data/mokogit/repo-avatars
|
||||
AVATAR_UPLOAD_PATH = /data/gitea/avatars
|
||||
REPOSITORY_AVATAR_UPLOAD_PATH = /data/gitea/repo-avatars
|
||||
|
||||
[attachment]
|
||||
PATH = /data/mokogit/attachments
|
||||
PATH = /data/gitea/attachments
|
||||
|
||||
[log]
|
||||
MODE = console
|
||||
LEVEL = info
|
||||
ROOT_PATH = /data/mokogit/log
|
||||
ROOT_PATH = /data/gitea/log
|
||||
|
||||
[security]
|
||||
INSTALL_LOCK = $INSTALL_LOCK
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
# Protect against buggy runc in docker <20.10.6 causing problems in with Alpine >= 3.14
|
||||
if [ ! -x /bin/sh ]; then
|
||||
echo "Executable test for /bin/sh failed. Your Docker version is too old to run Alpine 3.14+ and MokoGIT. You must upgrade Docker.";
|
||||
echo "Executable test for /bin/sh failed. Your Docker version is too old to run Alpine 3.14+ and Gitea. You must upgrade Docker.";
|
||||
exit 1;
|
||||
fi
|
||||
|
||||
@@ -30,7 +30,7 @@ if [ -n "${USER_UID}" ] && [ "${USER_UID}" != "`id -u ${USER}`" ]; then
|
||||
sed -i -e "s/^${USER}:\([^:]*\):[0-9]*:\([0-9]*\)/${USER}:\1:${USER_UID}:\2/" /etc/passwd
|
||||
fi
|
||||
|
||||
for FOLDER in /data/mokogit/conf /data/mokogit/log /data/git /data/ssh; do
|
||||
for FOLDER in /data/gitea/conf /data/gitea/log /data/git /data/ssh; do
|
||||
mkdir -p ${FOLDER}
|
||||
done
|
||||
|
||||
|
||||
@@ -1,2 +1,2 @@
|
||||
#!/bin/bash
|
||||
exec /app/mokogit/mokogit config edit-ini --in-place --apply-env "$@"
|
||||
exec /app/gitea/gitea config edit-ini --in-place --apply-env "$@"
|
||||
|
||||
@@ -0,0 +1,15 @@
|
||||
#!/bin/bash
|
||||
|
||||
###############################################################
|
||||
# This script sets defaults for gitea to run in the container #
|
||||
###############################################################
|
||||
|
||||
# It assumes that you place this script as gitea in /usr/local/bin
|
||||
#
|
||||
# And place the original in /usr/lib/gitea with working files in /data/gitea
|
||||
GITEA="/app/gitea/gitea"
|
||||
WORK_DIR="/data/gitea"
|
||||
CUSTOM_PATH="/data/gitea"
|
||||
|
||||
# Provide docker defaults
|
||||
GITEA_WORK_DIR="${GITEA_WORK_DIR:-$WORK_DIR}" GITEA_CUSTOM="${GITEA_CUSTOM:-$CUSTOM_PATH}" exec -a "$0" "$GITEA" $CONF_ARG "$@"
|
||||
@@ -1,15 +0,0 @@
|
||||
#!/bin/bash
|
||||
|
||||
#################################################################
|
||||
# This script sets defaults for mokogit to run in the container #
|
||||
#################################################################
|
||||
|
||||
# It assumes that you place this script as mokogit in /usr/local/bin
|
||||
#
|
||||
# And place the original in /usr/lib/mokogit with working files in /data/mokogit
|
||||
MOKOGIT="/app/mokogit/mokogit"
|
||||
WORK_DIR="/data/mokogit"
|
||||
CUSTOM_PATH="/data/mokogit"
|
||||
|
||||
# Provide docker defaults
|
||||
MOKOGIT_WORK_DIR="${MOKOGIT_WORK_DIR:-$WORK_DIR}" MOKOGIT_CUSTOM="${MOKOGIT_CUSTOM:-$CUSTOM_PATH}" exec -a "$0" "$MOKOGIT" $CONF_ARG "$@"
|
||||
@@ -3,21 +3,21 @@ RUN_USER = $RUN_USER
|
||||
RUN_MODE = $RUN_MODE
|
||||
|
||||
[repository]
|
||||
ROOT = $MOKOGIT_WORK_DIR/git/repositories
|
||||
ROOT = $GITEA_WORK_DIR/git/repositories
|
||||
|
||||
[repository.local]
|
||||
LOCAL_COPY_PATH = $MOKOGIT_TEMP/local-repo
|
||||
LOCAL_COPY_PATH = $GITEA_TEMP/local-repo
|
||||
|
||||
[repository.upload]
|
||||
TEMP_PATH = $MOKOGIT_TEMP/uploads
|
||||
TEMP_PATH = $GITEA_TEMP/uploads
|
||||
|
||||
[server]
|
||||
APP_DATA_PATH = $MOKOGIT_WORK_DIR
|
||||
APP_DATA_PATH = $GITEA_WORK_DIR
|
||||
SSH_DOMAIN = $SSH_DOMAIN
|
||||
HTTP_PORT = $HTTP_PORT
|
||||
ROOT_URL = $ROOT_URL
|
||||
DISABLE_SSH = $DISABLE_SSH
|
||||
; In rootless mokogit container only internal ssh server is supported
|
||||
; In rootless gitea container only internal ssh server is supported
|
||||
START_SSH_SERVER = true
|
||||
SSH_PORT = $SSH_PORT
|
||||
SSH_LISTEN_PORT = $SSH_LISTEN_PORT
|
||||
@@ -25,7 +25,7 @@ BUILTIN_SSH_SERVER_USER = $RUN_USER
|
||||
LFS_START_SERVER = $LFS_START_SERVER
|
||||
|
||||
[database]
|
||||
PATH = $MOKOGIT_WORK_DIR/data/gitea.db
|
||||
PATH = $GITEA_WORK_DIR/data/gitea.db
|
||||
DB_TYPE = $DB_TYPE
|
||||
HOST = $DB_HOST
|
||||
NAME = $DB_NAME
|
||||
@@ -33,17 +33,17 @@ USER = $DB_USER
|
||||
PASSWD = $DB_PASSWD
|
||||
|
||||
[session]
|
||||
PROVIDER_CONFIG = $MOKOGIT_WORK_DIR/data/sessions
|
||||
PROVIDER_CONFIG = $GITEA_WORK_DIR/data/sessions
|
||||
|
||||
[picture]
|
||||
AVATAR_UPLOAD_PATH = $MOKOGIT_WORK_DIR/data/avatars
|
||||
REPOSITORY_AVATAR_UPLOAD_PATH = $MOKOGIT_WORK_DIR/data/repo-avatars
|
||||
AVATAR_UPLOAD_PATH = $GITEA_WORK_DIR/data/avatars
|
||||
REPOSITORY_AVATAR_UPLOAD_PATH = $GITEA_WORK_DIR/data/repo-avatars
|
||||
|
||||
[attachment]
|
||||
PATH = $MOKOGIT_WORK_DIR/data/attachments
|
||||
PATH = $GITEA_WORK_DIR/data/attachments
|
||||
|
||||
[log]
|
||||
ROOT_PATH = $MOKOGIT_WORK_DIR/data/log
|
||||
ROOT_PATH = $GITEA_WORK_DIR/data/log
|
||||
|
||||
[security]
|
||||
INSTALL_LOCK = $INSTALL_LOCK
|
||||
@@ -54,4 +54,4 @@ DISABLE_REGISTRATION = $DISABLE_REGISTRATION
|
||||
REQUIRE_SIGNIN_VIEW = $REQUIRE_SIGNIN_VIEW
|
||||
|
||||
[lfs]
|
||||
PATH = $MOKOGIT_WORK_DIR/git/lfs
|
||||
PATH = $GITEA_WORK_DIR/git/lfs
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
# Protect against buggy runc in docker <20.10.6 causing problems in with Alpine >= 3.14
|
||||
if [ ! -x /bin/sh ]; then
|
||||
echo "Executable test for /bin/sh failed. Your Docker version is too old to run Alpine 3.14+ and MokoGIT. You must upgrade Docker.";
|
||||
echo "Executable test for /bin/sh failed. Your Docker version is too old to run Alpine 3.14+ and Gitea. You must upgrade Docker.";
|
||||
exit 1;
|
||||
fi
|
||||
|
||||
@@ -13,5 +13,5 @@ fi
|
||||
if [ $# -gt 0 ]; then
|
||||
exec "$@"
|
||||
else
|
||||
exec /usr/local/bin/mokogit -c ${MOKOGIT_APP_INI} web
|
||||
exec /usr/local/bin/gitea -c ${GITEA_APP_INI} web
|
||||
fi
|
||||
|
||||
@@ -5,19 +5,19 @@ mkdir -p ${HOME} && chmod 0700 ${HOME}
|
||||
if [ ! -w ${HOME} ]; then echo "${HOME} is not writable"; exit 1; fi
|
||||
|
||||
# Prepare custom folder
|
||||
mkdir -p ${MOKOGIT_CUSTOM} && chmod 0700 ${MOKOGIT_CUSTOM}
|
||||
mkdir -p ${GITEA_CUSTOM} && chmod 0700 ${GITEA_CUSTOM}
|
||||
|
||||
# Prepare temp folder
|
||||
mkdir -p ${MOKOGIT_TEMP} && chmod 0700 ${MOKOGIT_TEMP}
|
||||
if [ ! -w ${MOKOGIT_TEMP} ]; then echo "${MOKOGIT_TEMP} is not writable"; exit 1; fi
|
||||
mkdir -p ${GITEA_TEMP} && chmod 0700 ${GITEA_TEMP}
|
||||
if [ ! -w ${GITEA_TEMP} ]; then echo "${GITEA_TEMP} is not writable"; exit 1; fi
|
||||
|
||||
#Prepare config file
|
||||
if [ ! -f ${MOKOGIT_APP_INI} ]; then
|
||||
if [ ! -f ${GITEA_APP_INI} ]; then
|
||||
|
||||
#Prepare config file folder
|
||||
MOKOGIT_APP_INI_DIR=$(dirname ${MOKOGIT_APP_INI})
|
||||
mkdir -p ${MOKOGIT_APP_INI_DIR} && chmod 0700 ${MOKOGIT_APP_INI_DIR}
|
||||
if [ ! -w ${MOKOGIT_APP_INI_DIR} ]; then echo "${MOKOGIT_APP_INI_DIR} is not writable"; exit 1; fi
|
||||
GITEA_APP_INI_DIR=$(dirname ${GITEA_APP_INI})
|
||||
mkdir -p ${GITEA_APP_INI_DIR} && chmod 0700 ${GITEA_APP_INI_DIR}
|
||||
if [ ! -w ${GITEA_APP_INI_DIR} ]; then echo "${GITEA_APP_INI_DIR} is not writable"; exit 1; fi
|
||||
|
||||
# Set INSTALL_LOCK to true only if SECRET_KEY is not empty and
|
||||
# INSTALL_LOCK is empty
|
||||
@@ -26,7 +26,7 @@ if [ ! -f ${MOKOGIT_APP_INI} ]; then
|
||||
fi
|
||||
|
||||
# Substitute the environment variables in the template
|
||||
APP_NAME=${APP_NAME:-"MokoGIT"} \
|
||||
APP_NAME=${APP_NAME:-"Gitea: Git with a cup of tea"} \
|
||||
RUN_MODE=${RUN_MODE:-"prod"} \
|
||||
RUN_USER=${USER:-"git"} \
|
||||
SSH_DOMAIN=${SSH_DOMAIN:-"localhost"} \
|
||||
@@ -44,8 +44,8 @@ if [ ! -f ${MOKOGIT_APP_INI} ]; then
|
||||
DISABLE_REGISTRATION=${DISABLE_REGISTRATION:-"false"} \
|
||||
REQUIRE_SIGNIN_VIEW=${REQUIRE_SIGNIN_VIEW:-"false"} \
|
||||
SECRET_KEY=${SECRET_KEY:-""} \
|
||||
envsubst < /etc/templates/app.ini > ${MOKOGIT_APP_INI}
|
||||
envsubst < /etc/templates/app.ini > ${GITEA_APP_INI}
|
||||
fi
|
||||
|
||||
# Replace app.ini settings with env variables in the form MOKOGIT__SECTION_NAME__KEY_NAME
|
||||
environment-to-ini --config ${MOKOGIT_APP_INI}
|
||||
# Replace app.ini settings with env variables in the form GITEA__SECTION_NAME__KEY_NAME
|
||||
environment-to-ini --config ${GITEA_APP_INI}
|
||||
|
||||
@@ -1,2 +1,2 @@
|
||||
#!/bin/bash
|
||||
exec /app/mokogit/mokogit config edit-ini --in-place --apply-env "$@"
|
||||
exec /app/gitea/gitea config edit-ini --in-place --apply-env "$@"
|
||||
|
||||
@@ -0,0 +1,40 @@
|
||||
#!/bin/bash
|
||||
|
||||
###############################################################
|
||||
# This script sets defaults for gitea to run in the container #
|
||||
###############################################################
|
||||
|
||||
# It assumes that you place this script as gitea in /usr/local/bin
|
||||
#
|
||||
# And place the original in /usr/lib/gitea with working files in /data/gitea
|
||||
GITEA="/app/gitea/gitea"
|
||||
WORK_DIR="/var/lib/gitea"
|
||||
APP_INI="/etc/gitea/app.ini"
|
||||
|
||||
APP_INI_SET=""
|
||||
for i in "$@"; do
|
||||
case "$i" in
|
||||
"-c")
|
||||
APP_INI_SET=1
|
||||
;;
|
||||
"-c="*)
|
||||
APP_INI_SET=1
|
||||
;;
|
||||
"--config")
|
||||
APP_INI_SET=1
|
||||
;;
|
||||
"--config="*)
|
||||
APP_INI_SET=1
|
||||
;;
|
||||
*)
|
||||
;;
|
||||
esac
|
||||
done
|
||||
|
||||
if [ -z "$APP_INI_SET" ]; then
|
||||
CONF_ARG=("-c" "${GITEA_APP_INI:-$APP_INI}")
|
||||
fi
|
||||
|
||||
|
||||
# Provide docker defaults
|
||||
GITEA_WORK_DIR="${GITEA_WORK_DIR:-$WORK_DIR}" exec -a "$0" "$GITEA" "${CONF_ARG[@]}" "$@"
|
||||
@@ -1,40 +0,0 @@
|
||||
#!/bin/bash
|
||||
|
||||
#################################################################
|
||||
# This script sets defaults for mokogit to run in the container #
|
||||
#################################################################
|
||||
|
||||
# It assumes that you place this script as mokogit in /usr/local/bin
|
||||
#
|
||||
# And place the original in /usr/lib/mokogit with working files in /var/lib/mokogit
|
||||
MOKOGIT="/app/mokogit/mokogit"
|
||||
WORK_DIR="/var/lib/mokogit"
|
||||
APP_INI="/etc/mokogit/app.ini"
|
||||
|
||||
APP_INI_SET=""
|
||||
for i in "$@"; do
|
||||
case "$i" in
|
||||
"-c")
|
||||
APP_INI_SET=1
|
||||
;;
|
||||
"-c="*)
|
||||
APP_INI_SET=1
|
||||
;;
|
||||
"--config")
|
||||
APP_INI_SET=1
|
||||
;;
|
||||
"--config="*)
|
||||
APP_INI_SET=1
|
||||
;;
|
||||
*)
|
||||
;;
|
||||
esac
|
||||
done
|
||||
|
||||
if [ -z "$APP_INI_SET" ]; then
|
||||
CONF_ARG=("-c" "${MOKOGIT_APP_INI:-$APP_INI}")
|
||||
fi
|
||||
|
||||
|
||||
# Provide docker defaults
|
||||
MOKOGIT_WORK_DIR="${MOKOGIT_WORK_DIR:-$WORK_DIR}" exec -a "$0" "$MOKOGIT" "${CONF_ARG[@]}" "$@"
|
||||
@@ -9,6 +9,7 @@ godebug x509negativeserial=1
|
||||
|
||||
require (
|
||||
code.gitea.io/actions-proto-go v0.4.1
|
||||
code.gitea.io/gitea v1.26.2
|
||||
code.gitea.io/sdk/gitea v0.24.1
|
||||
codeberg.org/gusted/mcaptcha v0.0.0-20220723083913-4f3072e1d570
|
||||
connectrpc.com/connect v1.19.1
|
||||
|
||||
@@ -40,9 +40,7 @@ type ActionRunJob struct {
|
||||
|
||||
// WorkflowPayload is act/jobparser.SingleWorkflow for act/jobparser.Parse
|
||||
// it should contain exactly one job with global workflow fields for this model
|
||||
// MEDIUMBLOB: an untyped []byte maps to a 64 KiB BLOB on MySQL/MariaDB; large
|
||||
// single-job workflows overflow it and InsertRun fails (see migration 371).
|
||||
WorkflowPayload []byte `xorm:"MEDIUMBLOB"`
|
||||
WorkflowPayload []byte
|
||||
|
||||
JobID string `xorm:"VARCHAR(255)"` // job id in workflow, not job's id
|
||||
Needs []string `xorm:"JSON TEXT"`
|
||||
|
||||
@@ -448,8 +448,6 @@ func prepareMigrationTasks() []*migration {
|
||||
newMigration(368, "Drop org from repo manifest (derived from org profile)", v1_27.DropOrgFromRepoManifest),
|
||||
newMigration(369, "Rename mokogitea-actions system user to mokogit-actions", v1_27.RenameActionsUserToMokoGit),
|
||||
newMigration(370, "Remap saved gitea-* user themes to mokogit-*", v1_27.RemapGiteaThemesToMokogit),
|
||||
newMigration(371, "Widen action_run_job.workflow_payload to MEDIUMBLOB", v1_27.WidenActionRunJobWorkflowPayload),
|
||||
newMigration(372, "Add npm/mcp fields to repo manifest", v1_27.AddNpmFieldsToRepoManifest),
|
||||
}
|
||||
return preparedMigrations
|
||||
}
|
||||
|
||||
@@ -1,30 +0,0 @@
|
||||
// Copyright 2026 Moko Consulting <hello@mokoconsulting.tech>
|
||||
// SPDX-License-Identifier: GPL-3.0-or-later
|
||||
|
||||
package v1_27
|
||||
|
||||
import (
|
||||
"xorm.io/xorm"
|
||||
"xorm.io/xorm/schemas"
|
||||
)
|
||||
|
||||
// WidenActionRunJobWorkflowPayload widens action_run_job.workflow_payload on
|
||||
// MySQL/MariaDB from the default BLOB (64 KiB) to MEDIUMBLOB (16 MiB).
|
||||
//
|
||||
// ActionRunJob.WorkflowPayload was declared as an untyped []byte, so xorm created
|
||||
// a plain BLOB. At run creation the whole SingleWorkflow is interpolated (every
|
||||
// ${{ vars.* }} / git-context) and marshaled into this column; large single-job
|
||||
// workflows (e.g. deploy-*.yml with big inline SSH scripts and many vars) exceed
|
||||
// 64 KiB, so InsertRun fails with MySQL error 1406 "Data too long for column
|
||||
// 'workflow_payload'". Because workflow_dispatch returns 204 before that async
|
||||
// insert runs, the run is silently dropped ("204 but no run" — issue #815).
|
||||
//
|
||||
// Postgres (bytea) and SQLite (BLOB) have no practical size limit, so this is a
|
||||
// no-op there.
|
||||
func WidenActionRunJobWorkflowPayload(x *xorm.Engine) error {
|
||||
if x.Dialect().URI().DBType != schemas.MYSQL {
|
||||
return nil
|
||||
}
|
||||
_, err := x.Exec("ALTER TABLE `action_run_job` MODIFY COLUMN `workflow_payload` MEDIUMBLOB")
|
||||
return err
|
||||
}
|
||||
@@ -1,23 +0,0 @@
|
||||
// Copyright 2026 Moko Consulting <hello@mokoconsulting.tech>
|
||||
// SPDX-License-Identifier: GPL-3.0-or-later
|
||||
|
||||
package v1_27
|
||||
|
||||
import (
|
||||
"xorm.io/xorm"
|
||||
)
|
||||
|
||||
// AddNpmFieldsToRepoManifest adds npm/mcp metadata columns to repo_manifest so
|
||||
// the PUT /api/v1/repos/{owner}/{repo}/metadata handler can persist them
|
||||
// instead of silently dropping them. See issue #363.
|
||||
func AddNpmFieldsToRepoManifest(x *xorm.Engine) error {
|
||||
type RepoManifest struct {
|
||||
NodeMinimum string `xorm:"VARCHAR(20) 'node_minimum'"`
|
||||
NpmPackage string `xorm:"TEXT 'npm_package'"`
|
||||
NpmScope string `xorm:"VARCHAR(100) 'npm_scope'"`
|
||||
RegistryURL string `xorm:"TEXT 'registry_url'"`
|
||||
Bin string `xorm:"TEXT 'bin'"`
|
||||
PublishTarget string `xorm:"VARCHAR(50) 'publish_target'"`
|
||||
}
|
||||
return x.Sync(new(RepoManifest))
|
||||
}
|
||||
@@ -52,14 +52,6 @@ type RepoMetadata struct {
|
||||
ExtensionType string `xorm:"VARCHAR(50) 'extension_type'"` // component, module, plugin, package, template, library, file
|
||||
EntryPoint string `xorm:"TEXT 'entry_point'"` // build entry point path
|
||||
|
||||
// npm/mcp section (used by node/npm publish workflows and mokocli)
|
||||
NodeMinimum string `xorm:"VARCHAR(20) 'node_minimum'"` // minimum Node.js version, e.g. "18"
|
||||
NpmPackage string `xorm:"TEXT 'npm_package'"` // published npm package name, e.g. "@moko/foo"
|
||||
NpmScope string `xorm:"VARCHAR(100) 'npm_scope'"` // npm scope, e.g. "@moko"
|
||||
RegistryURL string `xorm:"TEXT 'registry_url'"` // npm registry URL
|
||||
Bin string `xorm:"TEXT 'bin'"` // bin entry (name or JSON map)
|
||||
PublishTarget string `xorm:"VARCHAR(50) 'publish_target'"` // publish target, e.g. "npm", "registry"
|
||||
|
||||
// deploy section
|
||||
DeployHost string `xorm:"VARCHAR(255) 'deploy_host'"` // SSH host for deploy
|
||||
DeployPort string `xorm:"VARCHAR(10) 'deploy_port'"` // SSH port (default 2918)
|
||||
|
||||
@@ -1,119 +0,0 @@
|
||||
// Copyright 2026 Moko Consulting <hello@mokoconsulting.tech>
|
||||
// SPDX-License-Identifier: GPL-3.0-or-later
|
||||
|
||||
package updateserver
|
||||
|
||||
import (
|
||||
"strings"
|
||||
|
||||
"code.mokoconsulting.tech/MokoConsulting/MokoGIT/modules/setting"
|
||||
)
|
||||
|
||||
// Update-feed platform identifiers. These are the recognized values for the
|
||||
// UpdateStreamConfig.Platform column and for the resolved "RepoUpdatePlatform"
|
||||
// context value used by the Serve* update-feed handlers.
|
||||
//
|
||||
// The Platform column is a plain string (no DB-level enum/CHECK constraint), so
|
||||
// these constants are enforced at the application layer only — adding new values
|
||||
// requires no schema migration.
|
||||
const (
|
||||
PlatformJoomla = "joomla"
|
||||
PlatformDolibarr = "dolibarr"
|
||||
PlatformBoth = "both" // joomla + dolibarr
|
||||
PlatformWordPress = "wordpress"
|
||||
PlatformPrestaShop = "prestashop"
|
||||
PlatformDrupal = "drupal"
|
||||
PlatformComposer = "composer"
|
||||
PlatformWHMCS = "whmcs"
|
||||
|
||||
// Feedless platforms: repositories whose distribution channel is an external
|
||||
// package registry (npm, MCP). They must NOT emit any Joomla/Dolibarr/etc.
|
||||
// update feed — the Serve* handlers return NotFound for these. See #810.
|
||||
PlatformNPM = "npm"
|
||||
PlatformMCP = "mcp"
|
||||
)
|
||||
|
||||
// feedlessPlatforms are the statically-known platforms that never emit a legacy
|
||||
// update feed. This is a back-compat fallback for the registry lookup below: the
|
||||
// authoritative signal is the platform registry's feed_format == "none", which
|
||||
// also covers "go" and any admin-configured feedless platform. See #811.
|
||||
var feedlessPlatforms = map[string]struct{}{
|
||||
PlatformNPM: {},
|
||||
PlatformMCP: {},
|
||||
}
|
||||
|
||||
// IsFeedlessPlatform reports whether the given platform must not serve any
|
||||
// update feed. A platform is feedless when the platform registry gives it no
|
||||
// wire format (feed_format == "none"). In the built-in registry that is npm /
|
||||
// mcp / go (npm & mcp publish to the npm registry; go publishes via git-release)
|
||||
// plus any admin-configured feedless platform. These repositories are
|
||||
// distributed through an external channel, so every Serve* handler returns
|
||||
// NotFound for them. See #810 / #811.
|
||||
//
|
||||
// Note: feed_format (NOT update_generator) is the authoritative signal. npm/mcp
|
||||
// carry update_generator == "npm" (their build/publish generator), but their
|
||||
// feed_format is "none" because the update server emits no feed for them.
|
||||
//
|
||||
// The registry is the single source of truth. The static feedlessPlatforms map
|
||||
// is only consulted as a defensive fallback (e.g. for a key unknown to the
|
||||
// registry) so a bare "npm"/"mcp" is always treated as feedless.
|
||||
func IsFeedlessPlatform(platform string) bool {
|
||||
key := strings.ToLower(strings.TrimSpace(platform))
|
||||
if key == "" {
|
||||
return false
|
||||
}
|
||||
// Registry-driven: feed_format == "none" means no legacy feed is emitted.
|
||||
// This is what makes npm/mcp/go feedless from a single config source.
|
||||
if def, ok := setting.GetPlatform(key); ok {
|
||||
if strings.EqualFold(strings.TrimSpace(def.FeedFormat), "none") {
|
||||
return true
|
||||
}
|
||||
// Known registry entry that DOES serve a feed (joomla, dolibarr, …).
|
||||
return false
|
||||
}
|
||||
// Unknown to the registry: fall back to the static feedless set.
|
||||
_, ok := feedlessPlatforms[key]
|
||||
return ok
|
||||
}
|
||||
|
||||
// ResolvePlatform determines the effective update-feed platform for a repo.
|
||||
//
|
||||
// Precedence (see #811 for why metadata can override the config row):
|
||||
//
|
||||
// - If the repo metadata platform (metadata.platform) is a registry-recognized
|
||||
// FEEDLESS platform (feed_format == "none": npm / mcp / go, plus any
|
||||
// admin-configured feedless platform), it ALWAYS wins. This is the #811 fix:
|
||||
// the update_stream_config.Platform column is `NOT NULL DEFAULT 'joomla'`, so
|
||||
// any licensing-enabled repo has a config row that resolves to "joomla" even
|
||||
// when it is really an npm/mcp/go repo. Letting a feedless metadata platform
|
||||
// win means those repos return NotFound instead of a bogus Joomla feed.
|
||||
// - Otherwise, an explicit update-stream config platform wins (this preserves a
|
||||
// genuine, deliberate override such as dolibarr/wordpress/etc.).
|
||||
// - Otherwise the platform is derived from the repository metadata platform, so
|
||||
// the two stores can no longer drift. See #811.
|
||||
// - Only when neither source is set do we fall back to the historical "joomla"
|
||||
// default (used by legacy Joomla extension repos).
|
||||
//
|
||||
// Joomla-preservation reasoning: a genuine Joomla repo has metadata.platform ==
|
||||
// "joomla" (or empty), which is NOT feedless, so the config platform still wins
|
||||
// and the Joomla feed is served exactly as before. The only behavior that
|
||||
// changes is that a repo whose metadata says npm/mcp/go no longer serves a feed
|
||||
// just because it carries a default-'joomla' config row.
|
||||
//
|
||||
// This is the single source of truth for the old "empty ⇒ joomla" fallback,
|
||||
// which previously caused npm/mcp repos to emit a Joomla feed. See #810 and #811.
|
||||
func ResolvePlatform(cfgPlatform, metadataPlatform string) string {
|
||||
meta := strings.ToLower(strings.TrimSpace(metadataPlatform))
|
||||
// #811: a recognized feedless metadata platform overrides the config row,
|
||||
// including the default-'joomla' row every licensing-enabled repo carries.
|
||||
if meta != "" && IsFeedlessPlatform(meta) {
|
||||
return meta
|
||||
}
|
||||
if p := strings.ToLower(strings.TrimSpace(cfgPlatform)); p != "" {
|
||||
return p
|
||||
}
|
||||
if meta != "" {
|
||||
return meta
|
||||
}
|
||||
return PlatformJoomla
|
||||
}
|
||||
@@ -14,16 +14,17 @@ import (
|
||||
)
|
||||
|
||||
const (
|
||||
// EnvConfigKeyPrefixMokoGit is the MokoGIT-branded env override prefix. The
|
||||
// legacy upstream GITEA__ prefix fallback has been retired: deployments must
|
||||
// set MOKOGIT__* override vars (coordinated rebrand cutover).
|
||||
EnvConfigKeyPrefixGitea = "GITEA__"
|
||||
// EnvConfigKeyPrefixMokoGit is the MokoGIT-branded env override prefix. It is
|
||||
// accepted alongside the upstream GITEA__ prefix so config keeps working whether
|
||||
// the deployment sets GITEA__* or MOKOGIT__* (coordinated rebrand transition).
|
||||
EnvConfigKeyPrefixMokoGit = "MOKOGIT__"
|
||||
EnvConfigKeySuffixFile = "__FILE"
|
||||
)
|
||||
|
||||
// envConfigKeyPrefixes lists the accepted env-override prefixes. A given env var
|
||||
// starts with exactly one of them, so the order does not affect precedence.
|
||||
var envConfigKeyPrefixes = []string{EnvConfigKeyPrefixMokoGit}
|
||||
var envConfigKeyPrefixes = []string{EnvConfigKeyPrefixMokoGit, EnvConfigKeyPrefixGitea}
|
||||
|
||||
const escapeRegexpString = "_0[xX](([0-9a-fA-F][0-9a-fA-F])+)_"
|
||||
|
||||
@@ -106,16 +107,16 @@ func decodeEnvSectionKey(encoded string) (ok bool, section, key string) {
|
||||
}
|
||||
|
||||
// decodeEnvironmentKey decode the environment key to section and key
|
||||
// The environment key is in the form of MOKOGIT__SECTION__KEY or MOKOGIT__SECTION__KEY__FILE
|
||||
func decodeEnvironmentKey(prefix, suffixFile, envKey string) (ok bool, section, key string, useFileValue bool) {
|
||||
if !strings.HasPrefix(envKey, prefix) {
|
||||
// The environment key is in the form of GITEA__SECTION__KEY or GITEA__SECTION__KEY__FILE
|
||||
func decodeEnvironmentKey(prefixGitea, suffixFile, envKey string) (ok bool, section, key string, useFileValue bool) {
|
||||
if !strings.HasPrefix(envKey, prefixGitea) {
|
||||
return false, "", "", false
|
||||
}
|
||||
if strings.HasSuffix(envKey, suffixFile) {
|
||||
useFileValue = true
|
||||
envKey = envKey[:len(envKey)-len(suffixFile)]
|
||||
}
|
||||
ok, section, key = decodeEnvSectionKey(envKey[len(prefix):])
|
||||
ok, section, key = decodeEnvSectionKey(envKey[len(prefixGitea):])
|
||||
return ok, section, key, useFileValue
|
||||
}
|
||||
|
||||
|
||||
@@ -33,7 +33,7 @@ func TestDecodeEnvSectionKey(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestDecodeEnvironmentKey(t *testing.T) {
|
||||
prefix := "MOKOGIT__"
|
||||
prefix := "GITEA__"
|
||||
suffix := "__FILE"
|
||||
|
||||
ok, section, key, file := decodeEnvironmentKey(prefix, suffix, "SEC__KEY")
|
||||
@@ -42,33 +42,33 @@ func TestDecodeEnvironmentKey(t *testing.T) {
|
||||
assert.Empty(t, key)
|
||||
assert.False(t, file)
|
||||
|
||||
ok, section, key, file = decodeEnvironmentKey(prefix, suffix, "MOKOGIT__SEC")
|
||||
ok, section, key, file = decodeEnvironmentKey(prefix, suffix, "GITEA__SEC")
|
||||
assert.False(t, ok)
|
||||
assert.Empty(t, section)
|
||||
assert.Empty(t, key)
|
||||
assert.False(t, file)
|
||||
|
||||
ok, section, key, file = decodeEnvironmentKey(prefix, suffix, "MOKOGIT____KEY")
|
||||
ok, section, key, file = decodeEnvironmentKey(prefix, suffix, "GITEA____KEY")
|
||||
assert.True(t, ok)
|
||||
assert.Empty(t, section)
|
||||
assert.Equal(t, "KEY", key)
|
||||
assert.False(t, file)
|
||||
|
||||
ok, section, key, file = decodeEnvironmentKey(prefix, suffix, "MOKOGIT__SEC__KEY")
|
||||
ok, section, key, file = decodeEnvironmentKey(prefix, suffix, "GITEA__SEC__KEY")
|
||||
assert.True(t, ok)
|
||||
assert.Equal(t, "sec", section)
|
||||
assert.Equal(t, "KEY", key)
|
||||
assert.False(t, file)
|
||||
|
||||
// with "__FILE" suffix, it doesn't support to write "[sec].FILE" to config (no such key FILE is used)
|
||||
// but it could be fixed in the future by adding a new suffix like "__VALUE" (no such key VALUE is used either)
|
||||
ok, section, key, file = decodeEnvironmentKey(prefix, suffix, "MOKOGIT__SEC__FILE")
|
||||
// with "__FILE" suffix, it doesn't support to write "[sec].FILE" to config (no such key FILE is used in Gitea)
|
||||
// but it could be fixed in the future by adding a new suffix like "__VALUE" (no such key VALUE is used in Gitea either)
|
||||
ok, section, key, file = decodeEnvironmentKey(prefix, suffix, "GITEA__SEC__FILE")
|
||||
assert.False(t, ok)
|
||||
assert.Empty(t, section)
|
||||
assert.Empty(t, key)
|
||||
assert.True(t, file)
|
||||
|
||||
ok, section, key, file = decodeEnvironmentKey(prefix, suffix, "MOKOGIT__SEC__KEY__FILE")
|
||||
ok, section, key, file = decodeEnvironmentKey(prefix, suffix, "GITEA__SEC__KEY__FILE")
|
||||
assert.True(t, ok)
|
||||
assert.Equal(t, "sec", section)
|
||||
assert.Equal(t, "KEY", key)
|
||||
@@ -90,37 +90,37 @@ key = old
|
||||
`)
|
||||
assert.NoError(t, err)
|
||||
|
||||
changed = EnvironmentToConfig(cfg, []string{"MOKOGIT__sec__key=new"})
|
||||
changed = EnvironmentToConfig(cfg, []string{"GITEA__sec__key=new"})
|
||||
assert.True(t, changed)
|
||||
assert.Equal(t, "new", cfg.Section("sec").Key("key").String())
|
||||
|
||||
changed = EnvironmentToConfig(cfg, []string{"MOKOGIT__sec__key=new"})
|
||||
changed = EnvironmentToConfig(cfg, []string{"GITEA__sec__key=new"})
|
||||
assert.False(t, changed)
|
||||
|
||||
// the legacy GITEA__ prefix is no longer accepted (rebrand cutover)
|
||||
changed = EnvironmentToConfig(cfg, []string{"GITEA__sec__key=gitea-new"})
|
||||
assert.False(t, changed)
|
||||
assert.Equal(t, "new", cfg.Section("sec").Key("key").String())
|
||||
// the MOKOGIT__ prefix is accepted alongside GITEA__ (rebrand transition)
|
||||
changed = EnvironmentToConfig(cfg, []string{"MOKOGIT__sec__key=mokogit-new"})
|
||||
assert.True(t, changed)
|
||||
assert.Equal(t, "mokogit-new", cfg.Section("sec").Key("key").String())
|
||||
|
||||
tmpFile := t.TempDir() + "/the-file"
|
||||
_ = os.WriteFile(tmpFile, []byte("value-from-file"), 0o644)
|
||||
changed = EnvironmentToConfig(cfg, []string{"MOKOGIT__sec__key__FILE=" + tmpFile})
|
||||
changed = EnvironmentToConfig(cfg, []string{"GITEA__sec__key__FILE=" + tmpFile})
|
||||
assert.True(t, changed)
|
||||
assert.Equal(t, "value-from-file", cfg.Section("sec").Key("key").String())
|
||||
|
||||
cfg, _ = NewConfigProviderFromData("")
|
||||
_ = os.WriteFile(tmpFile, []byte("value-from-file\n"), 0o644)
|
||||
EnvironmentToConfig(cfg, []string{"MOKOGIT__sec__key__FILE=" + tmpFile})
|
||||
EnvironmentToConfig(cfg, []string{"GITEA__sec__key__FILE=" + tmpFile})
|
||||
assert.Equal(t, "value-from-file", cfg.Section("sec").Key("key").String())
|
||||
|
||||
cfg, _ = NewConfigProviderFromData("")
|
||||
_ = os.WriteFile(tmpFile, []byte("value-from-file\r\n"), 0o644)
|
||||
EnvironmentToConfig(cfg, []string{"MOKOGIT__sec__key__FILE=" + tmpFile})
|
||||
EnvironmentToConfig(cfg, []string{"GITEA__sec__key__FILE=" + tmpFile})
|
||||
assert.Equal(t, "value-from-file", cfg.Section("sec").Key("key").String())
|
||||
|
||||
cfg, _ = NewConfigProviderFromData("")
|
||||
_ = os.WriteFile(tmpFile, []byte("value-from-file\n\n"), 0o644)
|
||||
EnvironmentToConfig(cfg, []string{"MOKOGIT__sec__key__FILE=" + tmpFile})
|
||||
EnvironmentToConfig(cfg, []string{"GITEA__sec__key__FILE=" + tmpFile})
|
||||
assert.Equal(t, "value-from-file\n", cfg.Section("sec").Key("key").String())
|
||||
}
|
||||
|
||||
@@ -133,7 +133,7 @@ key = some
|
||||
`)
|
||||
assert.NoError(t, err)
|
||||
|
||||
changed := EnvironmentToConfig(cfg, []string{"MOKOGIT__sec_0X2E_sub__key=some"})
|
||||
changed := EnvironmentToConfig(cfg, []string{"GITEA__sec_0X2E_sub__key=some"})
|
||||
assert.True(t, changed)
|
||||
|
||||
tmpFile := t.TempDir() + "/test-sub-sec-key.ini"
|
||||
|
||||
@@ -19,8 +19,4 @@ func loadMetadataFrom(rootCfg ConfigProvider) {
|
||||
if opts := sec.Key("PLATFORM_OPTIONS").Strings(","); len(opts) > 0 {
|
||||
Metadata.PlatformOptions = opts
|
||||
}
|
||||
|
||||
// Load the structured platform registry ([metadata] PLATFORM_REGISTRY).
|
||||
// Falls back to a built-in default reconciled with PLATFORM_OPTIONS.
|
||||
loadPlatformRegistryFrom(rootCfg)
|
||||
}
|
||||
|
||||
@@ -18,11 +18,11 @@ var (
|
||||
// AppPath represents the path to the gitea binary
|
||||
AppPath string
|
||||
|
||||
// AppWorkPath is the "working directory" of MokoGIT. It maps to the: WORK_PATH in app.ini, "--work-path" flag, environment variable MOKOGIT_WORK_DIR.
|
||||
// AppWorkPath is the "working directory" of Gitea. It maps to the: WORK_PATH in app.ini, "--work-path" flag, environment variable GITEA_WORK_DIR.
|
||||
// If that is not set it is the default set here by the linker or failing that the directory of AppPath.
|
||||
// It is used as the base path for several other paths.
|
||||
AppWorkPath string
|
||||
CustomPath string // Custom directory path. Env: MOKOGIT_CUSTOM
|
||||
CustomPath string // Custom directory path. Env: GITEA_CUSTOM
|
||||
CustomConf string
|
||||
|
||||
appWorkPathBuiltin string
|
||||
@@ -122,19 +122,19 @@ func InitWorkPathAndCfgProvider(getEnvFn func(name string) string, args ArgWorkP
|
||||
}
|
||||
|
||||
readFromEnv := func() {
|
||||
envWorkPath := getEnvFn("MOKOGIT_WORK_DIR")
|
||||
envWorkPath := getEnvFn("GITEA_WORK_DIR")
|
||||
if envWorkPath != "" {
|
||||
tmpWorkPath.Set(envWorkPath)
|
||||
if !filepath.IsAbs(tmpWorkPath.Value) {
|
||||
log.Fatal("MOKOGIT_WORK_DIR (work path) must be absolute path")
|
||||
log.Fatal("GITEA_WORK_DIR (work path) must be absolute path")
|
||||
}
|
||||
}
|
||||
|
||||
envCustomPath := getEnvFn("MOKOGIT_CUSTOM")
|
||||
envCustomPath := getEnvFn("GITEA_CUSTOM")
|
||||
if envCustomPath != "" {
|
||||
tmpCustomPath.Set(envCustomPath)
|
||||
if !filepath.IsAbs(tmpCustomPath.Value) {
|
||||
log.Fatal("MOKOGIT_CUSTOM (custom path) must be absolute path")
|
||||
log.Fatal("GITEA_CUSTOM (custom path) must be absolute path")
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -181,7 +181,7 @@ func InitWorkPathAndCfgProvider(getEnvFn func(name string) string, args ArgWorkP
|
||||
log.Fatal("WORK_PATH in %q must be absolute path", configWorkPath)
|
||||
}
|
||||
configWorkPath = filepath.Clean(configWorkPath)
|
||||
if tmpWorkPath.Value != "" && (getEnvFn("MOKOGIT_WORK_DIR") != "" || args.WorkPath != "") {
|
||||
if tmpWorkPath.Value != "" && (getEnvFn("GITEA_WORK_DIR") != "" || args.WorkPath != "") {
|
||||
fi1, err1 := os.Stat(tmpWorkPath.Value)
|
||||
fi2, err2 := os.Stat(configWorkPath)
|
||||
if err1 != nil || err2 != nil || !os.SameFile(fi1, fi2) {
|
||||
|
||||
@@ -46,7 +46,7 @@ func TestInitWorkPathAndCommonConfig(t *testing.T) {
|
||||
|
||||
t.Run("WorkDir(env)", func(t *testing.T) {
|
||||
testInit(dirFoo, "", "")
|
||||
InitWorkPathAndCommonConfig(envVars{"MOKOGIT_WORK_DIR": dirBar}.Getenv, ArgWorkPathAndCustomConf{})
|
||||
InitWorkPathAndCommonConfig(envVars{"GITEA_WORK_DIR": dirBar}.Getenv, ArgWorkPathAndCustomConf{})
|
||||
assert.Equal(t, dirBar, AppWorkPath)
|
||||
assert.Equal(t, fp(dirBar, "custom"), CustomPath)
|
||||
assert.Equal(t, fp(dirBar, "custom/conf/app.ini"), CustomConf)
|
||||
@@ -54,7 +54,7 @@ func TestInitWorkPathAndCommonConfig(t *testing.T) {
|
||||
|
||||
t.Run("WorkDir(env,arg)", func(t *testing.T) {
|
||||
testInit(dirFoo, "", "")
|
||||
InitWorkPathAndCommonConfig(envVars{"MOKOGIT_WORK_DIR": dirBar}.Getenv, ArgWorkPathAndCustomConf{WorkPath: dirXxx})
|
||||
InitWorkPathAndCommonConfig(envVars{"GITEA_WORK_DIR": dirBar}.Getenv, ArgWorkPathAndCustomConf{WorkPath: dirXxx})
|
||||
assert.Equal(t, dirXxx, AppWorkPath)
|
||||
assert.Equal(t, fp(dirXxx, "custom"), CustomPath)
|
||||
assert.Equal(t, fp(dirXxx, "custom/conf/app.ini"), CustomConf)
|
||||
@@ -62,7 +62,7 @@ func TestInitWorkPathAndCommonConfig(t *testing.T) {
|
||||
|
||||
t.Run("CustomPath(env)", func(t *testing.T) {
|
||||
testInit(dirFoo, "", "")
|
||||
InitWorkPathAndCommonConfig(envVars{"MOKOGIT_CUSTOM": fp(dirBar, "custom1")}.Getenv, ArgWorkPathAndCustomConf{})
|
||||
InitWorkPathAndCommonConfig(envVars{"GITEA_CUSTOM": fp(dirBar, "custom1")}.Getenv, ArgWorkPathAndCustomConf{})
|
||||
assert.Equal(t, dirFoo, AppWorkPath)
|
||||
assert.Equal(t, fp(dirBar, "custom1"), CustomPath)
|
||||
assert.Equal(t, fp(dirBar, "custom1/conf/app.ini"), CustomConf)
|
||||
@@ -70,7 +70,7 @@ func TestInitWorkPathAndCommonConfig(t *testing.T) {
|
||||
|
||||
t.Run("CustomPath(env,arg)", func(t *testing.T) {
|
||||
testInit(dirFoo, "", "")
|
||||
InitWorkPathAndCommonConfig(envVars{"MOKOGIT_CUSTOM": fp(dirBar, "custom1")}.Getenv, ArgWorkPathAndCustomConf{CustomPath: "custom2"})
|
||||
InitWorkPathAndCommonConfig(envVars{"GITEA_CUSTOM": fp(dirBar, "custom1")}.Getenv, ArgWorkPathAndCustomConf{CustomPath: "custom2"})
|
||||
assert.Equal(t, dirFoo, AppWorkPath)
|
||||
assert.Equal(t, fp(dirFoo, "custom2"), CustomPath)
|
||||
assert.Equal(t, fp(dirFoo, "custom2/conf/app.ini"), CustomConf)
|
||||
@@ -101,7 +101,7 @@ func TestInitWorkPathAndCommonConfig(t *testing.T) {
|
||||
assert.False(t, AppWorkPathMismatch)
|
||||
|
||||
testInit(dirFoo, "", "")
|
||||
InitWorkPathAndCommonConfig(envVars{"MOKOGIT_WORK_DIR": dirBar}.Getenv, ArgWorkPathAndCustomConf{CustomConf: iniWorkPath})
|
||||
InitWorkPathAndCommonConfig(envVars{"GITEA_WORK_DIR": dirBar}.Getenv, ArgWorkPathAndCustomConf{CustomConf: iniWorkPath})
|
||||
assert.Equal(t, dirXxx, AppWorkPath)
|
||||
assert.Equal(t, fp(dirXxx, "custom"), CustomPath)
|
||||
assert.Equal(t, iniWorkPath, CustomConf)
|
||||
@@ -129,13 +129,13 @@ func TestInitWorkPathAndCommonConfig(t *testing.T) {
|
||||
assert.Equal(t, fp(dirFoo, "custom1/cfg.ini"), CustomConf)
|
||||
|
||||
testInit(dirFoo, "custom1", "cfg.ini")
|
||||
InitWorkPathAndCommonConfig(envVars{"MOKOGIT_WORK_DIR": dirYyy}.Getenv, ArgWorkPathAndCustomConf{})
|
||||
InitWorkPathAndCommonConfig(envVars{"GITEA_WORK_DIR": dirYyy}.Getenv, ArgWorkPathAndCustomConf{})
|
||||
assert.Equal(t, dirYyy, AppWorkPath)
|
||||
assert.Equal(t, fp(dirYyy, "custom1"), CustomPath)
|
||||
assert.Equal(t, fp(dirYyy, "custom1/cfg.ini"), CustomConf)
|
||||
|
||||
testInit(dirFoo, "custom1", "cfg.ini")
|
||||
InitWorkPathAndCommonConfig(envVars{"MOKOGIT_CUSTOM": dirYyy}.Getenv, ArgWorkPathAndCustomConf{})
|
||||
InitWorkPathAndCommonConfig(envVars{"GITEA_CUSTOM": dirYyy}.Getenv, ArgWorkPathAndCustomConf{})
|
||||
assert.Equal(t, dirFoo, AppWorkPath)
|
||||
assert.Equal(t, dirYyy, CustomPath)
|
||||
assert.Equal(t, fp(dirYyy, "cfg.ini"), CustomConf)
|
||||
|
||||
@@ -1,255 +0,0 @@
|
||||
// Copyright 2026 Moko Consulting <hello@mokoconsulting.tech>
|
||||
// SPDX-License-Identifier: GPL-3.0-or-later
|
||||
|
||||
package setting
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"strings"
|
||||
)
|
||||
|
||||
// PlatformDef is a single platform's capability record in the platform registry.
|
||||
//
|
||||
// A platform key (matching repo_manifest.platform and UpdateStreamConfig.Platform)
|
||||
// carries the capability attributes that CI, the update server, and the workflow
|
||||
// sync tooling read instead of hardcoding per-platform behavior. Only Key is
|
||||
// required; every other field has a sensible zero/default so a bare key still
|
||||
// yields a usable (generic) record.
|
||||
//
|
||||
// This registry is NON-SECRET capability config only. It never carries
|
||||
// credentials, tokens, or deploy keys.
|
||||
type PlatformDef struct {
|
||||
// Key is the stable lowercase identifier (e.g. "joomla"). Matches
|
||||
// repo_manifest.platform and UpdateStreamConfig.Platform.
|
||||
Key string `json:"key"`
|
||||
// Label is the human-readable display name.
|
||||
Label string `json:"label,omitempty"`
|
||||
// Aliases are alternate keys matched (by prefix) in the release gate,
|
||||
// e.g. joomla5, joomla6.
|
||||
Aliases []string `json:"aliases,omitempty"`
|
||||
// Family groups related platforms: joomla | dolibarr | node | go | generic | dot.
|
||||
Family string `json:"family,omitempty"`
|
||||
// Artifact reports whether the platform produces a build artifact.
|
||||
Artifact bool `json:"artifact"`
|
||||
// UpdateGenerator names the update-feed generator the update server uses:
|
||||
// joomla | dolibarr | wordpress | composer | prestashop | drupal | whmcs | npm | none.
|
||||
UpdateGenerator string `json:"update_generator,omitempty"`
|
||||
// FeedFormat is the update-feed wire format: xml | json | none.
|
||||
FeedFormat string `json:"feed_format,omitempty"`
|
||||
// TemplateRepo is the workflow-template source repo (e.g. Template-Joomla).
|
||||
TemplateRepo string `json:"template_repo,omitempty"`
|
||||
// ManifestBased reports whether a manifest is parsed for element/version.
|
||||
ManifestBased bool `json:"manifest_based"`
|
||||
// PublishTarget names where artifacts are published (e.g. npm, updateserver, git-release).
|
||||
PublishTarget string `json:"publish_target,omitempty"`
|
||||
// DetectGlobs are file-pattern globs used to auto-detect this platform.
|
||||
DetectGlobs []string `json:"detect_globs,omitempty"`
|
||||
}
|
||||
|
||||
// Platforms holds the loaded platform registry indexed by key (lowercase).
|
||||
// It is populated by loadMetadataFrom at startup. Callers should use
|
||||
// PlatformRegistry(), GetPlatform() and PlatformList() rather than reading the
|
||||
// map directly.
|
||||
var platformRegistry map[string]*PlatformDef
|
||||
|
||||
// PlatformRegistry returns the loaded registry as a key->def map. Never nil.
|
||||
func PlatformRegistry() map[string]*PlatformDef {
|
||||
if platformRegistry == nil {
|
||||
platformRegistry = buildDefaultRegistry(Metadata.PlatformOptions)
|
||||
}
|
||||
return platformRegistry
|
||||
}
|
||||
|
||||
// PlatformList returns registry entries in the order of Metadata.PlatformOptions
|
||||
// (falling back to a stable built-in order for any extra keys).
|
||||
func PlatformList() []*PlatformDef {
|
||||
reg := PlatformRegistry()
|
||||
out := make([]*PlatformDef, 0, len(reg))
|
||||
seen := make(map[string]bool, len(reg))
|
||||
// Preserve admin-configured order first.
|
||||
for _, k := range Metadata.PlatformOptions {
|
||||
k = strings.ToLower(strings.TrimSpace(k))
|
||||
if def, ok := reg[k]; ok && !seen[k] {
|
||||
out = append(out, def)
|
||||
seen[k] = true
|
||||
}
|
||||
}
|
||||
// Append any registry-only keys not present in PlatformOptions.
|
||||
for k, def := range reg {
|
||||
if !seen[k] {
|
||||
out = append(out, def)
|
||||
seen[k] = true
|
||||
}
|
||||
}
|
||||
return out
|
||||
}
|
||||
|
||||
// GetPlatform returns the definition for a platform key. If the key is unknown,
|
||||
// it synthesizes a generic default so callers never get a nil (matches the
|
||||
// back-compat guarantee that an unlisted platform behaves like "generic").
|
||||
// The bool reports whether the key was explicitly present in the registry.
|
||||
func GetPlatform(key string) (*PlatformDef, bool) {
|
||||
key = strings.ToLower(strings.TrimSpace(key))
|
||||
reg := PlatformRegistry()
|
||||
if def, ok := reg[key]; ok {
|
||||
return def, true
|
||||
}
|
||||
return genericPlatformDef(key), false
|
||||
}
|
||||
|
||||
// genericPlatformDef returns a safe generic capability record for an unknown key.
|
||||
func genericPlatformDef(key string) *PlatformDef {
|
||||
return &PlatformDef{
|
||||
Key: key,
|
||||
Label: key,
|
||||
Family: "generic",
|
||||
Artifact: false,
|
||||
UpdateGenerator: "none",
|
||||
FeedFormat: "none",
|
||||
TemplateRepo: "Template-Generic",
|
||||
ManifestBased: false,
|
||||
PublishTarget: "git-release",
|
||||
}
|
||||
}
|
||||
|
||||
// builtinRegistry is the default platform registry. It reproduces current
|
||||
// behavior so an unconfigured instance is unchanged: Joomla still maps to the
|
||||
// joomla generator (xml), Dolibarr to dolibarr (json), npm/mcp are feedless, etc.
|
||||
func builtinRegistry() []*PlatformDef {
|
||||
return []*PlatformDef{
|
||||
{
|
||||
Key: "joomla", Label: "Joomla Extension", Aliases: []string{"joomla5", "joomla6"},
|
||||
Family: "joomla", Artifact: true, UpdateGenerator: "joomla", FeedFormat: "xml",
|
||||
TemplateRepo: "Template-Joomla", ManifestBased: true, PublishTarget: "updateserver",
|
||||
DetectGlobs: []string{"source/pkg_*.xml", "**/templateDetails.xml"},
|
||||
},
|
||||
{
|
||||
Key: "dolibarr", Label: "Dolibarr Module",
|
||||
Family: "dolibarr", Artifact: true, UpdateGenerator: "dolibarr", FeedFormat: "json",
|
||||
TemplateRepo: "Template-Dolibarr", ManifestBased: true, PublishTarget: "updateserver",
|
||||
DetectGlobs: []string{"htdocs/**/core/modules/mod*.class.php"},
|
||||
},
|
||||
{
|
||||
Key: "go", Label: "Go Module",
|
||||
Family: "go", Artifact: false, UpdateGenerator: "none", FeedFormat: "none",
|
||||
TemplateRepo: "Template-Go", ManifestBased: false, PublishTarget: "git-release",
|
||||
DetectGlobs: []string{"go.mod"},
|
||||
},
|
||||
{
|
||||
Key: "npm", Label: "NPM Package",
|
||||
Family: "node", Artifact: true, UpdateGenerator: "npm", FeedFormat: "none",
|
||||
TemplateRepo: "Template-NPM", ManifestBased: true, PublishTarget: "npm",
|
||||
DetectGlobs: []string{"package.json"},
|
||||
},
|
||||
{
|
||||
Key: "mcp", Label: "MCP Server",
|
||||
Family: "node", Artifact: true, UpdateGenerator: "npm", FeedFormat: "none",
|
||||
TemplateRepo: "Template-NPM", ManifestBased: true, PublishTarget: "npm",
|
||||
DetectGlobs: []string{"**/mcp.json", "**/.mcp.json"},
|
||||
},
|
||||
{
|
||||
Key: "generic", Label: "Generic", Family: "generic", Artifact: false,
|
||||
UpdateGenerator: "none", FeedFormat: "none", TemplateRepo: "Template-Generic",
|
||||
ManifestBased: false, PublishTarget: "git-release",
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
// buildDefaultRegistry indexes the built-in registry by key and then ensures a
|
||||
// record exists for every key in the admin PLATFORM_OPTIONS list (synthesizing a
|
||||
// generic default for any key without a built-in entry). This keeps the flat
|
||||
// PLATFORM_OPTIONS list and the structured registry consistent.
|
||||
func buildDefaultRegistry(options []string) map[string]*PlatformDef {
|
||||
reg := make(map[string]*PlatformDef)
|
||||
for _, def := range builtinRegistry() {
|
||||
d := def
|
||||
reg[d.Key] = d
|
||||
}
|
||||
for _, opt := range options {
|
||||
k := strings.ToLower(strings.TrimSpace(opt))
|
||||
if k == "" {
|
||||
continue
|
||||
}
|
||||
if _, ok := reg[k]; !ok {
|
||||
reg[k] = genericPlatformDef(k)
|
||||
}
|
||||
}
|
||||
return reg
|
||||
}
|
||||
|
||||
// loadPlatformRegistryFrom loads the structured platform registry.
|
||||
//
|
||||
// Storage: [metadata] PLATFORM_REGISTRY in app.ini. The value is EITHER an
|
||||
// inline JSON array of PlatformDef objects, OR a path to a JSON file (relative
|
||||
// paths are resolved against CustomPath, e.g. custom/platforms.json). When
|
||||
// unset, the built-in default registry is used, merged with any extra keys from
|
||||
// PLATFORM_OPTIONS. This keeps behavior unchanged for unconfigured instances and
|
||||
// avoids a DB schema change (idiomatic: mirrors the existing app.ini + file-path
|
||||
// config pattern used elsewhere in modules/setting).
|
||||
func loadPlatformRegistryFrom(rootCfg ConfigProvider) {
|
||||
// Base defaults, reconciled with the flat PLATFORM_OPTIONS list.
|
||||
platformRegistry = buildDefaultRegistry(Metadata.PlatformOptions)
|
||||
|
||||
raw := strings.TrimSpace(rootCfg.Section("metadata").Key("PLATFORM_REGISTRY").String())
|
||||
if raw == "" {
|
||||
return
|
||||
}
|
||||
|
||||
var data []byte
|
||||
if strings.HasPrefix(raw, "[") {
|
||||
// Inline JSON array.
|
||||
data = []byte(raw)
|
||||
} else {
|
||||
// Treat as a file path (resolve relative to CustomPath).
|
||||
path := raw
|
||||
if !filepath.IsAbs(path) {
|
||||
path = filepath.Join(CustomPath, path)
|
||||
}
|
||||
b, err := os.ReadFile(path)
|
||||
if err != nil {
|
||||
// Non-fatal: keep the default registry so the forge still boots.
|
||||
return
|
||||
}
|
||||
data = b
|
||||
}
|
||||
|
||||
var defs []*PlatformDef
|
||||
if err := json.Unmarshal(data, &defs); err != nil {
|
||||
// Non-fatal: malformed registry falls back to the default.
|
||||
return
|
||||
}
|
||||
if len(defs) == 0 {
|
||||
return
|
||||
}
|
||||
|
||||
// Replace the registry with the configured set, filling defaults per entry.
|
||||
reg := make(map[string]*PlatformDef, len(defs))
|
||||
for _, def := range defs {
|
||||
if def == nil {
|
||||
continue
|
||||
}
|
||||
key := strings.ToLower(strings.TrimSpace(def.Key))
|
||||
if key == "" {
|
||||
continue
|
||||
}
|
||||
def.Key = key
|
||||
if def.Label == "" {
|
||||
def.Label = key
|
||||
}
|
||||
if def.Family == "" {
|
||||
def.Family = "generic"
|
||||
}
|
||||
if def.UpdateGenerator == "" {
|
||||
def.UpdateGenerator = "none"
|
||||
}
|
||||
if def.FeedFormat == "" {
|
||||
def.FeedFormat = "none"
|
||||
}
|
||||
reg[key] = def
|
||||
}
|
||||
if len(reg) > 0 {
|
||||
platformRegistry = reg
|
||||
}
|
||||
}
|
||||
@@ -152,9 +152,9 @@ var UI = struct {
|
||||
Description string
|
||||
Keywords string
|
||||
}{
|
||||
Author: "MokoGIT",
|
||||
Description: "MokoGIT is a painless self-hosted Git service",
|
||||
Keywords: "go,git,self-hosted,mokogit",
|
||||
Author: "Gitea - Git with a cup of tea",
|
||||
Description: "Gitea (Git with a cup of tea) is a painless self-hosted Git service written in Go",
|
||||
Keywords: "go,git,self-hosted,gitea",
|
||||
},
|
||||
}
|
||||
|
||||
|
||||
@@ -113,34 +113,6 @@ type LicenseTemplateInfo struct {
|
||||
Body string `json:"body"`
|
||||
}
|
||||
|
||||
// Platform is a single platform capability record from the platform registry.
|
||||
// It exposes the non-secret capability attributes CI, the update server, and the
|
||||
// workflow sync tooling read instead of hardcoding per-platform behavior.
|
||||
type Platform struct {
|
||||
// Key is the stable lowercase platform identifier
|
||||
Key string `json:"key"`
|
||||
// Label is the human-readable display name
|
||||
Label string `json:"label"`
|
||||
// Aliases are alternate keys matched by prefix in the release gate
|
||||
Aliases []string `json:"aliases,omitempty"`
|
||||
// Family groups related platforms (joomla, dolibarr, node, go, generic, dot)
|
||||
Family string `json:"family"`
|
||||
// Artifact reports whether the platform produces a build artifact
|
||||
Artifact bool `json:"artifact"`
|
||||
// UpdateGenerator names the update-feed generator (joomla, dolibarr, npm, none, ...)
|
||||
UpdateGenerator string `json:"update_generator"`
|
||||
// FeedFormat is the update-feed wire format (xml, json, none)
|
||||
FeedFormat string `json:"feed_format"`
|
||||
// TemplateRepo is the workflow-template source repo
|
||||
TemplateRepo string `json:"template_repo,omitempty"`
|
||||
// ManifestBased reports whether a manifest is parsed for element/version
|
||||
ManifestBased bool `json:"manifest_based"`
|
||||
// PublishTarget names where artifacts are published
|
||||
PublishTarget string `json:"publish_target,omitempty"`
|
||||
// DetectGlobs are file-pattern globs used to auto-detect this platform
|
||||
DetectGlobs []string `json:"detect_globs,omitempty"`
|
||||
}
|
||||
|
||||
// APIError is an api error with a message
|
||||
type APIError struct {
|
||||
// Message contains the error description
|
||||
|
||||
@@ -3809,7 +3809,7 @@
|
||||
"admin.self_check.database_collation_mismatch": "Expect database to use collation: %s",
|
||||
"admin.self_check.database_collation_case_insensitive": "Database is using collation %s, which is a case-insensitive collation. Although ${APP_NAME} could work with it, there might be some rare cases which don't work as expected.",
|
||||
"admin.self_check.database_inconsistent_collation_columns": "Database is using collation %s, but these columns are using mismatched collations. This might cause some unexpected problems.",
|
||||
"admin.self_check.database_fix_mysql": "For MySQL/MariaDB users, you could use the \"mokogit doctor convert\" command to fix the collation problems, or you could also fix the problem manually with \"ALTER ... COLLATE ...\" SQL queries.",
|
||||
"admin.self_check.database_fix_mysql": "For MySQL/MariaDB users, you could use the \"gitea doctor convert\" command to fix the collation problems, or you could also fix the problem manually with \"ALTER ... COLLATE ...\" SQL queries.",
|
||||
"admin.self_check.database_fix_mssql": "For MSSQL users, you could only fix the problem manually with \"ALTER ... COLLATE ...\" SQL queries at the moment.",
|
||||
"admin.self_check.location_origin_mismatch": "Current URL (%[1]s) doesn't match the URL seen by ${APP_NAME} (%[2]s). If you are using a reverse proxy, please make sure the \"Host\" and \"X-Forwarded-Proto\" headers are set correctly.",
|
||||
"action.create_repo": "created repository <a href=\"%s\">%s</a>",
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
# This site is running a MokoGIT instance.
|
||||
# MokoGIT security problems should be reported to Moko Consulting.
|
||||
# This site is running a Gitea instance.
|
||||
# Gitea related security problems could be reported to Gitea community.
|
||||
# Site related security problems should be reported to this site's admin.
|
||||
Contact: mailto:security@mokoconsulting.tech
|
||||
Policy: https://git.mokoconsulting.tech/MokoConsulting/MokoGIT/src/branch/main/SECURITY.md
|
||||
Contact: https://github.com/go-gitea/gitea/blob/main/SECURITY.md
|
||||
Policy: https://github.com/go-gitea/gitea/blob/main/SECURITY.md
|
||||
Preferred-Languages: en
|
||||
|
||||
@@ -2,9 +2,9 @@
|
||||
// Copyright 2016 The Gitea Authors. All rights reserved.
|
||||
// SPDX-License-Identifier: MIT
|
||||
|
||||
// Package v1 MokoGIT API
|
||||
// Package v1 Gitea API
|
||||
//
|
||||
// This documentation describes the MokoGIT API.
|
||||
// This documentation describes the Gitea API.
|
||||
//
|
||||
// Schemes: https, http
|
||||
// License: MIT http://opensource.org/licenses/MIT
|
||||
@@ -1009,10 +1009,6 @@ func Routes() *web.Router {
|
||||
m.Get("/label/templates", misc.ListLabelTemplates)
|
||||
m.Get("/label/templates/{name}", misc.GetLabelTemplate)
|
||||
|
||||
// Platform registry (non-secret capability config read by CI / mokocli).
|
||||
m.Get("/platforms", misc.ListPlatforms)
|
||||
m.Get("/platforms/{key}", misc.GetPlatform)
|
||||
|
||||
m.Group("/settings", func() {
|
||||
m.Get("/ui", settings.GetGeneralUISettings)
|
||||
m.Get("/api", settings.GetGeneralAPISettings)
|
||||
|
||||
@@ -1,78 +0,0 @@
|
||||
// Copyright 2026 Moko Consulting <hello@mokoconsulting.tech>
|
||||
// SPDX-License-Identifier: GPL-3.0-or-later
|
||||
|
||||
package misc
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
"strings"
|
||||
|
||||
"code.mokoconsulting.tech/MokoConsulting/MokoGIT/modules/setting"
|
||||
api "code.mokoconsulting.tech/MokoConsulting/MokoGIT/modules/structs"
|
||||
"code.mokoconsulting.tech/MokoConsulting/MokoGIT/services/context"
|
||||
)
|
||||
|
||||
// toAPIPlatform converts a setting.PlatformDef into its API representation.
|
||||
func toAPIPlatform(def *setting.PlatformDef) *api.Platform {
|
||||
return &api.Platform{
|
||||
Key: def.Key,
|
||||
Label: def.Label,
|
||||
Aliases: def.Aliases,
|
||||
Family: def.Family,
|
||||
Artifact: def.Artifact,
|
||||
UpdateGenerator: def.UpdateGenerator,
|
||||
FeedFormat: def.FeedFormat,
|
||||
TemplateRepo: def.TemplateRepo,
|
||||
ManifestBased: def.ManifestBased,
|
||||
PublishTarget: def.PublishTarget,
|
||||
DetectGlobs: def.DetectGlobs,
|
||||
}
|
||||
}
|
||||
|
||||
// ListPlatforms returns the whole platform registry.
|
||||
func ListPlatforms(ctx *context.APIContext) {
|
||||
// swagger:operation GET /platforms miscellaneous listPlatforms
|
||||
// ---
|
||||
// summary: Returns the platform registry (all platform capability records)
|
||||
// produces:
|
||||
// - application/json
|
||||
// responses:
|
||||
// "200":
|
||||
// "$ref": "#/responses/PlatformList"
|
||||
defs := setting.PlatformList()
|
||||
response := make([]*api.Platform, len(defs))
|
||||
for i, def := range defs {
|
||||
response[i] = toAPIPlatform(def)
|
||||
}
|
||||
ctx.JSON(http.StatusOK, response)
|
||||
}
|
||||
|
||||
// GetPlatform returns a single platform record by key.
|
||||
func GetPlatform(ctx *context.APIContext) {
|
||||
// swagger:operation GET /platforms/{key} miscellaneous getPlatform
|
||||
// ---
|
||||
// summary: Returns a single platform capability record by key
|
||||
// produces:
|
||||
// - application/json
|
||||
// parameters:
|
||||
// - name: key
|
||||
// in: path
|
||||
// description: platform key
|
||||
// type: string
|
||||
// required: true
|
||||
// responses:
|
||||
// "200":
|
||||
// "$ref": "#/responses/Platform"
|
||||
// "404":
|
||||
// "$ref": "#/responses/notFound"
|
||||
key := strings.ToLower(strings.TrimSpace(ctx.PathParam("key")))
|
||||
def, ok := setting.GetPlatform(key)
|
||||
if !ok {
|
||||
// Unknown key: only 404 when it is not an admin-listed platform.
|
||||
// (GetPlatform synthesizes a generic default for unknown keys, but the
|
||||
// endpoint should be honest about what is actually configured.)
|
||||
ctx.APIErrorNotFound()
|
||||
return
|
||||
}
|
||||
ctx.JSON(http.StatusOK, toAPIPlatform(def))
|
||||
}
|
||||
@@ -11,11 +11,11 @@ import (
|
||||
"code.mokoconsulting.tech/MokoConsulting/MokoGIT/services/context"
|
||||
)
|
||||
|
||||
// Version shows the version of the MokoGIT server
|
||||
// Version shows the version of the Gitea server
|
||||
func Version(ctx *context.APIContext) {
|
||||
// swagger:operation GET /version miscellaneous getVersion
|
||||
// ---
|
||||
// summary: Returns the version of the MokoGIT application
|
||||
// summary: Returns the version of the Gitea application
|
||||
// produces:
|
||||
// - application/json
|
||||
// responses:
|
||||
|
||||
@@ -33,14 +33,6 @@ type apiMetadata struct {
|
||||
ExtensionType string `json:"extension_type"`
|
||||
EntryPoint string `json:"entry_point"`
|
||||
|
||||
// npm/mcp
|
||||
NodeMinimum string `json:"node_minimum,omitempty"`
|
||||
NpmPackage string `json:"npm_package,omitempty"`
|
||||
NpmScope string `json:"npm_scope,omitempty"`
|
||||
RegistryURL string `json:"registry_url,omitempty"`
|
||||
Bin string `json:"bin,omitempty"`
|
||||
PublishTarget string `json:"publish_target,omitempty"`
|
||||
|
||||
// deploy
|
||||
DeployHost string `json:"deploy_host,omitempty"`
|
||||
DeployPort string `json:"deploy_port,omitempty"`
|
||||
@@ -117,12 +109,6 @@ func GetRepoMetadata(ctx *context.APIContext) {
|
||||
Language: m.Language,
|
||||
ExtensionType: m.ExtensionType,
|
||||
EntryPoint: m.EntryPoint,
|
||||
NodeMinimum: m.NodeMinimum,
|
||||
NpmPackage: m.NpmPackage,
|
||||
NpmScope: m.NpmScope,
|
||||
RegistryURL: m.RegistryURL,
|
||||
Bin: m.Bin,
|
||||
PublishTarget: m.PublishTarget,
|
||||
DeployHost: m.DeployHost,
|
||||
DeployPort: m.DeployPort,
|
||||
DeployUser: m.DeployUser,
|
||||
@@ -202,12 +188,6 @@ func UpdateRepoMetadata(ctx *context.APIContext) {
|
||||
setStr("language", &m.Language)
|
||||
setStr("extension_type", &m.ExtensionType)
|
||||
setStr("entry_point", &m.EntryPoint)
|
||||
setStr("node_minimum", &m.NodeMinimum)
|
||||
setStr("npm_package", &m.NpmPackage)
|
||||
setStr("npm_scope", &m.NpmScope)
|
||||
setStr("registry_url", &m.RegistryURL)
|
||||
setStr("bin", &m.Bin)
|
||||
setStr("publish_target", &m.PublishTarget)
|
||||
setStr("deploy_host", &m.DeployHost)
|
||||
setStr("deploy_port", &m.DeployPort)
|
||||
setStr("deploy_user", &m.DeployUser)
|
||||
@@ -243,12 +223,6 @@ func UpdateRepoMetadata(ctx *context.APIContext) {
|
||||
Language: m.Language,
|
||||
ExtensionType: m.ExtensionType,
|
||||
EntryPoint: m.EntryPoint,
|
||||
NodeMinimum: m.NodeMinimum,
|
||||
NpmPackage: m.NpmPackage,
|
||||
NpmScope: m.NpmScope,
|
||||
RegistryURL: m.RegistryURL,
|
||||
Bin: m.Bin,
|
||||
PublishTarget: m.PublishTarget,
|
||||
DeployHost: m.DeployHost,
|
||||
DeployPort: m.DeployPort,
|
||||
DeployUser: m.DeployUser,
|
||||
|
||||
@@ -62,17 +62,3 @@ type swaggerResponseLabelTemplateInfo struct {
|
||||
// in:body
|
||||
Body []api.LabelTemplate `json:"body"`
|
||||
}
|
||||
|
||||
// PlatformList
|
||||
// swagger:response PlatformList
|
||||
type swaggerResponsePlatformList struct {
|
||||
// in:body
|
||||
Body []api.Platform `json:"body"`
|
||||
}
|
||||
|
||||
// Platform
|
||||
// swagger:response Platform
|
||||
type swaggerResponsePlatform struct {
|
||||
// in:body
|
||||
Body api.Platform `json:"body"`
|
||||
}
|
||||
|
||||
@@ -20,10 +20,6 @@ func Metadata(ctx *context.Context) {
|
||||
ctx.Data["Title"] = "Metadata"
|
||||
ctx.Data["PageIsAdminMetadata"] = true
|
||||
ctx.Data["PlatformOptions"] = strings.Join(setting.Metadata.PlatformOptions, "\n")
|
||||
// Resolved platform registry (read-only view). Capability attributes are
|
||||
// edited via app.ini [metadata] PLATFORM_REGISTRY; the textarea above still
|
||||
// edits the flat key list (PLATFORM_OPTIONS).
|
||||
ctx.Data["PlatformRegistry"] = setting.PlatformList()
|
||||
ctx.HTML(http.StatusOK, tplMetadata)
|
||||
}
|
||||
|
||||
|
||||
@@ -78,14 +78,10 @@ func validateUpdateKey(ctx *context.Context) (allowedChannels []string, ok bool,
|
||||
// ServeUpdatesXML generates and serves a Joomla-compatible updates.xml
|
||||
// from the repository's releases.
|
||||
func ServeUpdatesXML(ctx *context.Context) {
|
||||
// Registry-driven gating: serve the Joomla feed only for platforms whose
|
||||
// registry update_generator is "joomla" (plus the "both" compound platform,
|
||||
// which shares the Joomla + Dolibarr generators and has no standalone
|
||||
// registry entry). The platform is resolved upstream (metadata feedless wins
|
||||
// → config override → repo metadata → "joomla" default), so a feedless
|
||||
// (npm/mcp/go) platform never reaches the Joomla generator. See #810 / #811.
|
||||
// Block if platform is set to a non-Joomla value.
|
||||
// Empty/unset defaults to joomla for backwards compatibility.
|
||||
platform, _ := ctx.Data["RepoUpdatePlatform"].(string)
|
||||
if !updateserver.PlatformServesGenerator(platform, "joomla") && platform != updateserver_model.PlatformBoth {
|
||||
if platform != "" && platform != "joomla" && platform != "both" {
|
||||
ctx.NotFound(nil)
|
||||
return
|
||||
}
|
||||
@@ -118,12 +114,9 @@ func ServeUpdatesXML(ctx *context.Context) {
|
||||
// from the repository's releases. Uses the same license key validation as the
|
||||
// Joomla XML feed — all platforms share the same licensing system.
|
||||
func ServeDolibarrJSON(ctx *context.Context) {
|
||||
// Registry-driven gating: serve the Dolibarr feed only for platforms whose
|
||||
// registry update_generator is "dolibarr" (plus the "both" compound
|
||||
// platform). Feedless platforms (npm/mcp/go) and any other platform return
|
||||
// NotFound rather than a feed. See #810 / #811.
|
||||
platform, _ := ctx.Data["RepoUpdatePlatform"].(string)
|
||||
if !updateserver.PlatformServesGenerator(platform, "dolibarr") && platform != updateserver_model.PlatformBoth {
|
||||
// Block if platform doesn't include dolibarr.
|
||||
platform := ctx.Data["RepoUpdatePlatform"]
|
||||
if platform == "joomla" || platform == "" {
|
||||
ctx.NotFound(nil)
|
||||
return
|
||||
}
|
||||
@@ -156,12 +149,9 @@ func ServeDolibarrJSON(ctx *context.Context) {
|
||||
// ServeWordPressJSON generates and serves a WordPress PUC-compatible update feed.
|
||||
// Compatible with the YahnisElsts plugin-update-checker library.
|
||||
func ServeWordPressJSON(ctx *context.Context) {
|
||||
// Only serve for wordpress/both. Registry-recognized feedless platforms
|
||||
// (npm/mcp/go, feed_format=="none") and any other platform return
|
||||
// NotFound. See #810 / #811.
|
||||
platform, _ := ctx.Data["RepoUpdatePlatform"].(string)
|
||||
if updateserver_model.IsFeedlessPlatform(platform) ||
|
||||
(platform != updateserver_model.PlatformWordPress && platform != updateserver_model.PlatformBoth) {
|
||||
// Block if platform doesn't include wordpress.
|
||||
platform := ctx.Data["RepoUpdatePlatform"]
|
||||
if platform != "wordpress" && platform != "both" {
|
||||
ctx.NotFound(nil)
|
||||
return
|
||||
}
|
||||
@@ -205,10 +195,8 @@ func ServeWordPressJSON(ctx *context.Context) {
|
||||
|
||||
// ServeComposerJSON generates and serves a Composer packages.json feed.
|
||||
func ServeComposerJSON(ctx *context.Context) {
|
||||
// Only serve for composer. Registry-recognized feedless platforms
|
||||
// (npm/mcp/go) and any other platform return NotFound. See #810 / #811.
|
||||
platform, _ := ctx.Data["RepoUpdatePlatform"].(string)
|
||||
if updateserver_model.IsFeedlessPlatform(platform) || platform != updateserver_model.PlatformComposer {
|
||||
platform := ctx.Data["RepoUpdatePlatform"]
|
||||
if platform != "composer" {
|
||||
ctx.NotFound(nil)
|
||||
return
|
||||
}
|
||||
@@ -245,10 +233,8 @@ func ServeComposerJSON(ctx *context.Context) {
|
||||
|
||||
// ServePrestaShopXML generates and serves a PrestaShop module update XML.
|
||||
func ServePrestaShopXML(ctx *context.Context) {
|
||||
// Only serve for prestashop. Registry-recognized feedless platforms
|
||||
// (npm/mcp/go) and any other platform return NotFound. See #810 / #811.
|
||||
platform, _ := ctx.Data["RepoUpdatePlatform"].(string)
|
||||
if updateserver_model.IsFeedlessPlatform(platform) || platform != updateserver_model.PlatformPrestaShop {
|
||||
platform := ctx.Data["RepoUpdatePlatform"]
|
||||
if platform != "prestashop" {
|
||||
ctx.NotFound(nil)
|
||||
return
|
||||
}
|
||||
@@ -274,10 +260,8 @@ func ServePrestaShopXML(ctx *context.Context) {
|
||||
|
||||
// ServeDrupalXML generates and serves a Drupal update status XML.
|
||||
func ServeDrupalXML(ctx *context.Context) {
|
||||
// Only serve for drupal. Registry-recognized feedless platforms
|
||||
// (npm/mcp/go) and any other platform return NotFound. See #810 / #811.
|
||||
platform, _ := ctx.Data["RepoUpdatePlatform"].(string)
|
||||
if updateserver_model.IsFeedlessPlatform(platform) || platform != updateserver_model.PlatformDrupal {
|
||||
platform := ctx.Data["RepoUpdatePlatform"]
|
||||
if platform != "drupal" {
|
||||
ctx.NotFound(nil)
|
||||
return
|
||||
}
|
||||
@@ -303,10 +287,8 @@ func ServeDrupalXML(ctx *context.Context) {
|
||||
|
||||
// ServeWHMCSJSON generates and serves a WHMCS module update JSON.
|
||||
func ServeWHMCSJSON(ctx *context.Context) {
|
||||
// Only serve for whmcs. Registry-recognized feedless platforms
|
||||
// (npm/mcp/go) and any other platform return NotFound. See #810 / #811.
|
||||
platform, _ := ctx.Data["RepoUpdatePlatform"].(string)
|
||||
if updateserver_model.IsFeedlessPlatform(platform) || platform != updateserver_model.PlatformWHMCS {
|
||||
platform := ctx.Data["RepoUpdatePlatform"]
|
||||
if platform != "whmcs" {
|
||||
ctx.NotFound(nil)
|
||||
return
|
||||
}
|
||||
|
||||
@@ -701,21 +701,12 @@ func repoAssignmentPrepareTemplateData(ctx *Context, data *repoAssignmentPrepare
|
||||
ctx.Data["IsRepoAdmin"] = ctx.Repo.Permission.IsAdmin()
|
||||
ctx.Data["IsSiteAdmin"] = ctx.IsUserSiteAdmin()
|
||||
|
||||
// Resolve the effective update platform for platform-aware UI. When the
|
||||
// update-stream config has no explicit platform, derive it from the repo
|
||||
// metadata (metadata.platform) so npm/mcp repos are recognized and the two
|
||||
// stores can't drift. See #810 / #811.
|
||||
cfgPlatform := ""
|
||||
// Load repo update config for platform-aware UI.
|
||||
if repoUpdateCfg != nil {
|
||||
cfgPlatform = repoUpdateCfg.Platform
|
||||
ctx.Data["RepoUpdatePlatform"] = repoUpdateCfg.Platform
|
||||
} else {
|
||||
ctx.Data["RepoUpdatePlatform"] = "joomla"
|
||||
}
|
||||
metadataPlatform := ""
|
||||
if meta, err := repo_model.GetRepoMetadata(ctx, repo.ID); err != nil {
|
||||
log.Error("GetRepoMetadata: %v", err)
|
||||
} else if meta != nil {
|
||||
metadataPlatform = meta.Platform
|
||||
}
|
||||
ctx.Data["RepoUpdatePlatform"] = updateserver_model.ResolvePlatform(cfgPlatform, metadataPlatform)
|
||||
|
||||
ctx.Data["Title"] = repo.Owner.Name + "/" + repo.Name
|
||||
ctx.Data["PageTitleCommon"] = repo.Name + " - " + setting.AppName
|
||||
|
||||
@@ -4,8 +4,8 @@
|
||||
package context
|
||||
|
||||
import (
|
||||
repo_model "code.mokoconsulting.tech/MokoConsulting/MokoGIT/models/repo"
|
||||
updateserver_model "code.mokoconsulting.tech/MokoConsulting/MokoGIT/models/updateserver"
|
||||
repo_model "code.mokoconsulting.tech/MokoConsulting/MokoGIT/models/repo"
|
||||
user_model "code.mokoconsulting.tech/MokoConsulting/MokoGIT/models/user"
|
||||
"code.mokoconsulting.tech/MokoConsulting/MokoGIT/modules/log"
|
||||
)
|
||||
@@ -50,18 +50,10 @@ func RepoAssignmentPublicFeed() func(ctx *Context) {
|
||||
return
|
||||
}
|
||||
|
||||
// Resolve the effective feed platform. When the update-stream config has
|
||||
// no explicit platform override, derive it from the repo metadata
|
||||
// (metadata.platform) so the two stores can't drift, and so npm/mcp repos
|
||||
// are recognized as feedless instead of falling back to a Joomla feed.
|
||||
// See #810 / #811.
|
||||
metadataPlatform := ""
|
||||
if meta, err := repo_model.GetRepoMetadata(ctx, repo.ID); err != nil {
|
||||
log.Error("GetRepoMetadata: %v", err)
|
||||
} else if meta != nil {
|
||||
metadataPlatform = meta.Platform
|
||||
ctx.Data["RepoUpdatePlatform"] = cfg.Platform
|
||||
if cfg.Platform == "" {
|
||||
ctx.Data["RepoUpdatePlatform"] = "joomla"
|
||||
}
|
||||
ctx.Data["RepoUpdatePlatform"] = updateserver_model.ResolvePlatform(cfg.Platform, metadataPlatform)
|
||||
|
||||
log.Trace("Public feed access: %s/%s", ownerName, repoName)
|
||||
}
|
||||
|
||||
@@ -1,241 +0,0 @@
|
||||
// Copyright 2026 Moko Consulting <hello@mokoconsulting.tech>
|
||||
// SPDX-License-Identifier: GPL-3.0-or-later
|
||||
|
||||
package release
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"io"
|
||||
"path"
|
||||
"strings"
|
||||
|
||||
repo_model "code.mokoconsulting.tech/MokoConsulting/MokoGIT/models/repo"
|
||||
user_model "code.mokoconsulting.tech/MokoConsulting/MokoGIT/models/user"
|
||||
"code.mokoconsulting.tech/MokoConsulting/MokoGIT/modules/gitrepo"
|
||||
"code.mokoconsulting.tech/MokoConsulting/MokoGIT/modules/globallock"
|
||||
"code.mokoconsulting.tech/MokoConsulting/MokoGIT/modules/log"
|
||||
attachment_service "code.mokoconsulting.tech/MokoConsulting/MokoGIT/services/attachment"
|
||||
)
|
||||
|
||||
// generatedArtifactUploaderID marks a release attachment as server-generated by
|
||||
// the packaging hook rather than uploaded by a human. Real uploads always set
|
||||
// UploaderID to a positive doer ID (see routers/**/release_attachment.go), so
|
||||
// this negative built-in bot id can never collide with a user asset. Only
|
||||
// attachments carrying this marker are ever deleted by the packaging hook, which
|
||||
// prevents it from destroying a user-uploaded asset that happens to share a name
|
||||
// with a generated zip.
|
||||
const generatedArtifactUploaderID = user_model.ActionsUserID
|
||||
|
||||
// getReleasePackagingLockKey builds the global-lock key that serializes the
|
||||
// delete+attach sequence for a single release, following the forge convention
|
||||
// (see getPullWorkingLockKey / getWikiWorkingLockKey).
|
||||
func getReleasePackagingLockKey(relID int64) string {
|
||||
return fmt.Sprintf("release_packaging_%d", relID)
|
||||
}
|
||||
|
||||
// isRootEntryPoint reports whether an entry point refers to the repository root
|
||||
// (and therefore does not warrant a separate subtree archive).
|
||||
func isRootEntryPoint(entryPoint string) bool {
|
||||
switch normalizeEntryPoint(entryPoint) {
|
||||
case "", ".":
|
||||
return true
|
||||
default:
|
||||
return false
|
||||
}
|
||||
}
|
||||
|
||||
// normalizeEntryPoint reduces an entry point to a repo-relative, cleaned path
|
||||
// suitable for `git archive <commit> <path>`. It trims surrounding whitespace,
|
||||
// strips a leading slash (git archive rejects absolute paths), drops a trailing
|
||||
// slash, and cleans the result. A root-equivalent entry point normalizes to "".
|
||||
func normalizeEntryPoint(entryPoint string) string {
|
||||
ep := strings.TrimSpace(entryPoint)
|
||||
ep = strings.TrimPrefix(ep, "/")
|
||||
ep = strings.TrimSuffix(ep, "/")
|
||||
if ep == "" {
|
||||
return ""
|
||||
}
|
||||
ep = path.Clean(ep)
|
||||
if ep == "." || ep == "/" {
|
||||
return ""
|
||||
}
|
||||
return ep
|
||||
}
|
||||
|
||||
// sanitizeNameSegment makes a string safe and tidy for use inside an attachment
|
||||
// display name. Attachment storage paths are UUID-based (see
|
||||
// AttachmentRelativePath), so there is no traversal risk — this only keeps the
|
||||
// display name clean, e.g. a tag "release/1.0" would otherwise render as
|
||||
// "repo-release/1.0.zip".
|
||||
func sanitizeNameSegment(s string) string {
|
||||
return strings.NewReplacer(
|
||||
"/", "-",
|
||||
"\\", "-",
|
||||
"\x00", "-",
|
||||
).Replace(s)
|
||||
}
|
||||
|
||||
// findGeneratedArtifacts returns the existing, server-generated attachments on
|
||||
// the release with the given name. User-uploaded assets (any UploaderID other
|
||||
// than the marker) are never included, so they can never be touched.
|
||||
func findGeneratedArtifacts(rel *repo_model.Release, name string) []*repo_model.Attachment {
|
||||
var out []*repo_model.Attachment
|
||||
for _, a := range rel.Attachments {
|
||||
if a.Name == name && a.UploaderID == generatedArtifactUploaderID {
|
||||
out = append(out, a)
|
||||
}
|
||||
}
|
||||
return out
|
||||
}
|
||||
|
||||
// attachArchive streams a `git archive` of the given commit/paths directly into
|
||||
// a new release attachment via an io.Pipe, so the full zip is never buffered in
|
||||
// memory. paths == nil archives the whole repository; a single-element slice
|
||||
// archives that subtree. The attachment is tagged with the generated-artifact
|
||||
// marker so a later run can safely recognize and replace it.
|
||||
func attachArchive(ctx context.Context, rel *repo_model.Release, name, commitID string, paths []string) error {
|
||||
pr, pw := io.Pipe()
|
||||
|
||||
go func() {
|
||||
// "zip" is a valid archive format for gitrepo.CreateArchive (it only
|
||||
// rejects "unknown"). usePrefix=false keeps entries at the archive root.
|
||||
err := gitrepo.CreateArchive(ctx, rel.Repo, "zip", pw, false, commitID, paths)
|
||||
// Closing the writer with err (nil on success) propagates any archive
|
||||
// failure to the reader side so NewAttachment aborts instead of storing
|
||||
// a truncated zip.
|
||||
_ = pw.CloseWithError(err)
|
||||
}()
|
||||
|
||||
attach := &repo_model.Attachment{
|
||||
RepoID: rel.RepoID,
|
||||
ReleaseID: rel.ID,
|
||||
UploaderID: generatedArtifactUploaderID,
|
||||
Name: name,
|
||||
}
|
||||
|
||||
// size == -1: the archive is streamed with an unknown length, matching the
|
||||
// unknown-size upload path already used by the attachment service.
|
||||
if _, err := attachment_service.NewAttachment(ctx, attach, pr, -1); err != nil {
|
||||
_ = pr.CloseWithError(err)
|
||||
return fmt.Errorf("NewAttachment %s: %w", name, err)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// regenerateArtifact attaches a fresh archive under the canonical name and only
|
||||
// then, on success, removes any previously generated copies of that name
|
||||
// (attach-new-then-delete-old). This ordering guarantees a failed regeneration
|
||||
// never nets asset loss: if the archive fails, the previous artifact is left
|
||||
// intact and nothing is deleted. On success the stale generated copies are
|
||||
// removed, leaving exactly one generated artifact under the name.
|
||||
//
|
||||
// Only artifacts carrying the generated-artifact marker are considered for
|
||||
// deletion, so a user-uploaded asset of the same name is never removed. The
|
||||
// caller must hold the per-release packaging lock so the brief window in which
|
||||
// two same-named generated copies coexist is never observed concurrently.
|
||||
func regenerateArtifact(ctx context.Context, rel *repo_model.Release, name, commitID string, paths []string) error {
|
||||
// Snapshot prior generated copies BEFORE attaching the new one, so the
|
||||
// post-attach cleanup removes only the old rows, not the fresh insert.
|
||||
stale := findGeneratedArtifacts(rel, name)
|
||||
|
||||
if err := attachArchive(ctx, rel, name, commitID, paths); err != nil {
|
||||
// Attach failed — leave any existing artifact untouched. No net loss.
|
||||
return err
|
||||
}
|
||||
|
||||
// New artifact is stored under the canonical name; drop the stale copies.
|
||||
for _, old := range stale {
|
||||
if err := repo_model.DeleteAttachment(ctx, old, true); err != nil {
|
||||
// Non-fatal: log and continue. Worst case a superseded copy lingers,
|
||||
// but the fresh artifact is already in place under the real name.
|
||||
log.Warn("Failed to delete superseded release artifact %s (uuid %s): %v", old.Name, old.UUID, err)
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// GenerateReleaseArtifacts packages a published release into release
|
||||
// attachments: a full-repository zip always, plus an entry-point subtree zip
|
||||
// when the repository metadata declares a non-root build entry point.
|
||||
//
|
||||
// It is idempotent and safe on re-run: only server-generated artifacts (tagged
|
||||
// with the generated-artifact marker) are ever replaced, so a user-uploaded
|
||||
// asset sharing a name is never destroyed. The delete+attach sequence for the
|
||||
// release is serialized under a global lock, and each artifact is attached
|
||||
// before its stale copy is removed, so concurrent runs and mid-run failures can
|
||||
// never net an asset loss.
|
||||
//
|
||||
// It is intended to run BEFORE GenerateReleaseChecksums so the subsequent
|
||||
// checksum pass mints a .sha256 sidecar for each generated zip automatically.
|
||||
//
|
||||
// Following the convention of GenerateReleaseChecksums, a failure to produce an
|
||||
// individual artifact is logged and does not abort the release; only setup
|
||||
// failures (metadata lookup, attachment enumeration, lock acquisition) are
|
||||
// returned.
|
||||
func GenerateReleaseArtifacts(ctx context.Context, rel *repo_model.Release) error {
|
||||
if rel.Repo == nil {
|
||||
if err := rel.LoadAttributes(ctx); err != nil {
|
||||
return fmt.Errorf("LoadAttributes: %w", err)
|
||||
}
|
||||
}
|
||||
|
||||
commitID := rel.Sha1
|
||||
if commitID == "" {
|
||||
// No resolved commit (e.g. a draft with no tag) — nothing to archive.
|
||||
return nil
|
||||
}
|
||||
|
||||
version := sanitizeNameSegment(rel.TagName)
|
||||
repoName := rel.Repo.Name
|
||||
|
||||
fullName := fmt.Sprintf("%s-%s.zip", repoName, version)
|
||||
sourceName := fmt.Sprintf("%s-%s-source.zip", repoName, version)
|
||||
|
||||
// Resolve the build entry point from repo metadata, if any.
|
||||
var entryPoint string
|
||||
meta, err := repo_model.GetRepoMetadata(ctx, rel.RepoID)
|
||||
if err != nil {
|
||||
log.Warn("GenerateReleaseArtifacts: GetRepoMetadata for repo %d: %v", rel.RepoID, err)
|
||||
} else if meta != nil {
|
||||
entryPoint = meta.EntryPoint
|
||||
}
|
||||
wantSource := !isRootEntryPoint(entryPoint)
|
||||
|
||||
// Serialize the delete+attach sequence per-release so concurrent
|
||||
// CreateRelease/UpdateRelease calls on the same release cannot interleave
|
||||
// (which could duplicate zips or delete a freshly attached artifact).
|
||||
return globallock.LockAndDo(ctx, getReleasePackagingLockKey(rel.ID), func(ctx context.Context) error {
|
||||
// Re-load attachments inside the lock so replace decisions see a
|
||||
// consistent view (including any generated artifacts from a prior run).
|
||||
if err := repo_model.GetReleaseAttachments(ctx, rel); err != nil {
|
||||
return fmt.Errorf("GetReleaseAttachments: %w", err)
|
||||
}
|
||||
|
||||
created := 0
|
||||
|
||||
// Full-repository archive (paths == nil).
|
||||
if err := regenerateArtifact(ctx, rel, fullName, commitID, nil); err != nil {
|
||||
log.Error("GenerateReleaseArtifacts: full-repo zip for release %s (repo %d): %v", version, rel.RepoID, err)
|
||||
} else {
|
||||
created++
|
||||
}
|
||||
|
||||
// Entry-point subtree archive. The stale-snapshot is taken from the same
|
||||
// in-lock attachment read above; the full-repo archive uses a different
|
||||
// name, so no re-read is needed here.
|
||||
if wantSource {
|
||||
subPath := normalizeEntryPoint(entryPoint)
|
||||
if err := regenerateArtifact(ctx, rel, sourceName, commitID, []string{subPath}); err != nil {
|
||||
log.Error("GenerateReleaseArtifacts: subtree zip (%s) for release %s (repo %d): %v", subPath, version, rel.RepoID, err)
|
||||
} else {
|
||||
created++
|
||||
}
|
||||
}
|
||||
|
||||
if created > 0 {
|
||||
log.Info("Generated %d release artifact(s) for release %s (repo %d)", created, version, rel.RepoID)
|
||||
}
|
||||
return nil
|
||||
})
|
||||
}
|
||||
@@ -254,20 +254,8 @@ func CreateRelease(gitRepo *git.Repository, rel *repo_model.Release, attachmentU
|
||||
return err
|
||||
}
|
||||
|
||||
// Server-side packaging: attach full-repo + entry_point subtree zips.
|
||||
// Skip drafts (mirrors the notify guard below); run before the checksum
|
||||
// pass so the generated zips receive .sha256 sidecars automatically.
|
||||
if !rel.IsDraft {
|
||||
if err := GenerateReleaseArtifacts(gitRepo.Ctx, rel); err != nil {
|
||||
log.Error("GenerateReleaseArtifacts for %s: %v", rel.TagName, err)
|
||||
}
|
||||
}
|
||||
|
||||
// Generate SHA256 checksums for all release attachments.
|
||||
// FOLLOW-UP (#809): GenerateReleaseChecksums re-hashes every attachment on
|
||||
// the release, so publishing a release with many large assets re-reads them
|
||||
// all. Consider hashing only newly added/changed attachments.
|
||||
if len(attachmentUUIDs) > 0 || !rel.IsDraft {
|
||||
// Generate SHA256 checksums for all release attachments
|
||||
if len(attachmentUUIDs) > 0 {
|
||||
if err := GenerateReleaseChecksums(gitRepo.Ctx, rel); err != nil {
|
||||
log.Error("GenerateReleaseChecksums for %s: %v", rel.TagName, err)
|
||||
}
|
||||
@@ -427,21 +415,8 @@ func UpdateRelease(ctx context.Context, doer *user_model.User, gitRepo *git.Repo
|
||||
}
|
||||
}
|
||||
|
||||
// Server-side packaging on publish: (re)attach full-repo + entry_point
|
||||
// subtree zips. Skip drafts (mirrors the notify guard below). The helper is
|
||||
// idempotent, so a draft→publish transition replaces any prior artifacts.
|
||||
// Run before the checksum pass so the zips receive .sha256 sidecars.
|
||||
if !rel.IsDraft {
|
||||
if err := GenerateReleaseArtifacts(ctx, rel); err != nil {
|
||||
log.Error("GenerateReleaseArtifacts for %s: %v", rel.TagName, err)
|
||||
}
|
||||
}
|
||||
|
||||
// Regenerate checksums when attachments change or artifacts were generated.
|
||||
// FOLLOW-UP (#809): GenerateReleaseChecksums re-hashes every attachment on
|
||||
// the release, so a non-draft edit re-reads them all even if only one asset
|
||||
// changed. Consider hashing only newly added/changed attachments.
|
||||
if len(addAttachmentUUIDs) > 0 || len(delAttachmentUUIDs) > 0 || !rel.IsDraft {
|
||||
// Regenerate checksums when attachments change
|
||||
if len(addAttachmentUUIDs) > 0 || len(delAttachmentUUIDs) > 0 {
|
||||
if err := GenerateReleaseChecksums(ctx, rel); err != nil {
|
||||
log.Error("GenerateReleaseChecksums for %s: %v", rel.TagName, err)
|
||||
}
|
||||
|
||||
@@ -319,16 +319,15 @@ func GenerateJoomlaXML(ctx context.Context, repo *repo_model.Repository, require
|
||||
continue
|
||||
}
|
||||
|
||||
// Select the installable Joomla artifact for the download URL. A release can
|
||||
// carry non-installable zips alongside the real package -- e.g. the raw
|
||||
// source archive (<repo>-<channel>-source.zip). Taking the first zip would
|
||||
// hand Joomla the source archive, which has no manifest at its root and
|
||||
// fails to install with "Install path does not exist". selectJoomlaArtifact
|
||||
// prefers an extension-prefixed package and never a "-source" archive.
|
||||
// Find the first .zip attachment as the download URL, and its SHA256 sidecar.
|
||||
var downloadURL, sha256Hash string
|
||||
zipName := selectJoomlaArtifact(rel.Attachments)
|
||||
if zipName != "" {
|
||||
downloadURL = fmt.Sprintf("%s/releases/download/%s/%s", repoLink, rel.TagName, zipName)
|
||||
var zipName string
|
||||
for _, att := range rel.Attachments {
|
||||
if strings.HasSuffix(strings.ToLower(att.Name), ".zip") && !strings.HasSuffix(att.Name, ".sha256") {
|
||||
downloadURL = fmt.Sprintf("%s/releases/download/%s/%s", repoLink, rel.TagName, att.Name)
|
||||
zipName = att.Name
|
||||
break
|
||||
}
|
||||
}
|
||||
// Look for the SHA256 sidecar file.
|
||||
if zipName != "" {
|
||||
@@ -502,47 +501,6 @@ func channelSuffix(channel string) string {
|
||||
}
|
||||
}
|
||||
|
||||
// selectJoomlaArtifact chooses the installable Joomla package zip from a release's
|
||||
// attachments. A release may carry non-installable zips (the raw source archive,
|
||||
// e.g. "<repo>-<channel>-source.zip", or a generic channel archive) alongside the
|
||||
// real package; handing Joomla a source archive fails with "Install path does not
|
||||
// exist". Priority: (1) an extension-prefixed zip (pkg_/com_/mod_/plg_/tpl_/lib_)
|
||||
// that is not a "-source" archive, (2) any non-source zip, (3) any zip. Sidecar
|
||||
// checksums (.sha256) never match (they do not end in ".zip").
|
||||
func selectJoomlaArtifact(atts []*repo_model.Attachment) string {
|
||||
isZip := func(n string) bool { return strings.HasSuffix(strings.ToLower(n), ".zip") }
|
||||
isSource := func(n string) bool { return strings.Contains(strings.ToLower(n), "-source.") }
|
||||
isExtPkg := func(n string) bool {
|
||||
lc := strings.ToLower(n)
|
||||
for _, p := range []string{"pkg_", "com_", "mod_", "plg_", "tpl_", "lib_"} {
|
||||
if strings.HasPrefix(lc, p) {
|
||||
return true
|
||||
}
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
// Priority 1: extension-prefixed, non-source package (the real installable).
|
||||
for _, att := range atts {
|
||||
if isZip(att.Name) && !isSource(att.Name) && isExtPkg(att.Name) {
|
||||
return att.Name
|
||||
}
|
||||
}
|
||||
// Priority 2: any non-source zip.
|
||||
for _, att := range atts {
|
||||
if isZip(att.Name) && !isSource(att.Name) {
|
||||
return att.Name
|
||||
}
|
||||
}
|
||||
// Priority 3: any zip (last resort).
|
||||
for _, att := range atts {
|
||||
if isZip(att.Name) {
|
||||
return att.Name
|
||||
}
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
// readSHA256FromSidecar reads the SHA256 hash from a .sha256 sidecar attachment.
|
||||
// The sidecar format is: "<hex> <filename>\n"
|
||||
func readSHA256FromSidecar(_ context.Context, att *repo_model.Attachment) string {
|
||||
|
||||
@@ -1,75 +0,0 @@
|
||||
// Copyright 2026 Moko Consulting <hello@mokoconsulting.tech>
|
||||
// SPDX-License-Identifier: GPL-3.0-or-later
|
||||
|
||||
package updateserver
|
||||
|
||||
import (
|
||||
"strings"
|
||||
|
||||
"code.mokoconsulting.tech/MokoConsulting/MokoGIT/modules/setting"
|
||||
)
|
||||
|
||||
// This file rewires the update server's per-platform behavior onto the platform
|
||||
// registry (modules/setting) so that the update-feed generator and wire format
|
||||
// for a platform are looked up from config instead of hardcoded.
|
||||
//
|
||||
// Overlap note (for reviewer): PR #825 (feature/updateserver-npm-mcp) also
|
||||
// touches routers/web/repo/updateserver.go and adds models/updateserver/
|
||||
// platform.go (platform constants + ResolvePlatform + IsFeedlessPlatform). To
|
||||
// stay compatible and avoid a heavy conflict, this change is intentionally
|
||||
// ADDITIVE: it adds registry lookups here rather than rewriting the Serve*
|
||||
// handler bodies. The helpers below are drop-in replacements for the hardcoded
|
||||
// per-platform decisions and can be adopted by the handlers once #825 lands.
|
||||
|
||||
// GeneratorForPlatform returns the update-feed generator name for a platform
|
||||
// key, read from the registry. Falls back to "none" for unknown platforms.
|
||||
//
|
||||
// This replaces the hardcoded per-platform generator selection: instead of a
|
||||
// switch on the platform string, callers read registry[platform].UpdateGenerator.
|
||||
func GeneratorForPlatform(platform string) string {
|
||||
def, _ := setting.GetPlatform(platform)
|
||||
if def.UpdateGenerator == "" {
|
||||
return "none"
|
||||
}
|
||||
return def.UpdateGenerator
|
||||
}
|
||||
|
||||
// FeedFormatForPlatform returns the update-feed wire format (xml|json|none) for a
|
||||
// platform key, read from the registry. Content-Type is derived from this.
|
||||
func FeedFormatForPlatform(platform string) string {
|
||||
def, _ := setting.GetPlatform(platform)
|
||||
if def.FeedFormat == "" {
|
||||
return "none"
|
||||
}
|
||||
return def.FeedFormat
|
||||
}
|
||||
|
||||
// ContentTypeForPlatform returns the HTTP Content-Type for a platform's update
|
||||
// feed, derived from the registry feed_format. Empty string when the platform
|
||||
// emits no feed (feed_format=none), letting callers 404.
|
||||
func ContentTypeForPlatform(platform string) string {
|
||||
switch FeedFormatForPlatform(platform) {
|
||||
case "xml":
|
||||
return "application/xml; charset=utf-8"
|
||||
case "json":
|
||||
return "application/json; charset=utf-8"
|
||||
default:
|
||||
return ""
|
||||
}
|
||||
}
|
||||
|
||||
// PlatformServesGenerator reports whether the given platform key resolves (via
|
||||
// the registry) to the named update-feed generator. This lets a Serve* handler
|
||||
// gate on capability config instead of a hardcoded string compare, e.g.
|
||||
//
|
||||
// if !PlatformServesGenerator(platform, "joomla") { ctx.NotFound(nil); return }
|
||||
//
|
||||
// The empty platform string is treated as "joomla" for backwards compatibility
|
||||
// with legacy Joomla repos that predate the registry (mirrors the historic
|
||||
// "empty ⇒ joomla" default; PR #825's ResolvePlatform centralizes this).
|
||||
func PlatformServesGenerator(platform, generator string) bool {
|
||||
if strings.TrimSpace(platform) == "" {
|
||||
platform = "joomla"
|
||||
}
|
||||
return GeneratorForPlatform(platform) == generator
|
||||
}
|
||||
@@ -150,29 +150,20 @@ func WebPathFromRequest(s string) WebPath {
|
||||
}
|
||||
|
||||
var multiHyphenRe = regexp.MustCompile(`-{2,}`)
|
||||
var multiSpaceRe = regexp.MustCompile(` {2,}`)
|
||||
var nonSlugRe = regexp.MustCompile(`[^a-zA-Z0-9+.\- ]`)
|
||||
var nonSlugReWithSlash = regexp.MustCompile(`[^a-zA-Z0-9+.\-/ ]`)
|
||||
var nonSlugRe = regexp.MustCompile(`[^a-zA-Z0-9+.\-]`)
|
||||
var nonSlugReWithSlash = regexp.MustCompile(`[^a-zA-Z0-9+.\-/]`)
|
||||
|
||||
// sanitizeWikiTitle converts a user-provided title into a clean, URL-friendly slug.
|
||||
// Disallowed special characters become hyphens and consecutive hyphens/spaces collapse.
|
||||
// Preserves: letters, digits, hyphens, plus signs (+), dots (.), slashes (/), and spaces.
|
||||
//
|
||||
// Spaces are intentionally kept here (not converted to hyphens): the reversible
|
||||
// title<->web-path escaping in escapeSegToWeb performs the space<->dash conversion
|
||||
// and appends the "DashMarker" (".-") only when a segment contains a *literal* dash.
|
||||
// If this function collapsed spaces into dashes, escapeSegToWeb would mistake every
|
||||
// multi-word title's dashes for literal dashes and wrongly append a trailing ".-"
|
||||
// (e.g. "CICD Dashboard" -> "CICD-Dashboard.-"). See MokoGIT issue #832.
|
||||
// Spaces and special characters become hyphens, consecutive hyphens collapse to one.
|
||||
// Preserves: letters, digits, hyphens, plus signs (+), dots (.), and slashes (/).
|
||||
func sanitizeWikiTitle(title string) string {
|
||||
title = strings.TrimSpace(title)
|
||||
// Preserve slashes as directory separators and spaces for the escaper.
|
||||
title = strings.ReplaceAll(title, " ", "-")
|
||||
// Preserve slashes as directory separators
|
||||
title = nonSlugReWithSlash.ReplaceAllString(title, "-")
|
||||
title = multiSpaceRe.ReplaceAllString(title, " ")
|
||||
title = multiHyphenRe.ReplaceAllString(title, "-")
|
||||
title = strings.NewReplacer("-+-", "-", "+-", "-", "-+", "-").Replace(title) // clean stray plus signs
|
||||
title = strings.Trim(title, "-+.")
|
||||
title = strings.TrimSpace(title) // drop any spaces exposed by trimming leading/trailing punctuation
|
||||
return title
|
||||
}
|
||||
|
||||
|
||||
@@ -44,15 +44,7 @@ func TestUserTitleToWebPath(t *testing.T) {
|
||||
{"wiki-name.-", "wiki-name"},
|
||||
{"the+wiki-name.-", "the wiki-name"},
|
||||
{"a%2Fb", "a/b"},
|
||||
// Regression tests for MokoGIT issue #832: plain multi-word titles must slug
|
||||
// cleanly to "word-word" WITHOUT a spurious trailing ".-" DashMarker.
|
||||
{"CICD-Dashboard", "CICD Dashboard"},
|
||||
{"Incident-Response", "Incident Response"},
|
||||
{"Rollback-Procedures", "Rollback Procedures"},
|
||||
{"Backup-Recovery", "Backup Recovery"},
|
||||
{"15-admin-panels", "15 admin panels"},
|
||||
// Multiple spaces collapse to a single dash (no double dash, no DashMarker).
|
||||
{"a-b", "a b"},
|
||||
{"a%25b", "a%b"},
|
||||
} {
|
||||
assert.EqualValues(t, test.Expected, UserTitleToWebPath("", test.UserTitle))
|
||||
}
|
||||
|
||||
@@ -15,40 +15,5 @@
|
||||
</form>
|
||||
<p class="tw-text-text-light tw-text-sm tw-mt-3">Existing repositories keep their stored platform value even if it is later removed from this list; it simply won't be offered to other repos.</p>
|
||||
</div>
|
||||
|
||||
<h4 class="ui top attached header tw-mt-4">
|
||||
{{svg "octicon-table" 16}} Platform Registry
|
||||
</h4>
|
||||
<div class="ui attached segment">
|
||||
<p class="tw-text-text-light tw-text-sm">Resolved capability attributes per platform. These drive CI, the update server, and workflow sync (exposed at <code>GET /api/v1/platforms</code>). Capabilities are edited via <code>app.ini</code> <code>[metadata] PLATFORM_REGISTRY</code> (inline JSON array or a path to a JSON file such as <code>custom/platforms.json</code>); when unset, a built-in default registry is used.</p>
|
||||
<table class="ui small compact table">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Key</th>
|
||||
<th>Label</th>
|
||||
<th>Family</th>
|
||||
<th>Artifact</th>
|
||||
<th>Update Generator</th>
|
||||
<th>Feed Format</th>
|
||||
<th>Manifest</th>
|
||||
<th>Template Repo</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
{{range .PlatformRegistry}}
|
||||
<tr>
|
||||
<td><code>{{.Key}}</code></td>
|
||||
<td>{{.Label}}</td>
|
||||
<td>{{.Family}}</td>
|
||||
<td>{{if .Artifact}}yes{{else}}no{{end}}</td>
|
||||
<td>{{.UpdateGenerator}}</td>
|
||||
<td>{{.FeedFormat}}</td>
|
||||
<td>{{if .ManifestBased}}yes{{else}}no{{end}}</td>
|
||||
<td>{{.TemplateRepo}}</td>
|
||||
</tr>
|
||||
{{end}}
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
{{template "admin/layout_footer" .}}
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
</div>
|
||||
<div class="field">
|
||||
<label for="username">{{ctx.Locale.Tr "repo.settings.discord_username"}}</label>
|
||||
<input id="username" name="username" value="{{.DiscordHook.Username}}" placeholder="MokoGIT">
|
||||
<input id="username" name="username" value="{{.DiscordHook.Username}}" placeholder="Gitea">
|
||||
</div>
|
||||
<div class="field">
|
||||
<label for="icon_url">{{ctx.Locale.Tr "repo.settings.discord_icon_url"}}</label>
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
<form class="ui form" action="{{.BaseLink}}/packagist/{{or .Webhook.ID "new"}}" method="post">
|
||||
<div class="required field {{if .Err_Username}}error{{end}}">
|
||||
<label for="username">{{ctx.Locale.Tr "repo.settings.packagist_username"}}</label>
|
||||
<input id="username" name="username" value="{{.PackagistHook.Username}}" placeholder="MokoGIT" autofocus required>
|
||||
<input id="username" name="username" value="{{.PackagistHook.Username}}" placeholder="Gitea" autofocus required>
|
||||
</div>
|
||||
<div class="required field {{if .Err_APIToken}}error{{end}}">
|
||||
<label for="api_token">{{ctx.Locale.Tr "repo.settings.packagist_api_token"}}</label>
|
||||
|
||||
@@ -12,7 +12,7 @@
|
||||
|
||||
<div class="field">
|
||||
<label for="username">{{ctx.Locale.Tr "repo.settings.slack_username"}}</label>
|
||||
<input id="username" name="username" value="{{.SlackHook.Username}}" placeholder="MokoGIT">
|
||||
<input id="username" name="username" value="{{.SlackHook.Username}}" placeholder="Gitea">
|
||||
</div>
|
||||
<div class="field">
|
||||
<label for="icon_url">{{ctx.Locale.Tr "repo.settings.slack_icon_url"}}</label>
|
||||
|
||||
Generated
+3
-3
@@ -11,8 +11,8 @@
|
||||
],
|
||||
"swagger": "2.0",
|
||||
"info": {
|
||||
"description": "This documentation describes the MokoGIT API.",
|
||||
"title": "MokoGIT API",
|
||||
"description": "This documentation describes the Gitea API.",
|
||||
"title": "Gitea API",
|
||||
"license": {
|
||||
"name": "MIT",
|
||||
"url": "http://opensource.org/licenses/MIT"
|
||||
@@ -22738,7 +22738,7 @@
|
||||
"tags": [
|
||||
"miscellaneous"
|
||||
],
|
||||
"summary": "Returns the version of the MokoGIT application",
|
||||
"summary": "Returns the version of the Gitea application",
|
||||
"operationId": "getVersion",
|
||||
"responses": {
|
||||
"200": {
|
||||
|
||||
@@ -12106,12 +12106,12 @@
|
||||
}
|
||||
},
|
||||
"info": {
|
||||
"description": "This documentation describes the MokoGIT API.",
|
||||
"description": "This documentation describes the Gitea API.",
|
||||
"license": {
|
||||
"name": "MIT",
|
||||
"url": "http://opensource.org/licenses/MIT"
|
||||
},
|
||||
"title": "MokoGIT API",
|
||||
"title": "Gitea API",
|
||||
"version": "{{.SwaggerAppVer}}"
|
||||
},
|
||||
"openapi": "3.0.3",
|
||||
@@ -36295,7 +36295,7 @@
|
||||
"$ref": "#/components/responses/ServerVersion"
|
||||
}
|
||||
},
|
||||
"summary": "Returns the version of the MokoGIT application",
|
||||
"summary": "Returns the version of the Gitea application",
|
||||
"tags": [
|
||||
"miscellaneous"
|
||||
]
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
<div class="ui container fluid">
|
||||
<div class="tw-text-center tw-mb-4">
|
||||
<img src="{{AssetUrlPrefix}}/img/login-logo.png" style="max-width: 220px; max-height: 80px; object-fit: contain;" onerror="this.style.display='none'">
|
||||
<img src="{{AssetUrlPrefix}}/img/logo.svg" alt="{{ctx.Locale.Tr "logo"}}" style="max-width: 220px; max-height: 80px; object-fit: contain;" onerror="this.src='{{AssetUrlPrefix}}/img/logo.png'">
|
||||
|
||||
</div>
|
||||
{{if or (not .LinkAccountMode) (and .LinkAccountMode .LinkAccountModeSignIn)}}
|
||||
{{template "base/alert" .}}
|
||||
|
||||
Reference in New Issue
Block a user