Skip to content

Commit

Permalink
workflows: Add binary deploy workflow
Browse files Browse the repository at this point in the history
  • Loading branch information
ish-hcc committed Oct 6, 2024
1 parent 1463c40 commit 50049b8
Showing 1 changed file with 76 additions and 0 deletions.
76 changes: 76 additions & 0 deletions .github/workflows/deploy-to-cm-server.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
# This workflow performs continuous delivery (CD) to CM servers.
# This workflow will build the agent and server binaries. Then deploy to CM servers.
name: Deploy to CM Server

on:
push:
branches:
- main
paths-ignore:
- "**.md"
- ".gitignore"
- "LICENSE"
- "CODEOWNERS"
- "docs/**"
- "scripts/**"
# - "assets/**"
# - "scripts/**"
# - "src/testclient/scripts/**"
# - ".all-contributorsrc"
pull_request:
branches:
- main
paths-ignore:
- "**.md"
- ".gitignore"
- "LICENSE"
- "CODEOWNERS"
- "docs/**"
- "scripts/**"
# - "assets/**"
# - "scripts/**"
# - "src/testclient/scripts/**"
# - ".all-contributorsrc"

jobs:
build-and-deploy:
name: Build and deploy
strategy:
matrix:
go-version: ["1.23.0"]
os: [ubuntu-22.04]
runs-on: ${{matrix.os}}
steps:
- uses: actions/checkout@v4

- name: Set up Go
uses: actions/setup-go@v5
with:
go-version: ${{matrix.go-version}}

- name: Build
run: make

- name: Copy binary to NFS server
uses: appleboy/scp-action@v0.1.7
with:
host: ${{ secrets.CM_SERVER_IP_NFS }}
username: ${{ secrets.CM_SERVER_SSH_USER }}
password: ${{ secrets.CM_SERVER_SSH_PASSWORD }}
port: ${{ secrets.CM_SERVER_SSH_PORT }}
source: "cmd/cm-cicada/cm-cicada"
target: "/tmp/"
strip_components: 2
overwrite: true

- name: Restart service from NFS server with new binary
uses: appleboy/ssh-action@v1.0.3
with:
host: ${{ secrets.CM_SERVER_IP_NFS }}
username: ${{ secrets.CM_SERVER_SSH_USER }}
password: ${{ secrets.CM_SERVER_SSH_PASSWORD }}
port: ${{ secrets.CM_SERVER_SSH_PORT }}
script: |
systemctl stop cm-cicada
mv -f /tmp/cm-cicada /usr/bin/cm-cicada
systemctl start cm-cicada

0 comments on commit 50049b8

Please sign in to comment.