-
Notifications
You must be signed in to change notification settings - Fork 0
66 lines (60 loc) · 2.09 KB
/
Copy pathdeploy-dev.yml
File metadata and controls
66 lines (60 loc) · 2.09 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
---
name: Deploy to naga-dev
on:
# Manually trigger the workflow with specific inputs
workflow_dispatch:
inputs:
release_branch:
description: 'Release Branch to Deploy'
required: true
type: string
jobs:
deploy:
runs-on: ubuntu-latest
name: Deploy Release Branch to naga-dev
steps:
- name: Validate Release Branch Input
if: github.event_name == 'workflow_dispatch'
run: |
if [ -z "${{ inputs.release_branch }}" ]; then
echo "Error: Release Branch name must be provided!"
exit 1
fi
- name: Checkout Repository
uses: actions/checkout@v6
with:
ref: ${{ inputs.release_branch || github.ref }}
fetch-depth: 0
- name: Set up SSH
uses: webfactory/ssh-agent@v0.9.1
with:
ssh-private-key: ${{ secrets.DEV_SSH_KEY }}
- name: Add Server to Known Hosts
run: |
mkdir -p ~/.ssh
ssh-keyscan "naga-dev.litgateway.com" >> ~/.ssh/known_hosts
chmod 600 ~/.ssh/known_hosts
- name: Deploy to Target Server
run: |
ssh "debian@naga-dev.litgateway.com" /bin/bash << 'EOF'
set -e
DEPLOY_BRANCH="${{ inputs.release_branch || github.ref_name }}"
echo "Starting deployment of branch: '${DEPLOY_BRANCH}' to naga-dev"
# source profile and pull changes
source .profile
cd lit-peer/rust/lit-node/lit-node
git fetch origin
git checkout "${DEPLOY_BRANCH}"
git pull origin "${DEPLOY_BRANCH}"
# Build and restart the server
./scripts/build_and_restart_no_sgx.sh
EOF
- name: Notify Deployment Status
if: always()
run: |
if [ "${{ job.status }}" = "success" ]; then
echo "Successfully deployed branch ${{ inputs.release_branch || github.ref_name }} to naga-dev."
else
echo "Error: Deployment of branch ${{ inputs.release_branch || github.ref_name }} to naga-dev failed."
exit 1
fi