Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
53 changes: 53 additions & 0 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
name: Deploy to Production

Check warning on line 1 in .github/workflows/deploy.yml

View workflow job for this annotation

GitHub Actions / YAML Lint

1:1 [document-start] missing document start "---"

on:

Check warning on line 3 in .github/workflows/deploy.yml

View workflow job for this annotation

GitHub Actions / YAML Lint

3:1 [truthy] truthy value should be one of [false, true]
# Triggered directly when a release is cut in THIS repo (infra/migration changes)
release:
types: [published]

# Triggered by Konfig-Web-Backend or Konfig-Web-Frontend releasing
repository_dispatch:
types: [deploy]

# Manual trigger (escape hatch)
workflow_dispatch:
inputs:
reason:
description: "Reason for manual deploy"
required: false
default: "manual"

jobs:
deploy:
name: SSH → VM → deploy.sh
runs-on: ubuntu-latest

steps:
- name: Log trigger source
run: |
if [ "${{ github.event_name }}" = "repository_dispatch" ]; then
echo "Triggered by: ${{ github.event.client_payload.repo }} @ ${{ github.event.client_payload.tag }}"
elif [ "${{ github.event_name }}" = "release" ]; then
echo "Triggered by: Konfig release ${{ github.event.release.tag_name }}"
else
echo "Triggered by: manual workflow_dispatch (${{ inputs.reason }})"
fi

- name: Deploy via SSH
uses: appleboy/ssh-action@v1.0.3
with:
host: ${{ secrets.VM_HOST }}
username: ${{ secrets.VM_USER }}
key: ${{ secrets.VM_SSH_KEY }}
port: 22
# Timeout: deploy can take a few minutes (docker build)
command_timeout: 15m
script: |
set -euo pipefail
cd ${{ secrets.VM_DEPLOY_PATH }}
bash scripts/deploy.sh

- name: Notify on failure
if: failure()
run: |
echo "::error::Deploy failed. Check VM logs: journalctl -u docker or docker compose logs"
20 changes: 20 additions & 0 deletions db/migrations/011_service_tokens.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
-- Migration 011: Service tokens for SDK authentication
-- Stores hashed service tokens; raw token is shown once and never persisted.

CREATE TABLE IF NOT EXISTS service_tokens (
id TEXT PRIMARY KEY,
service_name TEXT NOT NULL,
namespace TEXT NOT NULL DEFAULT '',
token_hash TEXT NOT NULL UNIQUE,
prefix TEXT NOT NULL,
label TEXT NOT NULL DEFAULT '',
created_by TEXT NOT NULL,
created_at TIMESTAMPTZ NOT NULL DEFAULT NOW(),
last_used_at TIMESTAMPTZ,
revoked BOOLEAN NOT NULL DEFAULT FALSE
);

CREATE INDEX IF NOT EXISTS service_tokens_service_name_idx ON service_tokens (service_name);
CREATE INDEX IF NOT EXISTS service_tokens_token_hash_idx ON service_tokens (token_hash);

SELECT '011: service_tokens table created' AS status;
Loading