Move Projekt-KIQ-HP bahn/ -> dhive/ (dhive project); add steering files
This commit is contained in:
+113
@@ -0,0 +1,113 @@
|
||||
name: CI and Deploy
|
||||
|
||||
on:
|
||||
push:
|
||||
branches:
|
||||
- main
|
||||
workflow_dispatch:
|
||||
|
||||
concurrency:
|
||||
group: ${{ github.workflow }}-${{ github.ref }}
|
||||
cancel-in-progress: true
|
||||
|
||||
permissions:
|
||||
contents: read
|
||||
|
||||
env:
|
||||
DEPLOY_HOST: projekt-kiq.d-hive.de
|
||||
DEPLOY_USER: github-deploy
|
||||
DEPLOY_PATH: /opt/projekt-kiq
|
||||
|
||||
jobs:
|
||||
build-and-deploy:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Check out repository
|
||||
uses: actions/checkout@v5
|
||||
|
||||
- name: Set up Node.js
|
||||
uses: actions/setup-node@v5
|
||||
with:
|
||||
node-version: 20
|
||||
cache: npm
|
||||
|
||||
- name: Install dependencies
|
||||
run: npm ci
|
||||
|
||||
- name: Build frontend
|
||||
run: npm run build
|
||||
|
||||
- name: Prepare SSH
|
||||
run: |
|
||||
install -d -m 700 ~/.ssh
|
||||
printf '%s\n' "${{ secrets.DEPLOY_SSH_KEY }}" > ~/.ssh/deploy_key
|
||||
chmod 600 ~/.ssh/deploy_key
|
||||
ssh-keyscan -H "${DEPLOY_HOST}" > ~/.ssh/known_hosts
|
||||
chmod 600 ~/.ssh/known_hosts
|
||||
|
||||
- name: Create directories
|
||||
run: |
|
||||
ssh -i ~/.ssh/deploy_key \
|
||||
-o BatchMode=yes -o IdentitiesOnly=yes -o StrictHostKeyChecking=yes \
|
||||
"${DEPLOY_USER}@${DEPLOY_HOST}" \
|
||||
"install -d -m 755 ${DEPLOY_PATH}/site ${DEPLOY_PATH}/server/data"
|
||||
|
||||
- name: Deploy frontend
|
||||
run: |
|
||||
rsync -az --delete \
|
||||
-e "ssh -i ~/.ssh/deploy_key -o BatchMode=yes -o IdentitiesOnly=yes -o StrictHostKeyChecking=yes" \
|
||||
dist/ "${DEPLOY_USER}@${DEPLOY_HOST}:${DEPLOY_PATH}/site/"
|
||||
|
||||
- name: Deploy backend + Docker files
|
||||
run: |
|
||||
rsync -az \
|
||||
-e "ssh -i ~/.ssh/deploy_key -o BatchMode=yes -o IdentitiesOnly=yes -o StrictHostKeyChecking=yes" \
|
||||
server/ "${DEPLOY_USER}@${DEPLOY_HOST}:${DEPLOY_PATH}/server/"
|
||||
rsync -az \
|
||||
-e "ssh -i ~/.ssh/deploy_key -o BatchMode=yes -o IdentitiesOnly=yes -o StrictHostKeyChecking=yes" \
|
||||
package.json package-lock.json Dockerfile docker-compose.yml \
|
||||
"${DEPLOY_USER}@${DEPLOY_HOST}:${DEPLOY_PATH}/"
|
||||
|
||||
- name: Write .env
|
||||
run: |
|
||||
ssh -i ~/.ssh/deploy_key \
|
||||
-o BatchMode=yes -o IdentitiesOnly=yes -o StrictHostKeyChecking=yes \
|
||||
"${DEPLOY_USER}@${DEPLOY_HOST}" \
|
||||
"printf '%s\n' \
|
||||
'PORT=3003' \
|
||||
'NODE_ENV=production' \
|
||||
'ADMIN_USER=${{ secrets.KIQ_ADMIN_USER }}' \
|
||||
'ADMIN_PASSWORD=${{ secrets.KIQ_ADMIN_PASSWORD }}' \
|
||||
'SESSION_SECRET=${{ secrets.KIQ_SESSION_SECRET }}' \
|
||||
'SMTP_HOST=${{ secrets.KIQ_SMTP_HOST }}' \
|
||||
'SMTP_PORT=${{ secrets.KIQ_SMTP_PORT }}' \
|
||||
'SMTP_USER=${{ secrets.KIQ_SMTP_USER }}' \
|
||||
'SMTP_PASS=${{ secrets.KIQ_SMTP_PASS }}' \
|
||||
'ALERT_EMAIL=${{ secrets.KIQ_ALERT_EMAIL }}' \
|
||||
> ${DEPLOY_PATH}/.env"
|
||||
|
||||
- name: Deploy Caddyfile
|
||||
run: |
|
||||
rsync -az \
|
||||
-e "ssh -i ~/.ssh/deploy_key -o BatchMode=yes -o IdentitiesOnly=yes -o StrictHostKeyChecking=yes" \
|
||||
Caddyfile "${DEPLOY_USER}@${DEPLOY_HOST}:${DEPLOY_PATH}/Caddyfile"
|
||||
ssh -i ~/.ssh/deploy_key \
|
||||
-o BatchMode=yes -o IdentitiesOnly=yes -o StrictHostKeyChecking=yes \
|
||||
"${DEPLOY_USER}@${DEPLOY_HOST}" \
|
||||
"sudo -n /usr/bin/install -o root -g root -m 644 ${DEPLOY_PATH}/Caddyfile /etc/caddy/Caddyfile && \
|
||||
sudo -n /usr/bin/systemctl reload caddy"
|
||||
|
||||
- name: Build and start Docker container
|
||||
run: |
|
||||
ssh -i ~/.ssh/deploy_key \
|
||||
-o BatchMode=yes -o IdentitiesOnly=yes -o StrictHostKeyChecking=yes \
|
||||
"${DEPLOY_USER}@${DEPLOY_HOST}" \
|
||||
"cd ${DEPLOY_PATH} && sudo -n docker compose up -d --build"
|
||||
|
||||
- name: Verify
|
||||
run: |
|
||||
sleep 5
|
||||
ssh -i ~/.ssh/deploy_key \
|
||||
-o BatchMode=yes -o IdentitiesOnly=yes -o StrictHostKeyChecking=yes \
|
||||
"${DEPLOY_USER}@${DEPLOY_HOST}" \
|
||||
"curl -sf http://localhost:3003/api/health || sudo -n docker compose -f ${DEPLOY_PATH}/docker-compose.yml logs --tail 20"
|
||||
@@ -0,0 +1,38 @@
|
||||
name: Sync Tasks to OrgMyLife
|
||||
|
||||
on:
|
||||
push:
|
||||
paths: ['PLAN.md', 'TASKS.md', 'BACKLOG.md']
|
||||
workflow_dispatch: {}
|
||||
|
||||
jobs:
|
||||
sync:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
|
||||
- name: Parse open tasks and sync to OrgMyLife
|
||||
run: |
|
||||
REPO_NAME="Projekt-KIQ-HP"
|
||||
|
||||
TASKS="[]"
|
||||
for file in PLAN.md TASKS.md BACKLOG.md; do
|
||||
if [ -f "$file" ]; then
|
||||
ITEMS=$(grep -E '^\s*- \[ \]' "$file" | sed 's/.*- \[ \] //' | head -50)
|
||||
if [ -n "$ITEMS" ]; then
|
||||
TASKS=$(echo "$ITEMS" | jq -R -s 'split("\n") | map(select(length > 0)) | map({"title": ., "status": "backlog"})')
|
||||
break
|
||||
fi
|
||||
fi
|
||||
done
|
||||
|
||||
echo "Found tasks: $TASKS"
|
||||
|
||||
PAYLOAD=$(jq -n --arg repo "$REPO_NAME" --argjson tasks "$TASKS" '{"repo": $repo, "tasks": $tasks}')
|
||||
|
||||
curl -s -X POST \
|
||||
-u "${{ secrets.ORGMYLIFE_USER }}:${{ secrets.ORGMYLIFE_PASS }}" \
|
||||
-H "X-API-Key: ${{ secrets.ORGMYLIFE_API_SECRET }}" \
|
||||
-H "Content-Type: application/json" \
|
||||
-d "$PAYLOAD" \
|
||||
"https://api.andreknie.de/api/projects/sync"
|
||||
Reference in New Issue
Block a user