Skip to content

Commit 6ea352e

Browse files
ci(deploy): add binary deployment workflow via WireGuard VPN
1 parent e29a6d0 commit 6ea352e

1 file changed

Lines changed: 78 additions & 0 deletions

File tree

.github/workflows/deploy.yml

Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
name: CI/CD Binary Deployment via VPN
2+
3+
on:
4+
push:
5+
branches: ["feat/ec2-deployment", "main"]
6+
pull_request:
7+
branches: ["main"]
8+
9+
permissions:
10+
contents: read
11+
12+
concurrency:
13+
group: deploy-${{ github.ref }}
14+
cancel-in-progress: false
15+
16+
jobs:
17+
build:
18+
name: Build ARM64 Binary
19+
runs-on: ubuntu-latest
20+
steps:
21+
- name: Checkout code
22+
uses: actions/checkout@v4
23+
24+
- name: Set up Go
25+
uses: actions/setup-go@v5
26+
with:
27+
go-version: "1.26.1"
28+
29+
- name: Build for Graviton (ARM64)
30+
run: |
31+
CGO_ENABLED=0 GOOS=linux GOARCH=arm64 go build -o goperf-linux-arm64 .
32+
33+
- name: Upload Binary Artifact
34+
uses: actions/upload-artifact@v4
35+
with:
36+
name: goperf-binary
37+
path: goperf-linux-arm64
38+
retention-days: 1
39+
40+
deploy:
41+
name: Deploy to Private VM
42+
needs: build
43+
if: github.event_name == 'push'
44+
runs-on: ubuntu-latest
45+
steps:
46+
- name: Download Binary Artifact
47+
uses: actions/download-artifact@v4
48+
with:
49+
name: goperf-binary
50+
51+
- name: Setup WireGuard VPN
52+
uses: egor-tensin/setup-wireguard@v1
53+
with:
54+
endpoint: ${{ secrets.WG_SERVER_ENDPOINT }}
55+
endpoint_public_key: ${{ secrets.WG_SERVER_PUBLIC_KEY }}
56+
private_key: ${{ secrets.WG_PRIVATE_KEY }}
57+
ips: "${{ vars.VPN_CLIENT_IP }}/32"
58+
allowed_ips: "${{ vars.TARGET_PRIVATE_IP }}/32"
59+
60+
- name: Copy Binary to VM
61+
uses: appleboy/scp-action@v0.1.7
62+
with:
63+
host: ${{ vars.TARGET_PRIVATE_IP }}
64+
username: ${{ secrets.SSH_USER }}
65+
key: ${{ secrets.SSH_PRIVATE_KEY }}
66+
source: "goperf-linux-arm64"
67+
target: "/home/${{ secrets.SSH_USER }}/"
68+
69+
- name: Finalize Deployment
70+
uses: appleboy/ssh-action@v1
71+
with:
72+
host: ${{ vars.TARGET_PRIVATE_IP }}
73+
username: ${{ secrets.SSH_USER }}
74+
key: ${{ secrets.SSH_PRIVATE_KEY }}
75+
script: |
76+
mv ~/goperf-linux-arm64 ~/goperf
77+
chmod +x ~/goperf
78+
echo "Deployment successful. Run binary with: ./goperf"

0 commit comments

Comments
 (0)