Skip to content

Commit

Permalink
now its pulling
Browse files Browse the repository at this point in the history
  • Loading branch information
mike dupont committed Dec 24, 2024
1 parent 9fa1b3a commit 8138b4a
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 10 deletions.
4 changes: 3 additions & 1 deletion actions/Readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,9 @@ facilitate remote invocation of a swarms agent on cloud servers.
The script called is defined in `environments/call-swarms/main.tf` and applied in accounts/swarms/ like
```bash
pushd ../../accounts/swarms/
tofu apply
#tofu apply
# apply only the one change
tofu apply -auto-approve --target module.call_swarms.aws_ssm_document.deploy-docker
# terraform apply
popd
```
Expand Down
11 changes: 6 additions & 5 deletions actions/call_swarms.sh
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
#!/bin/bash
echo <<EOF
EOF
# convert this to python boto3
set -e
set -x
# Constants
Expand All @@ -14,7 +12,9 @@ TAG_KEY="${TAG_KEY:-Name}"
TAG_VALUE="${TAG_VALUE:-docker-swarms-ami-t3.medium}"

#what git remote
GIT_URL="${GIT_URL:-https://github.com/jmikedupont/swarms}"
GIT_URL="${GIT_URL:-https://github.com/jmikedupont2/swarms}"
#GIT_URL="${GIT_URL:-git@github.com:jmikedupont2/swarms.git}"
#git@github.com:username/reponame.git

# what to name the repo
export GIT_NAME="${GIT_NAME:-mdupont}"
Expand All @@ -25,9 +25,10 @@ export GIT_VERSION="${GIT_VERSION:-feature/squash2-docker}"
# what script to call?
DOCUMENT_NAME="${DOCUMENT_NAME:-deploy-docker}"

# aws ssm send-command --document-name "deploy-docker" --document-version "\$LATEST" --targets '[{"Key":"InstanceIds","Values":["i-0a3dae164f8f3c09a"]}]' --parameters '{"GitUrl":["https://github.com/jmikedupont/swarms"],"GitName":["mdupont"],"GitVersion":["feature/squash2-docker"]}' --timeout-seconds 600 --max-concurrency "50" --max-errors "0" --output-s3-bucket-name "swarms-session-logs-20241221151754799300000003" --cloud-watch-output-config '{"CloudWatchLogGroupName":"/ssm/session-logs-20241221151803393300000006","CloudWatchOutputEnabled":true}' --region us-east-2

# what version
DOCUMENT_VERSION="${DOCUMENT_VERSION:-1}"
DOCUMENT_VERSION="${DOCUMENT_VERSION:-\$LATEST}"

TIMEOUT_SECONDS="${TIMEOUT_SECONDS:-600}"
MAX_CONCURRENCY="${MAX_CONCURRENCY:-50}"
Expand Down
25 changes: 21 additions & 4 deletions environments/call-swarms/deploy-docker.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,27 @@ mainSteps:
runCommand:
- |
#!/bin/bash
set -x
# now change the ownership of /opt/swarms to the user swarms
chown -R swarms:swarms /opt/swarms
# echo generate this script to run as swarms to pull in latest version
tee /opt/swarms/update_docker_swarms.sh <<'EOF'
cd /opt/swarms/
sudo git remote add {{GitName}} {{GitUrl}} || echo oops
sudo git pull {{GitName}} || echo oops
export HOME=/home/swarms/
git config --global user.email "git-agent@swarms.ai"
git config --global user.name "git agent"
git remote add {{GitName}} {{GitUrl}} || echo oops
git remote set-url {{GitName}} {{GitUrl}} || echo oops2
echo git url {{GitUrl}}
git fetch --all|| echo oops
git pull {{GitName}} {{GitVersion}}|| echo oops
git checkout --force {{GitVersion}} || echo checkout
git log -3 || echo git fail
ls /opt/swarms/api/*.sh || echo no files
EOF
sudo chown swarms /opt/swarms/update_docker_swarms.sh
su -c "bash -e -x /opt/swarms/update_docker_swarms.sh" swarms
sudo git checkout --force {{GitVersion}}
sudo ls /opt/swarms/api/*.sh
sudo bash -e -x /opt/swarms/api/docker-boot.sh # needs root access

0 comments on commit 8138b4a

Please sign in to comment.