Skip to content

Commit 36c40fa

Browse files
committed
Merge branch 'bugfix/10.5.20/update-agent-hostname' of https://github.com/utmstack/UTMStack into bugfix/10.5.20/update-agent-hostname
2 parents ab9e6e6 + 3c1cdb3 commit 36c40fa

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

48 files changed

+1234
-645
lines changed
Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
name: "Alpha Deployment"
2+
3+
on:
4+
workflow_dispatch:
5+
inputs:
6+
version_tag:
7+
description: "Version to deploy."
8+
required: true
9+
event_processor_tag:
10+
description: "Event processor version to use for this deployment."
11+
required: true
12+
13+
jobs:
14+
validations:
15+
name: Validate permissions
16+
runs-on: ubuntu-latest
17+
steps:
18+
- name: Check permissions
19+
run: |
20+
echo "Checking permissions..."
21+
22+
if [[ "${{ github.event.inputs.version_tag }}" =~ ^v[0-9]+\.[0-9]+\.[0-9]+-alpha\.[0-9]+$ ]]; then
23+
echo "✅ Version tag format is correct."
24+
25+
if [[ "${ github.ref }" =~ ^refs/heads/(release/|feature/) ]]; then
26+
echo "✅ Base branch ${ github.ref } is valid."
27+
else
28+
echo "⛔ ERROR: Base branch ${ github.ref } is not valid. It should be release/ or feature/."
29+
exit 1
30+
fi
31+
32+
echo "Validating user permissions..."
33+
RESPONSE=$(curl -s -H "Authorization: Bearer ${{ secrets.GITHUB_TOKEN }}" \
34+
-H "Accept: application/vnd.github.json" \
35+
"https://api.github.com/orgs/utmstack/teams/integration-developers/memberships/${{ github.actor }}")
36+
37+
if echo "$RESPONSE" | grep -q '"state": "active"'; then
38+
echo "✅ User ${{ github.actor }} is a member of the integration-developers team."
39+
else
40+
echo "⛔ ERROR: User ${{ github.actor }} is not a member of the integration-developers team."
41+
exit 1
42+
fi
43+
44+
else
45+
echo "⛔ Version tag format is incorrect. It should be in the format vX.Y.Z-alpha.N."
46+
exit 1
47+
fi
48+
49+
deploy:
50+
name: Deploy
51+
needs: validations
52+
uses: ./.github/workflows/build.yml
53+
with:
54+
version_tag: ${{ github.event.inputs.version_tag }}
55+
event_processor_tag: ${{ github.event.inputs.event_processor_tag }}
56+
environment: alpha
57+
ghcr_token: ${{ secrets.GITHUB_TOKEN }}
58+
sign_cert: ${{ vars.SIGN_CERT }}
59+
sign_key: ${{ secrets.SIGN_KEY }}
60+
sign_container: ${{ secrets.SIGN_CONTAINER }}
61+
env:
62+
CM_AUTH: ${{ secrets.CM_AUTH_ALPHA }}
63+
Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
name: "Beta Deployment"
2+
3+
on:
4+
workflow_dispatch:
5+
inputs:
6+
version_tag:
7+
description: "Version to deploy."
8+
required: true
9+
event_processor_tag:
10+
description: "Event processor version to use for this deployment."
11+
required: true
12+
13+
jobs:
14+
validations:
15+
name: Validate permissions
16+
runs-on: ubuntu-latest
17+
steps:
18+
- name: Check permissions
19+
run: |
20+
echo "Checking permissions..."
21+
22+
if [[ "${{ github.event.inputs.version_tag }}" =~ ^v[0-9]+\.[0-9]+\.[0-9]+-beta\.[0-9]+$ ]]; then
23+
echo "✅ Version tag format is correct."
24+
25+
if [[ "${ github.ref }" =~ ^refs/heads/(release/|feature/) ]]; then
26+
echo "✅ Base branch ${ github.ref } is valid."
27+
else
28+
echo "⛔ ERROR: Base branch ${ github.ref } is not valid. It should be release/ or feature/."
29+
exit 1
30+
fi
31+
32+
echo "Validating user permissions..."
33+
RESPONSE=$(curl -s -H "Authorization: Bearer ${{ secrets.GITHUB_TOKEN }}" \
34+
-H "Accept: application/vnd.github.json" \
35+
"https://api.github.com/orgs/utmstack/teams/core-developers/memberships/${{ github.actor }}")
36+
37+
if echo "$RESPONSE" | grep -q '"state": "active"'; then
38+
echo "✅ User ${{ github.actor }} is a member of the core-developers team."
39+
else
40+
echo "⛔ ERROR: User ${{ github.actor }} is not a member of the core-developers team."
41+
exit 1
42+
fi
43+
44+
else
45+
echo "⛔ Version tag format is incorrect. It should be in the format vX.Y.Z-beta.N."
46+
exit 1
47+
fi
48+
49+
deploy:
50+
name: Deploy
51+
needs: validations
52+
uses: ./.github/workflows/build.yml
53+
with:
54+
version_tag: ${{ github.event.inputs.version_tag }}
55+
event_processor_tag: ${{ github.event.inputs.event_processor_tag }}
56+
environment: beta
57+
ghcr_token: ${{ secrets.GITHUB_TOKEN }}
58+
sign_cert: ${{ vars.SIGN_CERT }}
59+
sign_key: ${{ secrets.SIGN_KEY }}
60+
sign_container: ${{ secrets.SIGN_CONTAINER }}
61+
env:
62+
CM_AUTH: ${{ secrets.CM_AUTH_BETA }}
63+

.github/workflows/build.yml

Lines changed: 134 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,134 @@
1+
name: Build & Push Images
2+
3+
on:
4+
workflow_call:
5+
inputs:
6+
version_tag:
7+
required: true
8+
type: string
9+
event_processor_tag:
10+
required: true
11+
type: string
12+
environment:
13+
required: true
14+
type: string
15+
ghcr_token:
16+
required: true
17+
type: string
18+
sign_cert:
19+
required: true
20+
type: string
21+
sign_key:
22+
required: true
23+
type: string
24+
sign_container:
25+
required: true
26+
type: string
27+
28+
jobs:
29+
build_images:
30+
name: Build Docker Images without dependencies
31+
strategy:
32+
fail-fast: false
33+
matrix:
34+
service: ['backend', 'frontend', 'user-auditor', 'web-pdf']
35+
uses: ./.github/workflows/images-without-dependencies.yml
36+
with:
37+
microservice: ${{ matrix.service }}
38+
tag: ${{ inputs.version_tag }}
39+
secrets: inherit
40+
41+
build_images_with_dependencies:
42+
name: Build & Push Images with dependencies
43+
needs:
44+
- build_images
45+
runs-on: signing
46+
steps:
47+
- name: Check out code into the right branch
48+
uses: actions/checkout@v4
49+
50+
- name: Login to GitHub Container Registry
51+
run: |
52+
docker login ghcr.io -u utmstack -p ${{ inputs.ghcr_token }}
53+
echo "Logged in to GitHub Container Registry"
54+
55+
- name: Download base images
56+
run: |
57+
docker pull ghcr.io/threatwinds/eventprocessor/base:${{ inputs.event_processor_tag }}
58+
echo "Downloaded base images"
59+
60+
- name: Build Agent
61+
run: |
62+
cd ${{ github.workspace }}/agent/service/config; (Get-Content const.go) | Foreach-Object { $_ -replace 'const REPLACE_KEY string = ""', 'const REPLACE_KEY string = "${{ secrets.AGENT_SECRET_PREFIX }}"' } | Set-Content const.go
63+
64+
$env:GOOS = "linux"
65+
$env:GOARCH = "amd64"
66+
cd ${{ github.workspace }}/agent/service; go build -o utmstack_agent_service -v .
67+
cd ${{ github.workspace }}/agent/installer; go build -o utmstack_agent_installer -v .
68+
69+
$env:GOOS = "windows"
70+
cd ${{ github.workspace }}/agent/service; go build -o utmstack_agent_service.exe -v .
71+
signtool sign /fd SHA256 /tr http://timestamp.digicert.com /td SHA256 /f "${{ inputs.sign_cert }}" /csp "eToken Base Cryptographic Provider" /k "[{{${{ inputs.sign_key }}}}]=${{ inputs.sign_container }}" "utmstack_agent_service.exe"
72+
cd ${{ github.workspace }}/agent/installer; go build -o utmstack_agent_installer.exe -v .
73+
signtool sign /fd SHA256 /tr http://timestamp.digicert.com /td SHA256 /f "${{ inputs.sign_cert }}" /csp "eToken Base Cryptographic Provider" /k "[{{${{ inputs.sign_key }}}}]=${{ inputs.sign_container }}" "utmstack_agent_installer.exe"
74+
75+
Copy-Item -Path "C:/dependencies/${{ inputs.environment }}/agent/*" -Destination "./dependencies/"
76+
77+
echo "Agent build completed"
78+
79+
- name: Build Plugins
80+
run: |
81+
export GOOS=linux
82+
export GOARCH=amd64
83+
cd ${{ github.workspace }}/plugins
84+
make build
85+
86+
- name: Build Event Processor Image
87+
run: |
88+
New-Item -ItemType Directory -Force -Path "./geolocation/"
89+
Copy-Item -Path "C:/dependencies/${{ inputs.environment }}/geolocation/*" -Destination "./geolocation/"
90+
91+
docker build -t ghcr.io/utmstack/utmstack/eventprocessor:${{ inputs.version_tag }}-community \
92+
--build-arg BASE_IMAGE=ghcr.io/threatwinds/eventprocessor/base:${{ inputs.event_processor_tag }} \
93+
-f ./event_processor.Dockerfile \
94+
.
95+
echo "Event Processor image built"
96+
97+
- name: Build Agent Manager Image
98+
run: |
99+
go build -o ./agent-manager/agent-manager -v ./agent-manager
100+
docker build -t ghcr.io/utmstack/utmstack/agent-manager:${{ inputs.version_tag }}-community \
101+
-f ./agent-manager/Dockerfile \
102+
.
103+
echo "Agent Manager image built"
104+
105+
- name: Push images with dependencies
106+
run: |
107+
docker push ghcr.io/utmstack/utmstack/eventprocessor:${{ inputs.version_tag }}-community
108+
docker push ghcr.io/utmstack/utmstack/agent-manager:${{ inputs.version_tag }}-community
109+
echo "Pushed images with dependencies"
110+
111+
- name: Push new release
112+
run: |
113+
echo "Pushing new release..."
114+
$changelog = Get-Content -Path "CHANGELOG.md" -Raw
115+
116+
$cmAuth = $env:CM_AUTH | ConvertFrom-Json
117+
118+
$body = @{
119+
version = ${{ inputs.version_tag }}
120+
changelog = $changelog
121+
images = "ghcr.io/utmstack/utmstack/backend,ghcr.io/utmstack/utmstack/frontend,ghcr.io/utmstack/utmstack/user-auditor,ghcr.io/utmstack/utmstack/web-pdf,ghcr.io/utmstack/utmstack/eventprocessor,ghcr.io/utmstack/utmstack/agent-manager"
122+
edition = "community"
123+
} | ConvertTo-Json -Depth 3
124+
125+
$response = Invoke-RestMethod -Method Post `
126+
-Uri "https://customermanager.utmstack.com/${{ inputs.environment }}/api/v1/releases/register" `
127+
-Headers @{
128+
id = $cmAuth.id
129+
key = $cmAuth.key
130+
} `
131+
-Body $body `
132+
-ContentType "application/json"
133+
134+
$response
Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
name: Runner
2+
on:
3+
workflow_call:
4+
inputs:
5+
tag:
6+
required: true
7+
type: string
8+
microservice:
9+
required: true
10+
type: string
11+
12+
jobs:
13+
prepare_deployment:
14+
name: Prepare deployment - ${{inputs.microservice}}
15+
runs-on: ubuntu-latest
16+
outputs:
17+
tech: ${{ steps.get_tech.outputs.tech }}
18+
steps:
19+
- uses: actions/checkout@v4
20+
21+
- name: Determine Tech
22+
id: get_tech
23+
run: |
24+
service="${{inputs.microservice}}"
25+
if [[ "$service" == "backend" ]]; then
26+
tech="java-11"
27+
elif [[ "$service" == "frontend" ]]; then
28+
tech="frontend"
29+
elif [[ "$service" == "user-auditor" || "web-pdf" ]]; then
30+
tech="java"
31+
else
32+
tech="unknown"
33+
fi
34+
echo $tech
35+
echo "::set-output name=tech::$tech"
36+
shell: bash
37+
38+
frontend_deployment:
39+
name: Frontend deployment
40+
needs: prepare_deployment
41+
if: ${{ needs.prepare_deployment.outputs.tech == 'frontend' }}
42+
uses: ./.github/workflows/used-docker-frontend.yml
43+
with:
44+
image_name: ${{ inputs.microservice }}
45+
environment: ${{inputs.tag}}-community
46+
47+
golang_deployment:
48+
name: Golang deployment
49+
needs: prepare_deployment
50+
if: ${{ needs.prepare_deployment.outputs.tech == 'golang' }}
51+
uses: ./.github/workflows/used-docker-golang.yml
52+
with:
53+
image_name: ${{ inputs.microservice }}
54+
environment: ${{inputs.tag}}-community
55+
56+
java_11_deployment:
57+
name: Java 11 deployment
58+
needs: prepare_deployment
59+
if: ${{ needs.prepare_deployment.outputs.tech == 'java-11' }}
60+
uses: ./.github/workflows/used-docker-java-11.yml
61+
with:
62+
image_name: ${{ inputs.microservice }}
63+
tag: ${{inputs.tag}}-community
64+
version: ${{inputs.tag}}
65+
66+
java_deployment:
67+
name: Java deployment
68+
needs: prepare_deployment
69+
if: ${{ needs.prepare_deployment.outputs.tech == 'java' }}
70+
uses: ./.github/workflows/used-docker-java.yml
71+
with:
72+
image_name: ${{ inputs.microservice }}
73+
environment: ${{inputs.tag}}-community

0 commit comments

Comments
 (0)