Initial commit: hello world + deploy workflow
All checks were successful
Deploy to dev.bl.pixeldev.eu / deploy (push) Successful in 2s
All checks were successful
Deploy to dev.bl.pixeldev.eu / deploy (push) Successful in 2s
This commit is contained in:
commit
2a684eed4d
72
.gitea/workflows/deploy.yml
Normal file
72
.gitea/workflows/deploy.yml
Normal file
@ -0,0 +1,72 @@
|
||||
name: Deploy to dev.bl.pixeldev.eu
|
||||
|
||||
on:
|
||||
push:
|
||||
branches: [main]
|
||||
|
||||
jobs:
|
||||
deploy:
|
||||
runs-on: self-hosted
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v3
|
||||
|
||||
- name: Detect project type
|
||||
id: detect
|
||||
run: |
|
||||
if [ -f package.json ]; then
|
||||
echo "type=node" >> $GITHUB_OUTPUT
|
||||
else
|
||||
echo "type=static" >> $GITHUB_OUTPUT
|
||||
fi
|
||||
|
||||
- name: Sync files
|
||||
run: |
|
||||
SLUG="${{ github.event.repository.name }}"
|
||||
mkdir -p /opt/deployed/${SLUG}
|
||||
rsync -av --delete --exclude='.git' --exclude='node_modules' \
|
||||
$GITHUB_WORKSPACE/ /opt/deployed/${SLUG}/
|
||||
|
||||
- name: Install dependencies
|
||||
if: steps.detect.outputs.type == 'node'
|
||||
run: |
|
||||
cd /opt/deployed/${{ github.event.repository.name }}
|
||||
npm install --production
|
||||
|
||||
- name: Start / restart Node service
|
||||
if: steps.detect.outputs.type == 'node'
|
||||
id: node
|
||||
run: |
|
||||
SLUG="${{ github.event.repository.name }}"
|
||||
DIR="/opt/deployed/${SLUG}"
|
||||
|
||||
# Find entry point
|
||||
ENTRY=""
|
||||
for f in server.js index.js src/server.js src/index.js; do
|
||||
[ -f "$DIR/$f" ] && ENTRY="$DIR/$f" && break
|
||||
done
|
||||
[ -z "$ENTRY" ] && ENTRY=$(node -e "const p=require('$DIR/package.json'); console.log('$DIR/'+p.main)" 2>/dev/null)
|
||||
|
||||
# Allocate port (base 4000 + hash of slug)
|
||||
PORT=$((4000 + $(echo -n "$SLUG" | cksum | cut -d' ' -f1) % 1000))
|
||||
|
||||
# Start or restart
|
||||
pm2 describe "deploy-${SLUG}" > /dev/null 2>&1 \
|
||||
&& pm2 restart "deploy-${SLUG}" \
|
||||
|| PORT=$PORT pm2 start "$ENTRY" --name "deploy-${SLUG}"
|
||||
|
||||
echo "port=$PORT" >> $GITHUB_OUTPUT
|
||||
|
||||
- name: Register with dev registry
|
||||
run: |
|
||||
SLUG="${{ github.event.repository.name }}"
|
||||
NAME="${{ github.event.repository.name }}"
|
||||
TYPE="${{ steps.detect.outputs.type }}"
|
||||
PORT="${{ steps.node.outputs.port }}"
|
||||
|
||||
curl -s -X POST https://dev.bl.pixeldev.eu/api/register \
|
||||
-H "Content-Type: application/json" \
|
||||
-u admin:blaetternd-helix-dribbble124 \
|
||||
-d "{\"name\":\"${NAME}\",\"slug\":\"${SLUG}\",\"type\":\"${TYPE}\",\"port\":\"${PORT}\"}"
|
||||
|
||||
echo "✅ Live at https://dev.bl.pixeldev.eu/${SLUG}/"
|
||||
20
index.html
Normal file
20
index.html
Normal file
@ -0,0 +1,20 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<title>test2</title>
|
||||
<style>
|
||||
* { box-sizing: border-box; margin: 0; padding: 0; }
|
||||
body { background: #0d0d0d; color: #e0e0e0; font-family: 'Segoe UI', system-ui, sans-serif; min-height: 100vh; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 0.5rem; }
|
||||
h1 { font-size: 2.5rem; color: #fff; }
|
||||
p { color: #555; font-size: 0.9rem; }
|
||||
a { color: #7c9ef5; text-decoration: none; font-size: 0.85rem; }
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<h1>Hello, World! 👋</h1>
|
||||
<p>pixeldev/test2</p>
|
||||
<a href="https://dev.bl.pixeldev.eu">← dev.bl.pixeldev.eu</a>
|
||||
</body>
|
||||
</html>
|
||||
Loading…
Reference in New Issue
Block a user