diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index be8c1e77..c5aba901 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -210,16 +210,48 @@ jobs: cache-to: type=gha,mode=max # ══════════════════════════════════════════════════════════════════════════ - # Stage 4: Deploy (only after build succeeds, only on main branch) + # Stage 4: Update preprod K8s manifest (ArgoCD GitOps, only on main) # ══════════════════════════════════════════════════════════════════════════ - deploy: - name: Deploy to Production + update-k8s-manifest: + name: Update Preprod K8s Manifest runs-on: ubuntu-latest needs: [build] if: github.ref == 'refs/heads/main' && github.event_name == 'push' steps: - - name: Call Deployment Webhook + - name: Compute image tag + id: tag run: | - curl -X POST https://docker2.kuechenserver.org/api/stacks/webhooks/960c7d8e-97ec-4175-a8dc-73f037b02349 + SHORT_SHA=$(echo "${{ github.sha }}" | cut -c1-7) + echo "image=ghcr.io/${{ github.repository_owner }}/docuelevate:main-${SHORT_SHA}" >> "$GITHUB_OUTPUT" + echo "tag=main-${SHORT_SHA}" >> "$GITHUB_OUTPUT" + + - name: Checkout k8s-cluster-state + uses: actions/checkout@v4 + with: + repository: christianlouis/k8s-cluster-state + token: ${{ secrets.GH_PAT }} + path: k8s-cluster-state + + - name: Update image tag in preprod manifest + uses: mikefarah/yq@v4.44.6 + env: + IMAGE: ${{ steps.tag.outputs.image }} + with: + cmd: | + yq -i '(.. | select(tag == "!!str") | select(test("^(ghcr\\.io/christianlouis/docuelevate|christianlouis/docuelevate):"))) = strenv(IMAGE)' \ + k8s-cluster-state/apps/docuelevate/preprod/docuelevate-stack.yaml + + - name: Commit and push + run: | + cd k8s-cluster-state + git config user.name "github-actions[bot]" + git config user.email "github-actions[bot]@users.noreply.github.com" + git add apps/docuelevate/preprod/docuelevate-stack.yaml + if git diff --staged --quiet; then + echo "No changes to commit -- image tag already up to date" + else + git commit -m "chore(preprod): update docuelevate image to ${{ steps.tag.outputs.tag }}" + git push + fi diff --git a/app/views/filemanager.py b/app/views/filemanager.py index e6903189..8f77890d 100644 --- a/app/views/filemanager.py +++ b/app/views/filemanager.py @@ -172,6 +172,7 @@ def _db_records(db: Session, workdir_base: Path) -> List[Dict[str, Any]]: """ rows = [] for rec in db.query(FileRecord).order_by(FileRecord.id.desc()).all(): + def _check(p: str | None) -> Dict[str, Any]: if not p: return {"path": None, "exists": None, "rel": None} diff --git a/tests/test_config.py b/tests/test_config.py index 0faf4a96..f122f509 100644 --- a/tests/test_config.py +++ b/tests/test_config.py @@ -352,7 +352,7 @@ class TestOuterQuoteStripping: def test_mismatched_quotes_not_stripped(self): """Mismatched quotes (open with one type, close with another) are NOT stripped.""" - raw = '"sqlite:///test.db\'' + raw = "\"sqlite:///test.db'" config = Settings( database_url=raw, **_BASE_KWARGS,