Files
plex-playlist/.gitea/workflows/cicd.yml
copilotcoder b6f4a3eaf6
All checks were successful
CICD Start / Sanity and Base Decision (pull_request) Successful in 1m0s
New attempt to fix the CICD
Signed-off-by: copilotcoder <copilotcoder@darkhelm.org>
2026-05-31 16:26:59 -04:00

81 lines
2.6 KiB
YAML

name: CICD
on:
workflow_dispatch:
env:
GITEA_REGISTRY_HOST: kankali.darkhelm.lan
GITEA_REGISTRY_IP: 10.18.75.2
concurrency:
group: cicd-launch-${{ github.ref }}
cancel-in-progress: true
jobs:
launch:
name: Launch CICD Start
runs-on: ubuntu-act
steps:
- name: Configure registry host resolution
run: |
if ! grep -q "${GITEA_REGISTRY_HOST}" /etc/hosts; then
echo "${GITEA_REGISTRY_IP} ${GITEA_REGISTRY_HOST}" >> /etc/hosts
fi
- name: Dispatch CICD Start workflow
env:
ACTIONS_TRIGGER_TOKEN: ${{ secrets.ACTIONS_TRIGGER_TOKEN }}
PACKAGE_ACCESS_TOKEN: ${{ secrets.PACKAGE_ACCESS_TOKEN }}
REPO_FULL: ${{ github.repository }}
HEAD_REF: ${{ github.head_ref }}
REF_NAME: ${{ github.ref_name }}
HEAD_SHA: ${{ github.sha }}
run: |
set -e
DISPATCH_TOKEN="${ACTIONS_TRIGGER_TOKEN:-${PACKAGE_ACCESS_TOKEN:-}}"
if [ -z "${DISPATCH_TOKEN}" ]; then
echo "❌ Missing dispatch token. Set ACTIONS_TRIGGER_TOKEN (repo write scope) or ensure PACKAGE_ACCESS_TOKEN has Actions workflow-dispatch permissions."
exit 1
fi
if ! grep -q "${GITEA_REGISTRY_HOST}" /etc/hosts; then
echo "${GITEA_REGISTRY_IP} ${GITEA_REGISTRY_HOST}" >> /etc/hosts
fi
API_BASE="http://${GITEA_REGISTRY_IP}:3001/api/v1"
REPO_OWNER="${REPO_FULL%/*}"
REPO_NAME="${REPO_FULL#*/}"
TARGET_REF="${HEAD_REF:-${REF_NAME}}"
payload=$(cat <<EOF
{
"ref": "${TARGET_REF}",
"inputs": {
"head_sha": "${HEAD_SHA}",
"source_workflow": "CICD"
}
}
EOF
)
DISPATCH_URL="${API_BASE}/repos/${REPO_OWNER}/${REPO_NAME}/actions/workflows/cicd-start.yaml/dispatches"
RESPONSE_FILE="/tmp/dispatch-response.txt"
: > "${RESPONSE_FILE}"
HTTP_CODE=$(curl -sS --connect-timeout 5 --max-time 20 -o "${RESPONSE_FILE}" -w "%{http_code}" -X POST \
-H "Authorization: token ${DISPATCH_TOKEN}" \
-H "Content-Type: application/json" \
"${DISPATCH_URL}" \
-d "${payload}" || true)
if [ "${HTTP_CODE}" -lt 200 ] || [ "${HTTP_CODE}" -ge 300 ]; then
echo "❌ Dispatch failed with HTTP ${HTTP_CODE}"
echo "Dispatch URL: ${DISPATCH_URL}"
echo "Response body:"
cat "${RESPONSE_FILE}" || true
exit 1
fi
echo "✓ CICD Start dispatch succeeded"