feat: real-time traffic monitoring (backend + frontend + CI workflow)
This commit is contained in:
@@ -0,0 +1,191 @@
|
||||
name: NexusGuard CI/CD
|
||||
|
||||
on:
|
||||
push:
|
||||
tags:
|
||||
- 'v*'
|
||||
- 'dev-*'
|
||||
|
||||
env:
|
||||
BUILD_TOKEN: ${{ secrets.BUILD_TOKEN }}
|
||||
|
||||
jobs:
|
||||
# ──────────────────────────────────────────────
|
||||
# TEST — all 3 components in parallel
|
||||
# ──────────────────────────────────────────────
|
||||
server-core-test:
|
||||
runs-on: ubuntu-latest
|
||||
defaults:
|
||||
run:
|
||||
working-directory: apps/server-core
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
with:
|
||||
submodules: true
|
||||
fetch-depth: 0
|
||||
token: ${{ secrets.BUILD_TOKEN }}
|
||||
# Tambahkan ini jika menggunakan self-hosted Gitea runner:
|
||||
persist-credentials: true
|
||||
# Gitea kadang perlu ini:
|
||||
github-server-url: 'https://git.datadunia.com'
|
||||
- uses: actions/setup-go@v5
|
||||
with:
|
||||
go-version: '1.25'
|
||||
- name: Test
|
||||
run: go test ./... -tags dev -cover
|
||||
|
||||
device-agent-test:
|
||||
runs-on: ubuntu-latest
|
||||
defaults:
|
||||
run:
|
||||
working-directory: apps/device-agent
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
with:
|
||||
submodules: true
|
||||
fetch-depth: 0
|
||||
token: ${{ secrets.BUILD_TOKEN }}
|
||||
# Tambahkan ini jika menggunakan self-hosted Gitea runner:
|
||||
persist-credentials: true
|
||||
# Gitea kadang perlu ini:
|
||||
github-server-url: 'https://git.datadunia.com'
|
||||
- uses: actions/setup-go@v5
|
||||
with:
|
||||
go-version: '1.25'
|
||||
- name: Test
|
||||
run: go test ./... -cover
|
||||
|
||||
dashboard-test:
|
||||
runs-on: ubuntu-latest
|
||||
defaults:
|
||||
run:
|
||||
working-directory: apps/dashboard-ui
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
with:
|
||||
submodules: true
|
||||
fetch-depth: 0
|
||||
token: ${{ secrets.BUILD_TOKEN }}
|
||||
# Tambahkan ini jika menggunakan self-hosted Gitea runner:
|
||||
persist-credentials: true
|
||||
# Gitea kadang perlu ini:
|
||||
github-server-url: 'https://git.datadunia.com'
|
||||
- uses: actions/setup-node@v4
|
||||
with:
|
||||
node-version: '24'
|
||||
- name: Install
|
||||
run: npm ci || npm install
|
||||
- name: Build
|
||||
run: npm run build
|
||||
|
||||
# ──────────────────────────────────────────────
|
||||
# BUILD — binaries + frontend dist
|
||||
# ──────────────────────────────────────────────
|
||||
server-core-build:
|
||||
runs-on: ubuntu-latest
|
||||
needs: server-core-test
|
||||
defaults:
|
||||
run:
|
||||
working-directory: apps/server-core
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
with:
|
||||
submodules: true
|
||||
token: ${{ secrets.BUILD_TOKEN }}
|
||||
# Tambahkan ini jika menggunakan self-hosted Gitea runner:
|
||||
persist-credentials: true
|
||||
# Gitea kadang perlu ini:
|
||||
github-server-url: 'https://git.datadunia.com'
|
||||
- uses: actions/setup-go@v5
|
||||
with:
|
||||
go-version: '1.25'
|
||||
- name: Build
|
||||
run: go build -o bin/server-core .
|
||||
- name: Upload binary
|
||||
uses: actions/upload-artifact@v4
|
||||
with:
|
||||
name: server-core-linux-amd64
|
||||
path: apps/server-core/bin/server-core
|
||||
|
||||
device-agent-cross-build:
|
||||
runs-on: ubuntu-latest
|
||||
needs: device-agent-test
|
||||
strategy:
|
||||
matrix:
|
||||
goos: [linux, windows]
|
||||
goarch: [amd64, arm64]
|
||||
exclude:
|
||||
- goos: windows
|
||||
goarch: arm64
|
||||
defaults:
|
||||
run:
|
||||
working-directory: apps/device-agent
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
with:
|
||||
submodules: true
|
||||
token: ${{ secrets.BUILD_TOKEN }}
|
||||
# Tambahkan ini jika menggunakan self-hosted Gitea runner:
|
||||
persist-credentials: true
|
||||
# Gitea kadang perlu ini:
|
||||
github-server-url: 'https://git.datadunia.com'
|
||||
- uses: actions/setup-go@v5
|
||||
with:
|
||||
go-version: '1.25'
|
||||
- name: Build
|
||||
env:
|
||||
CGO_ENABLED: 0
|
||||
GOOS: ${{ matrix.goos }}
|
||||
GOARCH: ${{ matrix.goarch }}
|
||||
run: |
|
||||
EXT=""
|
||||
if [ "${{ matrix.goos }}" = "windows" ]; then EXT=".exe"; fi
|
||||
go build -o bin/nexus-device-agent-${{ matrix.goos }}-${{ matrix.goarch }}${EXT} .
|
||||
- name: Upload artifact
|
||||
uses: actions/upload-artifact@v4
|
||||
with:
|
||||
name: nexus-device-agent-${{ matrix.goos }}-${{ matrix.goarch }}
|
||||
path: apps/device-agent/bin/nexus-device-agent-*
|
||||
|
||||
dashboard-dist:
|
||||
runs-on: ubuntu-latest
|
||||
needs: dashboard-test
|
||||
defaults:
|
||||
run:
|
||||
working-directory: apps/dashboard-ui
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
with:
|
||||
submodules: true
|
||||
token: ${{ secrets.BUILD_TOKEN }}
|
||||
# Gitea kadang perlu ini:
|
||||
github-server-url: 'https://git.datadunia.com'
|
||||
- uses: actions/setup-node@v4
|
||||
with:
|
||||
node-version: '24'
|
||||
- name: Install
|
||||
run: npm ci || npm install
|
||||
- name: Build
|
||||
run: npm run build
|
||||
- name: Upload dist
|
||||
uses: actions/upload-artifact@v4
|
||||
with:
|
||||
name: dashboard-ui-dist
|
||||
path: apps/dashboard-ui/dist/
|
||||
|
||||
# ──────────────────────────────────────────────
|
||||
# RELEASE — tag v* only
|
||||
# ──────────────────────────────────────────────
|
||||
release:
|
||||
runs-on: ubuntu-latest
|
||||
needs: [server-core-build, device-agent-cross-build, dashboard-dist]
|
||||
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/')
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
with:
|
||||
fetch-depth: 0
|
||||
token: ${{ secrets.BUILD_TOKEN }}
|
||||
# Gitea kadang perlu ini:
|
||||
github-server-url: 'https://git.datadunia.com'
|
||||
- name: Echo release step
|
||||
run: echo "Release step for Gitea"
|
||||
Reference in New Issue
Block a user