chore: update all submodule refs + CI/CD workflows + AGENTS.md
This commit is contained in:
@@ -0,0 +1,89 @@
|
||||
name: Deploy
|
||||
|
||||
on:
|
||||
workflow_call:
|
||||
inputs:
|
||||
environment:
|
||||
description: 'Target environment (dev or production)'
|
||||
required: true
|
||||
type: string
|
||||
|
||||
jobs:
|
||||
deploy:
|
||||
runs-on: ubuntu-latest
|
||||
environment: ${{ inputs.environment }}
|
||||
steps:
|
||||
- name: Configure git auth for submodules
|
||||
run: git config --global url."https://x-access-token:${{ secrets.BUILD_TOKEN }}@git.datadunia.com/".insteadOf "https://git.datadunia.com/"
|
||||
|
||||
- uses: actions/checkout@v4
|
||||
with:
|
||||
fetch-depth: 0
|
||||
token: ${{ secrets.BUILD_TOKEN }}
|
||||
persist-credentials: true
|
||||
|
||||
- name: Download all artifacts
|
||||
uses: actions/download-artifact@v3
|
||||
with:
|
||||
path: ./artifacts
|
||||
|
||||
- name: Deploy to ${{ inputs.environment }}
|
||||
env:
|
||||
SSH_PRIVATE_KEY: ${{ secrets.SSH_PRIVATE_KEY }}
|
||||
DEPLOY_HOST: ${{ secrets.DEPLOY_HOST }}
|
||||
DEPLOY_USER: ${{ secrets.DEPLOY_USER }}
|
||||
DEPLOY_PATH: ${{ secrets.DEPLOY_PATH }}
|
||||
run: |
|
||||
echo "Deploying to ${{ inputs.environment }}..."
|
||||
echo "Host: $DEPLOY_HOST"
|
||||
echo "Path: $DEPLOY_PATH"
|
||||
|
||||
# Setup SSH
|
||||
mkdir -p ~/.ssh
|
||||
echo "$SSH_PRIVATE_KEY" > ~/.ssh/deploy_key
|
||||
chmod 600 ~/.ssh/deploy_key
|
||||
ssh-keyscan -H "$DEPLOY_HOST" >> ~/.ssh/known_hosts 2>/dev/null
|
||||
|
||||
# Upload artifacts
|
||||
echo "Uploading server-core..."
|
||||
scp -i ~/.ssh/deploy_key artifacts/server-core-linux-amd64/server-core \
|
||||
"${DEPLOY_USER}@${DEPLOY_HOST}:${DEPLOY_PATH}/bin/"
|
||||
|
||||
echo "Uploading device-agent..."
|
||||
for platform in linux-amd64 linux-arm64; do
|
||||
scp -i ~/.ssh/deploy_key "artifacts/nexus-device-agent-${platform}/nexus-device-agent-${platform}" \
|
||||
"${DEPLOY_USER}@${DEPLOY_HOST}:${DEPLOY_PATH}/bin/"
|
||||
done
|
||||
|
||||
echo "Uploading dashboard..."
|
||||
if [ -d "artifacts/dashboard-ui-dist/dist" ]; then
|
||||
tar -czf /tmp/dashboard-ui.tar.gz -C artifacts/dashboard-ui-dist dist/
|
||||
scp -i ~/.ssh/deploy_key /tmp/dashboard-ui.tar.gz \
|
||||
"${DEPLOY_USER}@${DEPLOY_HOST}:${DEPLOY_PATH}/"
|
||||
fi
|
||||
|
||||
# Deploy on server
|
||||
echo "Running deployment..."
|
||||
ssh -i ~/.ssh/deploy_key "${DEPLOY_USER}@${DEPLOY_HOST}" << 'DEPLOY_SCRIPT'
|
||||
cd "${DEPLOY_PATH}" || exit 1
|
||||
|
||||
# Stop services
|
||||
echo "Stopping services..."
|
||||
docker compose down || true
|
||||
|
||||
# Run update script
|
||||
echo "Running update..."
|
||||
bash update.sh --force
|
||||
|
||||
# Verify services
|
||||
echo "Verifying services..."
|
||||
docker compose ps
|
||||
|
||||
echo "Deployment complete!"
|
||||
DEPLOY_SCRIPT
|
||||
|
||||
echo "Deployed to ${{ inputs.environment }} successfully!"
|
||||
|
||||
- name: Cleanup
|
||||
if: always()
|
||||
run: rm -rf ~/.ssh/deploy_key /tmp/dashboard-ui.tar.gz
|
||||
Reference in New Issue
Block a user