115 lines
3.0 KiB
YAML
115 lines
3.0 KiB
YAML
name: Deploy Docker Compose
|
|
|
|
on:
|
|
workflow_call:
|
|
inputs:
|
|
vm_ip:
|
|
description: VM IP address
|
|
required: true
|
|
type: string
|
|
|
|
jump_host:
|
|
type: string
|
|
default: 212.3.125.242
|
|
|
|
jump_port:
|
|
type: string
|
|
default: "2222"
|
|
|
|
jump_user:
|
|
type: string
|
|
default: jump
|
|
|
|
vm_port:
|
|
type: string
|
|
default: "22"
|
|
|
|
vm_user:
|
|
type: string
|
|
default: debian
|
|
|
|
compose_path:
|
|
type: string
|
|
default: "~/docker-compose.yml"
|
|
|
|
working_directory:
|
|
type: string
|
|
default: "~"
|
|
|
|
infisical_env:
|
|
description: "Infisical Environment"
|
|
type: string
|
|
required: false
|
|
|
|
infisical_path:
|
|
description: "Infisical secret path"
|
|
type: string
|
|
required: false
|
|
default: "/"
|
|
|
|
infisical_api_url:
|
|
description: "Infisical API URL (for self-hosted instances)"
|
|
type: string
|
|
required: false
|
|
default: "https://secrets.itlab-ffeks.dnu.edu.ua"
|
|
|
|
secrets:
|
|
infisical_project_token:
|
|
description: "Infisical Service Token for project secrets"
|
|
required: true
|
|
|
|
infisical_cicd_token:
|
|
description: "Infisical Service Token for CI/CD secrets"
|
|
required: true
|
|
|
|
jobs:
|
|
deploy:
|
|
runs-on: ubuntu-latest
|
|
|
|
steps:
|
|
- uses: actions/checkout@v4
|
|
|
|
- name: Configure SSH
|
|
uses: $/.gitea/actions/configure-homelab-ssh
|
|
with:
|
|
infisical_cicd_token: ${{ secrets.infisical_cicd_token }}
|
|
infisical_api_url: ${{ inputs.infisical_api_url }}
|
|
infisical_env: ${{ inputs.infisical_env }}
|
|
jump_host: ${{ inputs.jump_host }}
|
|
jump_port: ${{ inputs.jump_port }}
|
|
jump_user: ${{ inputs.jump_user }}
|
|
vm_ip: ${{ inputs.vm_ip }}
|
|
vm_port: ${{ inputs.vm_port }}
|
|
vm_user: ${{ inputs.vm_user }}
|
|
ssh_host_alias: vm
|
|
|
|
- name: Test SSH connection to VM
|
|
run: |
|
|
ssh -vvv vm 'echo "SSH connection successful" && hostname && whoami'
|
|
|
|
- name: Upload compose file
|
|
run: |
|
|
scp docker-compose.yml vm:${{ inputs.compose_path }}
|
|
|
|
- name: Restart services
|
|
run: |
|
|
ssh vm <<'EOF'
|
|
set -e
|
|
cd ${{ inputs.working_directory }}
|
|
|
|
export INFISICAL_TOKEN="${{ secrets.infisical_project_token }}"
|
|
export INFISICAL_API_URL="${{ inputs.infisical_api_url }}"
|
|
export INFISICAL_DOMAIN="$INFISICAL_API_URL"
|
|
export INFISICAL_DISABLE_UPDATE_CHECK=true
|
|
|
|
INFISICAL_ENV="${{ inputs.infisical_env }}"
|
|
if [ -z "$INFISICAL_ENV" ]; then
|
|
INFISICAL_ENV="${{ gitea.ref_name }}"
|
|
fi
|
|
INFISICAL_PATH="${{ inputs.infisical_path }}"
|
|
|
|
echo "Running docker compose down and up under Infisical..."
|
|
infisical run --env="$INFISICAL_ENV" --path="$INFISICAL_PATH" -- docker compose down
|
|
infisical run --env="$INFISICAL_ENV" --path="$INFISICAL_PATH" -- docker compose up -d
|
|
EOF
|