ci: migrate GitHub actions to Gitea actions
Deploy CV Site (andreknie.de) / deploy (push) Canceled after 0s
Deploy CV Site (andreknie.de) / deploy (push) Canceled after 0s
This commit is contained in:
-109
@@ -1,109 +0,0 @@
|
||||
name: Deploy Jury Voting
|
||||
|
||||
on:
|
||||
push:
|
||||
branches:
|
||||
- main
|
||||
workflow_dispatch:
|
||||
|
||||
concurrency:
|
||||
group: ${{ github.workflow }}-${{ github.ref }}
|
||||
cancel-in-progress: true
|
||||
|
||||
permissions:
|
||||
contents: read
|
||||
|
||||
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
|
||||
env:
|
||||
NODE_ENV: production
|
||||
run: npm run build
|
||||
|
||||
- name: Create deployment archive
|
||||
run: |
|
||||
tar czf deploy.tar.gz \
|
||||
--exclude='*.pdf' \
|
||||
--exclude='*.doc' \
|
||||
--exclude='*.xlsx' \
|
||||
--exclude='Teams' \
|
||||
--exclude='node_modules' \
|
||||
--exclude='.git' \
|
||||
dist/ \
|
||||
server/ \
|
||||
shared/ \
|
||||
package.json \
|
||||
package-lock.json \
|
||||
jury-voting.service \
|
||||
tsconfig.json \
|
||||
tsconfig.node.json
|
||||
|
||||
- name: Deploy to VPS
|
||||
uses: appleboy/ssh-action@v1
|
||||
with:
|
||||
host: 217.160.174.2
|
||||
username: root
|
||||
key: ${{ secrets.DEPLOY_SSH_KEY }}
|
||||
script: |
|
||||
mkdir -p /opt/jury-voting/server/data
|
||||
|
||||
- name: Upload archive
|
||||
uses: appleboy/scp-action@v0.1.7
|
||||
with:
|
||||
host: 217.160.174.2
|
||||
username: root
|
||||
key: ${{ secrets.DEPLOY_SSH_KEY }}
|
||||
source: deploy.tar.gz
|
||||
target: /tmp/
|
||||
|
||||
- name: Extract and start service
|
||||
uses: appleboy/ssh-action@v1
|
||||
with:
|
||||
host: 217.160.174.2
|
||||
username: root
|
||||
key: ${{ secrets.DEPLOY_SSH_KEY }}
|
||||
script: |
|
||||
set -e
|
||||
|
||||
# Install Node.js if not present
|
||||
if ! command -v node &> /dev/null; then
|
||||
curl -fsSL https://deb.nodesource.com/setup_20.x | bash -
|
||||
apt-get install -y nodejs
|
||||
fi
|
||||
|
||||
# Extract archive (preserve session.json)
|
||||
cd /opt/jury-voting
|
||||
tar xzf /tmp/deploy.tar.gz --overwrite
|
||||
rm -f /tmp/deploy.tar.gz
|
||||
|
||||
# Install production dependencies
|
||||
npm ci --omit=dev
|
||||
|
||||
# Seed data if first run
|
||||
if [ ! -f server/data/session.json ]; then
|
||||
cp server/data/seed.json server/data/session.json
|
||||
fi
|
||||
|
||||
# Install and restart systemd service
|
||||
cp jury-voting.service /etc/systemd/system/jury-voting.service
|
||||
systemctl daemon-reload
|
||||
systemctl enable jury-voting
|
||||
systemctl restart jury-voting
|
||||
|
||||
# Verify
|
||||
sleep 2
|
||||
curl -sf http://localhost:3002/api/health && echo "Deploy successful!" || (journalctl -u jury-voting -n 20 --no-pager && exit 1)
|
||||
-113
@@ -1,113 +0,0 @@
|
||||
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"
|
||||
@@ -1,38 +0,0 @@
|
||||
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