-
-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #71 from OpenMined/rasswanth/add-automated-deploy
[CD] Add automated deployments
- Loading branch information
Showing
2 changed files
with
65 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
name: CD - Deploy SyftBox Server | ||
|
||
on: | ||
workflow_dispatch: | ||
inputs: | ||
version: | ||
description: "SyftBox Version to deploy" | ||
type: string | ||
default: latest | ||
|
||
# Prevents concurrent runs of the same workflow | ||
# while the previous run is still in progress | ||
concurrency: | ||
group: "CD - Deploy SyftBox Server" | ||
cancel-in-progress: false | ||
|
||
jobs: | ||
|
||
deploy-syftbox-server: | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- name: Install Just | ||
uses: extractions/setup-just@v2 | ||
with: | ||
just-version: "1.36.0" | ||
|
||
- name: Set up SSH | ||
run: | | ||
mkdir -p ~/.ssh | ||
echo "${{ secrets.SYFTBOX_SERVER_PRIVATE_KEY }}" > ~/.ssh/syftbox.pem | ||
chmod 600 ~/.ssh/syftbox.pem | ||
ssh-keyscan -H "20.168.10.234" >> ~/.ssh/known_hosts | ||
- name: Deploy SyftBox Server | ||
run: | | ||
just deploy ~/.ssh/syftbox.pem ${{ inputs.version }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -76,29 +76,43 @@ build: | |
rm -rf dist | ||
uv build | ||
|
||
# Build & Deploy syftbox to a remote server using SSH | ||
[group('build')] | ||
deploy keyfile remote="[email protected]": build | ||
fetch-syftbox-version version="latest": | ||
#!/bin/bash | ||
set -eou pipefail | ||
set -euo pipefail | ||
|
||
# If version is latest, then fetch the latest version from PyPI | ||
# else, check if the version exists on PyPI | ||
if [ "{{ version }}" = "latest" ]; then | ||
echo "Fetching the latest version of syftbox from PyPI..." | ||
curl -sSf "https://pypi.org/pypi/syftbox/json" | jq -r ".info.version" || { echo "Failed to fetch the latest version." >&2; exit 1; } | ||
else | ||
echo "Checking if syftbox version {{ version }} exists on PyPI..." | ||
if curl -sSf -o /dev/null "https://pypi.org/pypi/syftbox/{{ version }}/json"; then | ||
echo "{{ version }}" | ||
else | ||
echo "syftbox version {{ version }} does not exist." >&2 | ||
exit 1 | ||
fi | ||
fi | ||
|
||
# there will be only one wheel file in the dist directory, but you never know... | ||
LOCAL_WHEEL=$(ls dist/*.whl | grep syftbox | head -n 1) | ||
|
||
# Remote paths to copy the wheel to | ||
REMOTE_DIR="~" | ||
REMOTE_WHEEL="$REMOTE_DIR/$(basename $LOCAL_WHEEL)" | ||
|
||
echo -e "Deploying {{ _cyan }}$LOCAL_WHEEL{{ _nc }} to {{ _green }}{{ remote }}:$REMOTE_WHEEL{{ _nc }}" | ||
# Build & Deploy syftbox to a remote server using SSH | ||
[group('build')] | ||
deploy keyfile version="latest" remote="[email protected]": | ||
#!/bin/bash | ||
set -eou pipefail | ||
|
||
# change permissions to comply with ssh/scp | ||
chmod 600 {{ keyfile }} | ||
|
||
# Use scp to transfer the file to the remote server | ||
scp -i {{ keyfile }} "$LOCAL_WHEEL" "{{ remote }}:$REMOTE_DIR" | ||
# Sanity Check the syft box version | ||
REMOTE_VERSION=$(just fetch-syftbox-version {{ version }} | tail -n 1) | ||
|
||
echo -e "Deploying syftbox version $REMOTE_VERSION to {{ remote }}..." | ||
|
||
# install pip package | ||
ssh -i {{ keyfile }} {{ remote }} "pip install --break-system-packages $REMOTE_WHEEL --force" | ||
ssh -i {{ keyfile }} {{ remote }} "pip install syftbox==$REMOTE_VERSION --break-system-packages --force" | ||
|
||
# restart service | ||
# TODO - syftbox service was created manually on 20.168.10.234 | ||
|
@@ -139,7 +153,7 @@ bump-version level="patch": | |
|
||
[group('utils')] | ||
ssh keyfile remote="[email protected]": | ||
ssh -i {{ keyfile }} remote | ||
ssh -i {{ keyfile }} {{ remote }} | ||
|
||
# remove all local files & directories | ||
[group('utils')] | ||
|