Compare commits
12 Commits
9a59e10b0c
...
v0.1.5
Author | SHA1 | Date | |
---|---|---|---|
ab11665665 | |||
37468b6785 | |||
471767c4ed | |||
596baba5ef | |||
12390031f9 | |||
daed8c1462 | |||
7e5e295590 | |||
cb91ca3159 | |||
340f92ed04 | |||
2169b3d45f | |||
27792ff7f4 | |||
2334287437 |
@@ -5,21 +5,22 @@ on:
|
|||||||
push:
|
push:
|
||||||
branches: [ "development", "main", "staging"]
|
branches: [ "development", "main", "staging"]
|
||||||
tags: [ "v*.*.*" ]
|
tags: [ "v*.*.*" ]
|
||||||
pull_request:
|
#pull_request:
|
||||||
branches: [ "development", "main", "staging" ]
|
#branches: [ "development", "main", "staging" ]
|
||||||
|
|
||||||
|
permissions:
|
||||||
|
contents: write
|
||||||
|
packages: write
|
||||||
|
|
||||||
env:
|
env:
|
||||||
DOTNET_VERSION: '8.0.x'
|
DOTNET_VERSION: '8.0.x'
|
||||||
DOCKER_IMAGE_NAME: watcher-server
|
DOCKER_IMAGE_NAME: watcher-server
|
||||||
REGISTRY_URL: git.triggermeelmo.com
|
REGISTRY_URL: git.triggermeelmo.com
|
||||||
DOCKER_PLATFORMS: 'linux/amd64,linux/arm64'
|
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' }}
|
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
build-and-test:
|
build-and-test:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
env:
|
|
||||||
RUNNER_TOOL_CACHE: /toolcache # Runner Tool Cache
|
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout code
|
- name: Checkout code
|
||||||
uses: actions/checkout@v4
|
uses: actions/checkout@v4
|
||||||
@@ -45,12 +46,12 @@ jobs:
|
|||||||
set-tag:
|
set-tag:
|
||||||
name: Set Tag Name
|
name: Set Tag Name
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
env:
|
|
||||||
RUNNER_TOOL_CACHE: /toolcache
|
|
||||||
outputs:
|
outputs:
|
||||||
tag_name: ${{ steps.set_tag.outputs.tag_name }}
|
tag_name: ${{ steps.set_tag.outputs.tag_name }}
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v4
|
- uses: actions/checkout@v4
|
||||||
|
with:
|
||||||
|
fetch-depth: 0
|
||||||
|
|
||||||
- name: Determine next semantic version tag
|
- name: Determine next semantic version tag
|
||||||
id: set_tag
|
id: set_tag
|
||||||
@@ -75,17 +76,16 @@ jobs:
|
|||||||
elif [[ "${GITHUB_REF}" == "refs/heads/development" ]]; then
|
elif [[ "${GITHUB_REF}" == "refs/heads/development" ]]; then
|
||||||
minor=$((minor + 1))
|
minor=$((minor + 1))
|
||||||
patch=0
|
patch=0
|
||||||
else
|
elif [[ "${GITHUB_REF}" == "refs/heads/staging" ]]; then
|
||||||
patch=$((patch + 1))
|
patch=$((patch + 1))
|
||||||
fi
|
fi
|
||||||
|
|
||||||
new_tag="v${major}.${minor}.${patch}"
|
new_tag="v${major}.${minor}.${patch}"
|
||||||
|
echo "Creating new version tag: ${new_tag}"
|
||||||
echo "tag_name=${new_tag}" >> $GITHUB_OUTPUT
|
echo "tag_name=${new_tag}" >> $GITHUB_OUTPUT
|
||||||
|
|
||||||
docker-build-and-push:
|
docker-build-and-push:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
env:
|
|
||||||
RUNNER_TOOL_CACHE: /toolcache # Runner Tool Cache
|
|
||||||
needs: [build-and-test, set-tag]
|
needs: [build-and-test, set-tag]
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout code
|
- name: Checkout code
|
||||||
@@ -112,21 +112,35 @@ jobs:
|
|||||||
name: Create Tag
|
name: Create Tag
|
||||||
needs: [docker-build-and-push]
|
needs: [docker-build-and-push]
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
env:
|
|
||||||
RUNNER_TOOL_CACHE: /toolcache
|
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v4
|
- uses: actions/checkout@v4
|
||||||
with:
|
with:
|
||||||
fetch-depth: 0
|
fetch-depth: 0
|
||||||
|
token: ${{ secrets.GITHUB_TOKEN }}
|
||||||
|
|
||||||
- name: Set up Git user
|
- name: Check if tag already exists
|
||||||
|
id: check_tag
|
||||||
run: |
|
run: |
|
||||||
git config user.name "GitHub Actions"
|
git fetch --tags
|
||||||
git config user.email "actions@github.com"
|
if git rev-parse "${{ needs.set-tag.outputs.tag_name }}" >/dev/null 2>&1; then
|
||||||
|
echo "Tag ${{ needs.set-tag.outputs.tag_name }} already exists!"
|
||||||
|
echo "exists=true" >> $GITHUB_OUTPUT
|
||||||
|
else
|
||||||
|
echo "Tag ${{ needs.set-tag.outputs.tag_name }} does not exist"
|
||||||
|
echo "exists=false" >> $GITHUB_OUTPUT
|
||||||
|
fi
|
||||||
|
|
||||||
- name: Create and push tag
|
- name: Create and push tag
|
||||||
env:
|
if: steps.check_tag.outputs.exists == 'false'
|
||||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
|
||||||
run: |
|
run: |
|
||||||
|
echo "Creating new tag: ${{ needs.set-tag.outputs.tag_name }}"
|
||||||
|
git config user.name "GitHub Actions"
|
||||||
|
git config user.email "actions@github.com"
|
||||||
git tag ${{ needs.set-tag.outputs.tag_name }}
|
git tag ${{ needs.set-tag.outputs.tag_name }}
|
||||||
git push origin ${{ needs.set-tag.outputs.tag_name }}
|
git push origin ${{ needs.set-tag.outputs.tag_name }}
|
||||||
|
echo "Tag created and pushed successfully"
|
||||||
|
|
||||||
|
- name: Skip tag creation
|
||||||
|
if: steps.check_tag.outputs.exists == 'true'
|
||||||
|
run: |
|
||||||
|
echo "Skipping tag creation - ${{ needs.set-tag.outputs.tag_name }} already exists"
|
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;
|
namespace Watcher.Controllers;
|
||||||
|
|
||||||
public class RegistrationDto
|
public class HardwareDto
|
||||||
{
|
{
|
||||||
// Server Identity
|
// Server Identity
|
||||||
[Required]
|
[Required]
|
||||||
@@ -101,9 +101,9 @@ public class MonitoringController : Controller
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// Endpoint, an dem sich neue Agents registrieren
|
// Endpoint, an den der Agent seine Hardwareinformationen schickt
|
||||||
[HttpPost("register-agent-by-id")]
|
[HttpPost("hardware-info")]
|
||||||
public async Task<IActionResult> Register([FromBody] RegistrationDto dto)
|
public async Task<IActionResult> Register([FromBody] HardwareDto dto)
|
||||||
{
|
{
|
||||||
// Gültigkeit des Payloads prüfen
|
// Gültigkeit des Payloads prüfen
|
||||||
if (!ModelState.IsValid)
|
if (!ModelState.IsValid)
|
||||||
@@ -140,7 +140,8 @@ public class MonitoringController : Controller
|
|||||||
return NotFound("No Matching Server found.");
|
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)
|
public async Task<IActionResult> GetServerIdByIp([FromQuery] string IpAddress)
|
||||||
{
|
{
|
||||||
var server = await _context.Servers
|
var server = await _context.Servers
|
||||||
@@ -252,6 +253,8 @@ public class MonitoringController : Controller
|
|||||||
Name = dto.Name
|
Name = dto.Name
|
||||||
};
|
};
|
||||||
|
|
||||||
|
_logger.LogInformation(container.Name + " added for Host " + container.ServerId);
|
||||||
|
|
||||||
_context.Containers.Add(container);
|
_context.Containers.Add(container);
|
||||||
await _context.SaveChangesAsync();
|
await _context.SaveChangesAsync();
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user