-
Notifications
You must be signed in to change notification settings - Fork 2
102 lines (85 loc) · 3.06 KB
/
publish-das-components-image.yml
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
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
name: Build and Publish POC Components
on:
push:
branches:
- master
- das-237
jobs:
build_binaries:
runs-on: self-hosted
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Build Binaries
run: make build-all
- name: Upload Binaries as Artifacts
uses: actions/upload-artifact@v4
with:
name: binaries
path: src/bin
if-no-files-found: "error"
build_and_publish:
runs-on: self-hosted
needs: build_binaries
strategy:
matrix:
target: [attention-broker, query-agent, link-creation-agent, link-creation-client]
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Download Binaries Artifacts
uses: actions/download-artifact@v4
with:
name: binaries
path: src/bin
- name: Log in to Docker Hub
uses: docker/login-action@v2
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}
- name: Build and Push Docker Image
uses: docker/build-push-action@v4
with:
context: .
file: .docker/poc/Dockerfile
push: true
target: ${{ matrix.target }}
tags: trueagi/das:${{ matrix.target }}-poc
deploy_ensemble_to_server:
runs-on: self-hosted
needs: build_and_publish
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Set up SSH key
run: |
echo "Setting up SSH key..."
mkdir -p ~/.ssh
echo "${{ secrets.SSH_PRIVATE_KEY }}" > ~/.ssh/id_rsa
chmod 600 ~/.ssh/id_rsa
eval "$(ssh-agent -s)"
ssh-add ~/.ssh/id_rsa
- name: Copy script to server using SCP
run: |
echo "Copying script to server..."
scp -o StrictHostKeyChecking=no src/scripts/refresh-nunet-deployment.sh ${{ secrets.SSH_USER }}@${{ secrets.SERVER_HOST }}:/tmp/refresh-nunet-deployment.sh
- name: Encode ensemble.yaml and store in environment
id: load_ensemble
run: |
ENSEMBLE_CONTENT=$(base64 -w 0 < src/assets/ensemble.yaml)
echo "ENSEMBLE_CONTENT=$ENSEMBLE_CONTENT" >> $GITHUB_ENV
echo "ensemble.yaml content encoded successfully."
- name: Process ensemble.yaml and execute deployment script on remote server
run: |
echo "Running deployment script on the remote server..."
ssh -o StrictHostKeyChecking=no ${{ secrets.SSH_USER }}@${{ secrets.SERVER_HOST }} << 'EOF'
PEER_ID=$(nunet actor cmd /dms/node/peers/self -c user | jq -r '.id')
if [ -z "$PEER_ID" ]; then
echo "Error: Could not get the peer ID"
exit 1
fi
echo "Peer ID: $PEER_ID"
ENSEMBLE_FILE=$(mktemp /tmp/ensemble.XXXXXX.yaml)
echo "${{ env.ENSEMBLE_CONTENT }}" | base64 --decode | sed "s#\${PEER_ID}#$PEER_ID#g" > $ENSEMBLE_FILE
bash +x /tmp/refresh-nunet-deployment.sh $ENSEMBLE_FILE
EOF