Files
crank/.github/workflows/deploy.yml
T
2026-03-25 13:30:55 +03:00

56 lines
1.5 KiB
YAML

name: Deploy
on:
push:
branches:
- main
workflow_dispatch:
concurrency:
group: deploy-${{ github.ref }}
cancel-in-progress: true
jobs:
deploy:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup SSH agent
uses: webfactory/ssh-agent@v0.9.0
with:
ssh-private-key: ${{ secrets.DEPLOY_SSH_KEY }}
- name: Sync project to server
run: |
rsync -az --delete \
--exclude ".git" \
--exclude "target" \
--exclude "notes" \
--exclude "node_modules" \
./ "${{ secrets.DEPLOY_USER }}@${{ secrets.DEPLOY_HOST }}:${{ secrets.DEPLOY_PATH }}/"
- name: Write environment file
run: |
ssh "${{ secrets.DEPLOY_USER }}@${{ secrets.DEPLOY_HOST }}" \
"mkdir -p '${{ secrets.DEPLOY_PATH }}' && cat > '${{ secrets.DEPLOY_PATH }}/.env'" \
<<< "${{ secrets.DEPLOY_ENV_FILE }}"
- name: Deploy with Docker Compose
run: |
ssh "${{ secrets.DEPLOY_USER }}@${{ secrets.DEPLOY_HOST }}" "
set -e
cd '${{ secrets.DEPLOY_PATH }}'
docker compose up -d --build --remove-orphans
"
- name: Verify health endpoints
run: |
ssh "${{ secrets.DEPLOY_USER }}@${{ secrets.DEPLOY_HOST }}" "
set -e
curl --fail --silent http://127.0.0.1:3001/health >/dev/null
curl --fail --silent http://127.0.0.1:3002/health >/dev/null
"