feat: add dev pipeline with branch-specific deploy
This commit is contained in:
@@ -1,5 +1,44 @@
|
|||||||
|
when:
|
||||||
|
event: [push, manual]
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
test:
|
install:
|
||||||
image: alpine
|
image: node:20
|
||||||
commands:
|
commands:
|
||||||
- echo "Hello"
|
- cd server && npm ci
|
||||||
|
|
||||||
|
deploy-main:
|
||||||
|
image: alpine:latest
|
||||||
|
environment:
|
||||||
|
DEPLOY_KEY:
|
||||||
|
from_secret: deploy_key
|
||||||
|
commands:
|
||||||
|
- apk add --no-cache openssh rsync
|
||||||
|
- mkdir -p /ssh
|
||||||
|
- echo "$DEPLOY_KEY" > /ssh/deploy_key
|
||||||
|
- chmod 600 /ssh/deploy_key
|
||||||
|
- rsync -e "ssh -i /ssh/deploy_key -o StrictHostKeyChecking=no" -avz --delete --exclude node_modules --exclude .env ./server/ root@192.168.1.88:/opt/shop/server/server/
|
||||||
|
- ssh -i /ssh/deploy_key -o StrictHostKeyChecking=no root@192.168.1.88 "cd /opt/shop/server/server && npm install 2>&1 | tail -3 && systemctl restart shop-server"
|
||||||
|
depends_on: [install]
|
||||||
|
when:
|
||||||
|
branch: main
|
||||||
|
|
||||||
|
deploy-dev:
|
||||||
|
image: alpine:latest
|
||||||
|
environment:
|
||||||
|
DEPLOY_KEY:
|
||||||
|
from_secret: deploy_key
|
||||||
|
SERVER_ENV_DEV:
|
||||||
|
from_secret: server_env_dev
|
||||||
|
commands:
|
||||||
|
- apk add --no-cache openssh rsync
|
||||||
|
- mkdir -p /ssh
|
||||||
|
- echo "$DEPLOY_KEY" > /ssh/deploy_key
|
||||||
|
- chmod 600 /ssh/deploy_key
|
||||||
|
- echo "$SERVER_ENV_DEV" > /tmp/.env
|
||||||
|
- rsync -e "ssh -i /ssh/deploy_key -o StrictHostKeyChecking=no" -avz --delete --exclude node_modules --exclude .env ./server/ root@192.168.1.118:/opt/shop/server/server/
|
||||||
|
- rsync -e "ssh -i /ssh/deploy_key -o StrictHostKeyChecking=no" -avz /tmp/.env root@192.168.1.118:/opt/shop/server/server/.env
|
||||||
|
- ssh -i /ssh/deploy_key -o StrictHostKeyChecking=no root@192.168.1.118 "cd /opt/shop/server/server && npm install 2>&1 | tail -3 && systemctl restart shop-server"
|
||||||
|
depends_on: [install]
|
||||||
|
when:
|
||||||
|
branch: dev
|
||||||
|
|||||||
Reference in New Issue
Block a user