Skip to content

Commit

Permalink
add deploy on release
Browse files Browse the repository at this point in the history
  • Loading branch information
ParzivalEugene committed Jul 26, 2024
1 parent a4ac00e commit ec9d627
Show file tree
Hide file tree
Showing 3 changed files with 47 additions and 1 deletion.
22 changes: 22 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -40,3 +40,25 @@ jobs:
files: |
${{ steps.compile.outputs.BUILT_ARCHIVE }}
${{ steps.compile.outputs.BUILT_CHECKSUM }}
deploy:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4

- name: Add SSH key
run: |
mkdir -p ~/.ssh
echo "${{ secrets.HELIOS_SSH }}" > ~/.ssh/helios_ssh
chmod 600 ~/.ssh/helios_ssh
- name: Deploy to Digital Ocean
run: |
ssh -o StrictHostKeyChecking=no -i ~/.ssh/helios_ssh -p ${{ secrets.SSH_PORT }} ${{ secrets.SSH_USER }}@${{ secrets.SSH_HOST }} "kill $(pidof agent-wireguard)"
ssh -o StrictHostKeyChecking=no -i ~/.ssh/helios_ssh -p ${{ secrets.SSH_PORT }} ${{ secrets.SSH_USER }}@${{ secrets.SSH_HOST }} "rm -f download-binary.sh"
scp -o StrictHostKeyChecking=no -i ~/.ssh/helios_ssh -P ${{ secrets.SSH_PORT }} scripts/download-binary.sh ${{ secrets.SSH_USER }}@${{ secrets.SSH_HOST }}:~/download-binary.sh
ssh -o StrictHostKeyChecking=no -i ~/.ssh/helios_ssh -p ${{ secrets.SSH_PORT }} ${{ secrets.SSH_USER }}@${{ secrets.SSH_HOST }} "./agent-wireguard"
16 changes: 15 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,20 @@ cargo run
```
> Yeah, that's it! The server will be running on `http://<AGENT_HOST>:<AGENT_PORT>`.
## Remote Deployment
## Remote Deployment (actions)

### Prerequisites

Setup github secrets following the table below:

| Secret Name | Description |
| --- | --- |
| HELIOS_SSH | SSH private key for the remote server |
| SSH_PORT | SSH port for the remote server |
| SSH_USER | SSH user for the remote server |
| SSH_HOST | IP address or hostname of the remote server |

## Remote Deployment (manual)

### Prerequisites

Expand All @@ -32,3 +45,4 @@ cargo run
3. Download the latest release from the [releases page](https://github.com/HeliosShieldProject/agent-wireguard-rust/releases).
4. Specify .env file following the example [.env.example](.env.example).
5. Unzip the release and run the binary `./agent-wireguard-rust`.

10 changes: 10 additions & 0 deletions scripts/download_binary.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
SAVE_PATH="asset.tar.gz"
rm -f "$SAVE_PATH" agent-wireguard
ASSET_URL=$(curl -s -H "Accept: application/vnd.github.v3+json" https://api.github.com/repos/$OWNER/$REPO/releases/latest | grep '"browser_download_url"' | grep 'tar.gz' | head -n 1 | sed -E 's/.*"([^"]+)".*/\1/')
if [ -z "$ASSET_URL" ]; then
echo "No assets found in the latest release."
exit 1
fi
curl -L -o "$SAVE_PATH" "$ASSET_URL"
tar -xzf "$SAVE_PATH"
rm -f "$SAVE_PATH"

0 comments on commit ec9d627

Please sign in to comment.