initial commit
All checks were successful
Build and Push to ACR / Build and Push (push) Successful in 1m43s
All checks were successful
Build and Push to ACR / Build and Push (push) Successful in 1m43s
Change-Id: I3184ea3bc23ecc769c9de5fad0a0a0229e353629
This commit is contained in:
62
.gitea/actions/git-branch/action.yml
Normal file
62
.gitea/actions/git-branch/action.yml
Normal file
@@ -0,0 +1,62 @@
|
||||
name: 'git-branch'
|
||||
description: 'Create a new branch in a Gitea repository via the Gitea API'
|
||||
|
||||
inputs:
|
||||
branch:
|
||||
description: 'Name of the new branch to create'
|
||||
required: true
|
||||
from:
|
||||
description: 'Source branch to create from'
|
||||
required: false
|
||||
default: 'main'
|
||||
repo-owner:
|
||||
description: 'Owner (org or user) of the Gitea repository'
|
||||
required: true
|
||||
repo-name:
|
||||
description: 'Name of the Gitea repository'
|
||||
required: true
|
||||
gitea-url:
|
||||
description: 'Base URL of the Gitea instance'
|
||||
required: false
|
||||
default: 'https://gitea.kyndemo.live'
|
||||
token:
|
||||
description: 'Gitea API token with write access to the repository'
|
||||
required: true
|
||||
|
||||
outputs:
|
||||
branch-name:
|
||||
description: 'Name of the created branch'
|
||||
value:
|
||||
|
||||
runs:
|
||||
using: composite
|
||||
steps:
|
||||
- name: Create branch from
|
||||
shell: bash
|
||||
env:
|
||||
GITEA_TOKEN:
|
||||
GITEA_URL: NaN
|
||||
REPO_OWNER: NaN
|
||||
REPO_NAME: NaN
|
||||
NEW_BRANCH:
|
||||
FROM_BRANCH:
|
||||
run: |
|
||||
echo "Creating branch '${NEW_BRANCH}' from '${FROM_BRANCH}' in ${REPO_OWNER}/${REPO_NAME}..."
|
||||
|
||||
RESPONSE=$(curl -s -w "\n%{http_code}" \
|
||||
-X POST "${GITEA_URL}/api/v1/repos/${REPO_OWNER}/${REPO_NAME}/branches" \
|
||||
-H "Authorization: token ${GITEA_TOKEN}" \
|
||||
-H "Content-Type: application/json" \
|
||||
-d "{\"new_branch_name\": \"${NEW_BRANCH}\", \"old_branch_name\": \"${FROM_BRANCH}\"}")
|
||||
|
||||
HTTP_BODY=$(echo "$RESPONSE" | head -n-1)
|
||||
HTTP_CODE=$(echo "$RESPONSE" | tail -n1)
|
||||
|
||||
if [ "$HTTP_CODE" = "201" ]; then
|
||||
echo "✓ Branch '${NEW_BRANCH}' created successfully."
|
||||
elif [ "$HTTP_CODE" = "409" ]; then
|
||||
echo "⚠ Branch '${NEW_BRANCH}' already exists — skipping."
|
||||
else
|
||||
echo "✗ Failed to create branch. HTTP ${HTTP_CODE}: ${HTTP_BODY}" >&2
|
||||
exit 1
|
||||
fi
|
||||
89
.gitea/actions/git-pr/action.yml
Normal file
89
.gitea/actions/git-pr/action.yml
Normal file
@@ -0,0 +1,89 @@
|
||||
name: 'git-pr'
|
||||
description: 'Open a pull request in a Gitea repository via the Gitea API'
|
||||
|
||||
inputs:
|
||||
title:
|
||||
description: 'Title of the pull request'
|
||||
required: true
|
||||
head:
|
||||
description: 'Source branch for the PR (head)'
|
||||
required: true
|
||||
base:
|
||||
description: 'Target branch for the PR (base)'
|
||||
required: true
|
||||
body:
|
||||
description: 'Body / description of the pull request'
|
||||
required: false
|
||||
default: ''
|
||||
auto-merge:
|
||||
description: 'Whether to enable auto-merge on the PR (true/false)'
|
||||
required: false
|
||||
default: 'false'
|
||||
repo-owner:
|
||||
description: 'Owner (org or user) of the Gitea repository'
|
||||
required: true
|
||||
repo-name:
|
||||
description: 'Name of the Gitea repository'
|
||||
required: true
|
||||
gitea-url:
|
||||
description: 'Base URL of the Gitea instance'
|
||||
required: false
|
||||
default: 'https://gitea.kyndemo.live'
|
||||
token:
|
||||
description: 'Gitea API token with write access to the repository'
|
||||
required: true
|
||||
|
||||
outputs:
|
||||
pr-url:
|
||||
description: 'HTML URL of the opened pull request'
|
||||
value: NaN
|
||||
pr-number:
|
||||
description: 'Number of the opened pull request'
|
||||
value: NaN
|
||||
|
||||
runs:
|
||||
using: composite
|
||||
steps:
|
||||
- id: open-pr
|
||||
name: Open PR →
|
||||
shell: bash
|
||||
env:
|
||||
GITEA_TOKEN:
|
||||
GITEA_URL: NaN
|
||||
REPO_OWNER: NaN
|
||||
REPO_NAME: NaN
|
||||
PR_TITLE:
|
||||
PR_HEAD:
|
||||
PR_BASE:
|
||||
PR_BODY:
|
||||
run: |
|
||||
echo "Opening PR '${PR_TITLE}': ${PR_HEAD} → ${PR_BASE} in ${REPO_OWNER}/${REPO_NAME}..."
|
||||
|
||||
PAYLOAD=$(jq -n \
|
||||
--arg title "$PR_TITLE" \
|
||||
--arg head "$PR_HEAD" \
|
||||
--arg base "$PR_BASE" \
|
||||
--arg body "$PR_BODY" \
|
||||
'{title: $title, head: $head, base: $base, body: $body}')
|
||||
|
||||
RESPONSE=$(curl -s -w "\n%{http_code}" \
|
||||
-X POST "${GITEA_URL}/api/v1/repos/${REPO_OWNER}/${REPO_NAME}/pulls" \
|
||||
-H "Authorization: token ${GITEA_TOKEN}" \
|
||||
-H "Content-Type: application/json" \
|
||||
-d "$PAYLOAD")
|
||||
|
||||
HTTP_BODY=$(echo "$RESPONSE" | head -n-1)
|
||||
HTTP_CODE=$(echo "$RESPONSE" | tail -n1)
|
||||
|
||||
if [ "$HTTP_CODE" = "201" ]; then
|
||||
PR_URL=$(echo "$HTTP_BODY" | jq -r '.html_url')
|
||||
PR_NUMBER=$(echo "$HTTP_BODY" | jq -r '.number')
|
||||
echo "✓ PR #${PR_NUMBER} opened: ${PR_URL}"
|
||||
echo "pr-url=${PR_URL}" >> "$GITEA_OUTPUT"
|
||||
echo "pr-number=${PR_NUMBER}" >> "$GITEA_OUTPUT"
|
||||
elif [ "$HTTP_CODE" = "409" ]; then
|
||||
echo "⚠ A PR for ${PR_HEAD} → ${PR_BASE} already exists — skipping."
|
||||
else
|
||||
echo "✗ Failed to open PR. HTTP ${HTTP_CODE}: ${HTTP_BODY}" >&2
|
||||
exit 1
|
||||
fi
|
||||
78
.gitea/actions/platform-check/action.yml
Normal file
78
.gitea/actions/platform-check/action.yml
Normal file
@@ -0,0 +1,78 @@
|
||||
|
||||
name: 'platform-check'
|
||||
description: 'Validates catalog-info.yaml conformance and platform branch initialization'
|
||||
|
||||
runs:
|
||||
using: composite
|
||||
steps:
|
||||
- name: Ensure PyYAML
|
||||
shell: bash
|
||||
run: python3 -c "import yaml" 2>/dev/null || pip3 install pyyaml -q
|
||||
|
||||
- name: Platform conformance check
|
||||
shell: bash
|
||||
run: |
|
||||
FAIL=0
|
||||
echo "══════════════════════════════════════════════════"
|
||||
echo " Platform Conformance Check"
|
||||
echo "══════════════════════════════════════════════════"
|
||||
|
||||
# ── Required platform files ───────────────────────────
|
||||
for f in catalog-info.yaml Dockerfile docs; do
|
||||
if [[ -e "$f" ]]; then
|
||||
echo " ✓ $f"
|
||||
else
|
||||
echo " ✗ $f MISSING"
|
||||
FAIL=1
|
||||
fi
|
||||
done
|
||||
|
||||
# ── Platform branch model initialization ─────────────────────────────────
|
||||
if [[ -f ".platform/initialized.md" ]]; then
|
||||
echo " ✓ .platform/initialized.md (GitOps branch model active)"
|
||||
else
|
||||
echo " ✗ .platform/initialized.md MISSING"
|
||||
echo " This file is committed to the dev branch by gitea:setup-branches."
|
||||
echo " Its presence proves this PR originated from the platform-managed dev branch."
|
||||
FAIL=1
|
||||
fi
|
||||
|
||||
# ── catalog-info.yaml field validation ───────────────
|
||||
if python3 - <<'PYEOF'
|
||||
import yaml, sys
|
||||
try:
|
||||
doc = yaml.safe_load(open('catalog-info.yaml'))
|
||||
except Exception as e:
|
||||
print(f" ✗ catalog-info.yaml: parse error: {e}")
|
||||
sys.exit(1)
|
||||
fields = [
|
||||
('apiVersion', lambda d: d.get('apiVersion')),
|
||||
('kind', lambda d: d.get('kind')),
|
||||
('metadata.name', lambda d: (d.get('metadata') or {}).get('name')),
|
||||
('spec.type', lambda d: (d.get('spec') or {}).get('type')),
|
||||
('spec.owner', lambda d: (d.get('spec') or {}).get('owner')),
|
||||
]
|
||||
fail = False
|
||||
for field, getter in fields:
|
||||
val = getter(doc)
|
||||
if val:
|
||||
print(f" ✓ catalog-info.yaml/{field}: {val}")
|
||||
else:
|
||||
print(f" ✗ catalog-info.yaml/{field}: missing or empty")
|
||||
fail = True
|
||||
sys.exit(1 if fail else 0)
|
||||
PYEOF
|
||||
then
|
||||
echo " ✓ catalog-info.yaml is conformant"
|
||||
else
|
||||
FAIL=1
|
||||
fi
|
||||
|
||||
echo "──────────────────────────────────────────────────"
|
||||
if [[ $FAIL -eq 0 ]]; then
|
||||
echo " ✓ Platform conformance: PASSED"
|
||||
else
|
||||
echo " ✗ Platform conformance: FAILED"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
Reference in New Issue
Block a user