workflows: Copy binary files as artifacts #6
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
# 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 Servers | |
on: | |
push: | |
branches: | |
- main | |
paths-ignore: | |
- "**.md" | |
- ".gitignore" | |
- "LICENSE" | |
- "CODEOWNERS" | |
- "agent/docs/**" | |
- "server/docs/**" | |
- "agent/scripts/**" | |
- "server/scripts/**" | |
# - "assets/**" | |
# - "scripts/**" | |
# - "src/testclient/scripts/**" | |
# - ".all-contributorsrc" | |
pull_request: | |
branches: | |
- main | |
paths-ignore: | |
- "**.md" | |
- ".gitignore" | |
- "LICENSE" | |
- "CODEOWNERS" | |
- "agent/docs/**" | |
- "server/docs/**" | |
- "agent/scripts/**" | |
- "server/scripts/**" | |
# - "assets/**" | |
# - "scripts/**" | |
# - "src/testclient/scripts/**" | |
# - ".all-contributorsrc" | |
jobs: | |
build-and-deploy-agent: | |
name: Build and deploy agent | |
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 -C agent | |
- uses: actions/upload-artifact@v4 | |
with: | |
name: cm-honeybee-agent | |
path: "agent/cmd/cm-honeybee-agent/cm-honeybee-agent" | |
- uses: actions/download-artifact@v4 | |
with: | |
name: cm-honeybee-agent | |
path: distfiles | |
- name: Stop agent from NFS server | |
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-honeybee-agent" | |
- name: Copy agent 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: "distfiles/cm-honeybee-agent" | |
target: "/usr/bin/" | |
overwrite: true | |
- name: Start agent from NFS server | |
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 start cm-honeybee-agent" | |
- name: Stop agent from Web server | |
uses: appleboy/ssh-action@v1.0.3 | |
with: | |
host: ${{ secrets.CM_SERVER_IP_WEB }} | |
username: ${{ secrets.CM_SERVER_SSH_USER }} | |
password: ${{ secrets.CM_SERVER_SSH_PASSWORD }} | |
port: ${{ secrets.CM_SERVER_SSH_PORT }} | |
script: "systemctl stop cm-honeybee-agent" | |
- name: Copy agent binary to Web server | |
uses: appleboy/scp-action@v0.1.7 | |
with: | |
host: ${{ secrets.CM_SERVER_IP_WEB }} | |
username: ${{ secrets.CM_SERVER_SSH_USER }} | |
password: ${{ secrets.CM_SERVER_SSH_PASSWORD }} | |
port: ${{ secrets.CM_SERVER_SSH_PORT }} | |
source: "distfiles/cm-honeybee-agent" | |
target: "/usr/bin/" | |
overwrite: true | |
- name: Start agent from Web server | |
uses: appleboy/ssh-action@v1.0.3 | |
with: | |
host: ${{ secrets.CM_SERVER_IP_WEB }} | |
username: ${{ secrets.CM_SERVER_SSH_USER }} | |
password: ${{ secrets.CM_SERVER_SSH_PASSWORD }} | |
port: ${{ secrets.CM_SERVER_SSH_PORT }} | |
script: "systemctl start cm-honeybee-agent" | |
build-and-deploy-server: | |
name: Build and deploy server | |
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 -C server | |
- uses: actions/upload-artifact@v4 | |
with: | |
name: cm-honeybee | |
path: "server/cmd/cm-honeybee/cm-honeybee" | |
- uses: actions/download-artifact@v4 | |
with: | |
name: cm-honeybee | |
path: distfiles | |
- name: Stop server from NFS server | |
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-honeybee" | |
- name: Copy server 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: "distfiles/cm-honeybee" | |
target: "/usr/bin/" | |
overwrite: true | |
- name: Start server from NFS server | |
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 start cm-honeybee" |