ci(forgejo): port full CI + CD workflows to Forgejo Actions
Some checks failed
CI / Dockerfile Package Check (push) Successful in 42s
CI / Security Scan (push) Failing after 1m7s
CI / OpenSpec Validate (push) Successful in 2m31s
CI / Typecheck (push) Successful in 5m16s
CI / Unit Tests (push) Failing after 5m50s
CI / Build (push) Successful in 4m30s
CI / Lint (push) Successful in 19m28s
CI / Journal Image Smoke Test (push) Failing after 9m17s
CI / E2E Tests (push) Failing after 2m15s
CI / Visual Tests (push) Successful in 16m22s
Some checks failed
CI / Dockerfile Package Check (push) Successful in 42s
CI / Security Scan (push) Failing after 1m7s
CI / OpenSpec Validate (push) Successful in 2m31s
CI / Typecheck (push) Successful in 5m16s
CI / Unit Tests (push) Failing after 5m50s
CI / Build (push) Successful in 4m30s
CI / Lint (push) Successful in 19m28s
CI / Journal Image Smoke Test (push) Failing after 9m17s
CI / E2E Tests (push) Failing after 2m15s
CI / Visual Tests (push) Successful in 16m22s
- ci.yml: all 10 jobs (security/dockerfile/openspec/typecheck/lint/test/ build/visual/e2e/image-smoke); drop merge_group, gitleaks via full URL, visual-diff PR comment via Forgejo API. - cd-apps/cd-brouter/cd-infra/cd-staging: drop GitHub Environments, GHCR push auth via DEPLOY_GHCR_TOKEN. cd-staging flags Forgejo PR-event and peter-evans comment-action risks for validation. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
parent
db8a3bf2ad
commit
7e6d4cbcb2
5 changed files with 1177 additions and 4 deletions
130
.forgejo/workflows/cd-infra.yml
Normal file
130
.forgejo/workflows/cd-infra.yml
Normal file
|
|
@ -0,0 +1,130 @@
|
|||
name: CD Infra
|
||||
# Ported from .github/workflows/cd-infra.yml for Forgejo Actions.
|
||||
# Only difference: no `environment: infra`. No image build here — GHCR login
|
||||
# happens on the server using DEPLOY_GHCR_TOKEN from the merged .env.
|
||||
on:
|
||||
push:
|
||||
branches: [main]
|
||||
paths:
|
||||
- "infrastructure/**"
|
||||
workflow_dispatch:
|
||||
inputs:
|
||||
restart_all:
|
||||
description: "Restart all containers (not just infra)"
|
||||
type: boolean
|
||||
default: false
|
||||
|
||||
concurrency:
|
||||
group: deploy-infra
|
||||
cancel-in-progress: true
|
||||
|
||||
jobs:
|
||||
deploy:
|
||||
name: Deploy Infrastructure
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v7
|
||||
|
||||
- name: Decrypt secrets
|
||||
run: |
|
||||
curl -sLO https://github.com/getsops/sops/releases/download/v3.9.4/sops-v3.9.4.linux.amd64
|
||||
chmod +x sops-v3.9.4.linux.amd64
|
||||
SOPS_AGE_KEY="${{ secrets.AGE_SECRET_KEY }}" ./sops-v3.9.4.linux.amd64 -d infrastructure/secrets.app.env > infrastructure/.env
|
||||
SOPS_AGE_KEY="${{ secrets.AGE_SECRET_KEY }}" ./sops-v3.9.4.linux.amd64 -d infrastructure/secrets.infra.env >> infrastructure/.env
|
||||
echo "DOMAIN=trails.cool" >> infrastructure/.env
|
||||
echo "IS_FLAGSHIP=true" >> infrastructure/.env
|
||||
|
||||
- name: Copy configs to server
|
||||
uses: appleboy/scp-action@v1
|
||||
with:
|
||||
host: ${{ secrets.DEPLOY_HOST }}
|
||||
username: root
|
||||
key: ${{ secrets.DEPLOY_SSH_KEY }}
|
||||
source: "infrastructure/docker-compose.yml,infrastructure/caddy,infrastructure/prometheus/prometheus.yml,infrastructure/loki/loki-config.yml,infrastructure/promtail/promtail-config.yml,infrastructure/postgres/queries.yml,infrastructure/postgres/init-grafana-user.sql,infrastructure/grafana/provisioning,infrastructure/grafana/dashboards,infrastructure/scripts"
|
||||
target: /opt/trails-cool
|
||||
strip_components: 1
|
||||
|
||||
- name: Copy secrets to server
|
||||
uses: appleboy/scp-action@v1
|
||||
with:
|
||||
host: ${{ secrets.DEPLOY_HOST }}
|
||||
username: root
|
||||
key: ${{ secrets.DEPLOY_SSH_KEY }}
|
||||
source: "infrastructure/.env"
|
||||
target: /opt/trails-cool
|
||||
strip_components: 1
|
||||
|
||||
- name: Deploy via SSH
|
||||
uses: appleboy/ssh-action@v1
|
||||
with:
|
||||
host: ${{ secrets.DEPLOY_HOST }}
|
||||
username: root
|
||||
key: ${{ secrets.DEPLOY_SSH_KEY }}
|
||||
script: |
|
||||
set -euo pipefail
|
||||
cd /opt/trails-cool
|
||||
|
||||
GHCR_TOKEN=$(grep DEPLOY_GHCR_TOKEN .env | cut -d= -f2-)
|
||||
echo "$GHCR_TOKEN" | docker login ghcr.io -u stigi --password-stdin 2>/dev/null || true
|
||||
|
||||
docker compose exec -T postgres psql -U trails -d trails -f /docker-entrypoint-initdb.d/init-grafana-user.sql 2>/dev/null || true
|
||||
GRAFANA_DB_PW=$(grep GRAFANA_DB_PASSWORD .env | cut -d= -f2-)
|
||||
if [ -n "$GRAFANA_DB_PW" ]; then
|
||||
docker compose exec -T postgres psql -U trails -d trails -c "ALTER ROLE grafana_reader PASSWORD '$GRAFANA_DB_PW'" 2>/dev/null || true
|
||||
fi
|
||||
|
||||
PROMETHEUS_BEFORE_ID=$(docker inspect -f '{{.Id}}' trails-cool-prometheus-1 2>/dev/null || true)
|
||||
|
||||
if [ "${{ github.event.inputs.restart_all }}" = "true" ]; then
|
||||
docker compose --env-file .env up -d --remove-orphans
|
||||
else
|
||||
docker compose --env-file .env up -d --remove-orphans postgres prometheus loki promtail grafana postgres-exporter node-exporter cadvisor
|
||||
fi
|
||||
|
||||
PROMETHEUS_AFTER_ID=$(docker inspect -f '{{.Id}}' trails-cool-prometheus-1 2>/dev/null || true)
|
||||
|
||||
if [ -n "$PROMETHEUS_BEFORE_ID" ] && [ "$PROMETHEUS_BEFORE_ID" = "$PROMETHEUS_AFTER_ID" ]; then
|
||||
docker compose --env-file .env kill -s SIGHUP prometheus
|
||||
fi
|
||||
docker compose --env-file .env restart loki promtail
|
||||
docker compose exec caddy caddy reload --config /etc/caddy/Caddyfile
|
||||
|
||||
docker compose ps
|
||||
|
||||
for ctr in trails-cool-postgres-1 trails-cool-journal-1; do
|
||||
for i in $(seq 1 36); do
|
||||
status=$(docker inspect -f '{{.State.Health.Status}}' "$ctr" 2>/dev/null || echo missing)
|
||||
[ "$status" = "healthy" ] && break
|
||||
sleep 5
|
||||
done
|
||||
if [ "$status" != "healthy" ]; then
|
||||
echo "$ctr did not become healthy (last status: $status)"
|
||||
exit 1
|
||||
fi
|
||||
done
|
||||
|
||||
PROMETHEUS_READY=
|
||||
for i in $(seq 1 36); do
|
||||
prom_status=$(docker inspect -f '{{.State.Status}}' trails-cool-prometheus-1 2>/dev/null || echo missing)
|
||||
if [ "$prom_status" = "running" ]; then
|
||||
prom_ip=$(docker inspect -f '{{range.NetworkSettings.Networks}}{{.IPAddress}}{{end}}' trails-cool-prometheus-1)
|
||||
if curl -sf "http://$prom_ip:9090/-/ready" >/dev/null; then
|
||||
PROMETHEUS_READY=1
|
||||
break
|
||||
fi
|
||||
fi
|
||||
sleep 5
|
||||
done
|
||||
if [ -z "$PROMETHEUS_READY" ]; then
|
||||
echo "trails-cool-prometheus-1 did not become ready (last status: $prom_status)"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
GRAFANA_TOKEN=$(grep GRAFANA_SERVICE_TOKEN .env | cut -d= -f2-)
|
||||
if [ -n "$GRAFANA_TOKEN" ]; then
|
||||
docker compose exec -T grafana curl -sf -X POST \
|
||||
-H "Authorization: Bearer $GRAFANA_TOKEN" \
|
||||
-H "Content-Type: application/json" \
|
||||
-d '{"text":"Deploy infra ${{ github.sha }}","tags":["deploy","infra"]}' \
|
||||
http://localhost:3000/api/annotations || true
|
||||
fi
|
||||
Loading…
Add table
Add a link
Reference in a new issue