-
Notifications
You must be signed in to change notification settings - Fork 3
93 lines (87 loc) · 3.07 KB
/
container-build.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
# .github/workflows/container-build.yml
name: Build and Push Containers
on:
push:
branches:
- main
paths-ignore:
- '*.md'
- 'docs/**'
- '.github/**'
- '!.github/workflows/container-build.yml'
permissions:
contents: read
packages: write
jobs:
build-containers:
runs-on: ubuntu-latest
env:
VERSION: latest
BASE_REPO: ghcr.io/carverauto/serviceradar
steps:
- uses: actions/checkout@v4
- name: Extract short SHA
id: vars
run: echo "sha_short=$(git rev-parse --short HEAD)" >> $GITHUB_OUTPUT
- name: Set up Go
uses: actions/setup-go@v5
with:
go-version: '1.24'
- name: Set up Node.js
uses: actions/setup-node@v4
with:
node-version: '20'
cache: 'npm'
cache-dependency-path: 'web/package-lock.json'
- name: Setup ko
uses: ko-build/[email protected]
- name: Build web UI
run: ./scripts/build-web.sh
- name: Move web artifacts
run: |
mkdir -p pkg/cloud/api/web/
cp -r web/dist pkg/cloud/api/web/
mkdir -p cmd/cloud/.kodata
cp -r web/dist cmd/cloud/.kodata/web
- name: Login to GitHub Container Registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Build and push container images
run: |
# Build and push agent
cd cmd/agent
KO_DOCKER_REPO=${{ env.BASE_REPO }}/serviceradar-agent GOFLAGS="-tags=containers" ko build \
--platform=linux/amd64,linux/arm64 \
--tags=sha-${{ steps.vars.outputs.sha_short }},latest \
--bare .
cd ../..
# Build and push poller
cd cmd/poller
KO_DOCKER_REPO=${{ env.BASE_REPO }}/serviceradar-poller GOFLAGS="-tags=containers" ko build \
--platform=linux/amd64,linux/arm64 \
--tags=sha-${{ steps.vars.outputs.sha_short }},latest \
--bare .
cd ../..
# Build and push cloud
cd cmd/cloud
KO_DOCKER_REPO=${{ env.BASE_REPO }}/serviceradar-cloud GOFLAGS="-tags=containers" ko build \
--platform=linux/amd64,linux/arm64 \
--tags=sha-${{ steps.vars.outputs.sha_short }},latest \
--bare .
cd ../..
# Build and push dusk checker
cd cmd/checkers/dusk
KO_DOCKER_REPO=${{ env.BASE_REPO }}/serviceradar-dusk-checker GOFLAGS="-tags=containers" ko build \
--platform=linux/amd64,linux/arm64 \
--tags=sha-${{ steps.vars.outputs.sha_short }},latest \
--bare .
cd ../../..
# Build and push snmp checker
cd cmd/checkers/snmp
KO_DOCKER_REPO=${{ env.BASE_REPO }}/serviceradar-snmp-checker GOFLAGS="-tags=containers" ko build \
--platform=linux/amd64,linux/arm64 \
--tags=sha-${{ steps.vars.outputs.sha_short }},latest \
--bare .