Compare commits
33 Commits
9a59e10b0c
...
v0.1.6
Author | SHA1 | Date | |
---|---|---|---|
b9d5ade0f1 | |||
921b4a9664 | |||
0e9555e3f7 | |||
19c7aaaca1 | |||
068c67d0d9 | |||
4c6635f989 | |||
98080df509 | |||
286f72eac7 | |||
d49977815d | |||
b012693c21 | |||
e385eb94f4 | |||
285ff89cb0 | |||
fe45d901e4 | |||
ba6e201adc | |||
5867cfc3e1 | |||
8771e1ee02 | |||
2be4331a6e | |||
98754be109 | |||
9ee2750534 | |||
9920c94a8b | |||
b7bc477d2e | |||
ab11665665 | |||
37468b6785 | |||
471767c4ed | |||
596baba5ef | |||
12390031f9 | |||
daed8c1462 | |||
7e5e295590 | |||
cb91ca3159 | |||
340f92ed04 | |||
2169b3d45f | |||
27792ff7f4 | |||
2334287437 |
@@ -3,23 +3,22 @@ name: Gitea CI/CD
|
||||
on:
|
||||
workflow_dispatch:
|
||||
push:
|
||||
branches: [ "development", "main", "staging"]
|
||||
tags: [ "v*.*.*" ]
|
||||
pull_request:
|
||||
branches: [ "development", "main", "staging" ]
|
||||
tags: [ "v*.*.*" ]
|
||||
|
||||
env:
|
||||
DOTNET_VERSION: '8.0.x'
|
||||
DOCKER_IMAGE_NAME: watcher-server
|
||||
REGISTRY_URL: git.triggermeelmo.com
|
||||
DOCKER_PLATFORMS: 'linux/amd64,linux/arm64'
|
||||
TAG: ${{ github.ref == 'refs/heads/main' && 'latest' || github.ref == 'refs/heads/development' && 'development' || github.ref_type == 'tag' && github.ref_name || 'pr' }}
|
||||
|
||||
concurrency:
|
||||
group: ${{ github.workflow }}-${{ github.ref }}
|
||||
cancel-in-progress: true
|
||||
|
||||
jobs:
|
||||
build-and-test:
|
||||
runs-on: ubuntu-latest
|
||||
env:
|
||||
RUNNER_TOOL_CACHE: /toolcache # Runner Tool Cache
|
||||
steps:
|
||||
- name: Checkout code
|
||||
uses: actions/checkout@v4
|
||||
@@ -44,11 +43,12 @@ jobs:
|
||||
|
||||
set-tag:
|
||||
name: Set Tag Name
|
||||
needs: [build-and-test]
|
||||
#if: ${{ !failure() && !cancelled() && github.event_name != 'pull_request' }}
|
||||
runs-on: ubuntu-latest
|
||||
env:
|
||||
RUNNER_TOOL_CACHE: /toolcache
|
||||
outputs:
|
||||
tag_name: ${{ steps.set_tag.outputs.tag_name }}
|
||||
should_tag: ${{ steps.set_tag.outputs.should_tag }}
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
|
||||
@@ -72,21 +72,33 @@ jobs:
|
||||
major=$((major + 1))
|
||||
minor=0
|
||||
patch=0
|
||||
new_tag="v${major}.${minor}.${patch}"
|
||||
echo "tag_name=${new_tag}" >> $GITHUB_OUTPUT
|
||||
echo "should_tag=true" >> $GITHUB_OUTPUT
|
||||
echo "Creating new major version tag: ${new_tag}"
|
||||
|
||||
elif [[ "${GITHUB_REF}" == "refs/heads/development" ]]; then
|
||||
minor=$((minor + 1))
|
||||
patch=0
|
||||
else
|
||||
patch=$((patch + 1))
|
||||
fi
|
||||
new_tag="v${major}.${minor}.${patch}"
|
||||
echo "tag_name=${new_tag}" >> $GITHUB_OUTPUT
|
||||
echo "should_tag=true" >> $GITHUB_OUTPUT
|
||||
echo "Creating new minor version tag: ${new_tag}"
|
||||
|
||||
new_tag="v${major}.${minor}.${patch}"
|
||||
echo "tag_name=${new_tag}" >> $GITHUB_OUTPUT
|
||||
elif [[ "${GITHUB_REF}" == "refs/heads/staging" ]]; then
|
||||
patch=$((patch + 1))
|
||||
new_tag="v${major}.${minor}.${patch}"
|
||||
echo "tag_name=${new_tag}" >> $GITHUB_OUTPUT
|
||||
echo "should_tag=true" >> $GITHUB_OUTPUT
|
||||
echo "Creating new patch version tag: ${new_tag}"
|
||||
fi
|
||||
|
||||
docker-build-and-push:
|
||||
runs-on: ubuntu-latest
|
||||
env:
|
||||
RUNNER_TOOL_CACHE: /toolcache # Runner Tool Cache
|
||||
needs: [build-and-test, set-tag]
|
||||
if: |
|
||||
needs.set-tag.outputs.should_tag == 'true' &&
|
||||
github.event_name != 'pull_request'
|
||||
steps:
|
||||
- name: Checkout code
|
||||
uses: actions/checkout@v4
|
||||
@@ -110,10 +122,11 @@ jobs:
|
||||
|
||||
tag:
|
||||
name: Create Tag
|
||||
needs: [docker-build-and-push]
|
||||
needs: [docker-build-and-push, set-tag]
|
||||
if: |
|
||||
needs.set-tag.outputs.should_tag == 'true' &&
|
||||
github.event_name != 'pull_request'
|
||||
runs-on: ubuntu-latest
|
||||
env:
|
||||
RUNNER_TOOL_CACHE: /toolcache
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
with:
|
||||
@@ -128,5 +141,6 @@ jobs:
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
run: |
|
||||
echo "Creating new tag: ${{ needs.set-tag.outputs.tag_name }}"
|
||||
git tag ${{ needs.set-tag.outputs.tag_name }}
|
||||
git push origin ${{ needs.set-tag.outputs.tag_name }}
|
28
Tests/servicediscovery.py
Normal file
28
Tests/servicediscovery.py
Normal file
@@ -0,0 +1,28 @@
|
||||
import json
|
||||
import urllib.request
|
||||
|
||||
url = "http://localhost:5000/monitoring/service-discovery"
|
||||
payload = {
|
||||
"ServerId": 1,
|
||||
"ContainerId": "aaaaaaaaaaaa",
|
||||
"Name": "test-Name",
|
||||
"Image": "test-Image"
|
||||
}
|
||||
|
||||
data = json.dumps(payload).encode("utf-8")
|
||||
req = urllib.request.Request(
|
||||
url,
|
||||
data=data,
|
||||
headers={"Content-Type": "application/json"},
|
||||
method="POST"
|
||||
)
|
||||
|
||||
try:
|
||||
with urllib.request.urlopen(req) as response:
|
||||
resp_data = response.read().decode("utf-8")
|
||||
print("Status Code:", response.status)
|
||||
print("Response:", resp_data)
|
||||
except Exception as e:
|
||||
print("Fehler beim Senden der Request:", e)
|
||||
|
||||
|
@@ -12,7 +12,7 @@ using Watcher.ViewModels;
|
||||
|
||||
namespace Watcher.Controllers;
|
||||
|
||||
public class RegistrationDto
|
||||
public class HardwareDto
|
||||
{
|
||||
// Server Identity
|
||||
[Required]
|
||||
@@ -101,9 +101,9 @@ public class MonitoringController : Controller
|
||||
}
|
||||
|
||||
|
||||
// Endpoint, an dem sich neue Agents registrieren
|
||||
[HttpPost("register-agent-by-id")]
|
||||
public async Task<IActionResult> Register([FromBody] RegistrationDto dto)
|
||||
// Endpoint, an den der Agent seine Hardwareinformationen schickt
|
||||
[HttpPost("hardware-info")]
|
||||
public async Task<IActionResult> Register([FromBody] HardwareDto dto)
|
||||
{
|
||||
// Gültigkeit des Payloads prüfen
|
||||
if (!ModelState.IsValid)
|
||||
@@ -140,7 +140,8 @@ public class MonitoringController : Controller
|
||||
return NotFound("No Matching Server found.");
|
||||
}
|
||||
|
||||
[HttpGet("server-id-by-ip")]
|
||||
// Endpoint, an dem sich ein Agent initial registriert
|
||||
[HttpGet("register")]
|
||||
public async Task<IActionResult> GetServerIdByIp([FromQuery] string IpAddress)
|
||||
{
|
||||
var server = await _context.Servers
|
||||
@@ -252,6 +253,8 @@ public class MonitoringController : Controller
|
||||
Name = dto.Name
|
||||
};
|
||||
|
||||
_logger.LogInformation(container.Name + " added for Host " + container.ServerId);
|
||||
|
||||
_context.Containers.Add(container);
|
||||
await _context.SaveChangesAsync();
|
||||
}
|
||||
|
Reference in New Issue
Block a user