12 Commits

Author SHA1 Message Date
ab11665665 dani des is men push vorm pennen gehen
Some checks failed
Gitea CI/CD / Set Tag Name (push) Successful in 6s
Gitea CI/CD / build-and-test (push) Successful in 48s
Gitea CI/CD / Create Tag (push) Has been cancelled
Gitea CI/CD / docker-build-and-push (push) Has been cancelled
2025-10-04 02:06:22 +02:00
37468b6785 added version tag output
All checks were successful
Gitea CI/CD / Set Tag Name (push) Successful in 5s
Gitea CI/CD / build-and-test (push) Successful in 45s
Gitea CI/CD / docker-build-and-push (push) Successful in 5m57s
Gitea CI/CD / Create Tag (push) Successful in 5s
2025-10-04 01:51:56 +02:00
471767c4ed added farther checking for existing tags 2025-10-04 01:43:57 +02:00
596baba5ef added permissions for packages and moved token to actions checkout
All checks were successful
Gitea CI/CD / Set Tag Name (push) Successful in 5s
Gitea CI/CD / build-and-test (push) Successful in 44s
Gitea CI/CD / docker-build-and-push (push) Successful in 5m39s
Gitea CI/CD / Create Tag (push) Successful in 5s
2025-10-04 01:41:06 +02:00
12390031f9 added permissions to write
All checks were successful
Gitea CI/CD / Set Tag Name (push) Successful in 5s
Gitea CI/CD / build-and-test (push) Successful in 52s
Gitea CI/CD / docker-build-and-push (push) Successful in 7m29s
Gitea CI/CD / Create Tag (push) Successful in 7s
2025-10-04 01:15:16 +02:00
daed8c1462 .gitea/workflows/build.yaml aktualisiert
Some checks failed
Gitea CI/CD / Set Tag Name (push) Successful in 5s
Gitea CI/CD / docker-build-and-push (push) Has been cancelled
Gitea CI/CD / Create Tag (push) Has been cancelled
Gitea CI/CD / build-and-test (push) Has been cancelled
2025-10-04 00:52:35 +02:00
7e5e295590 .gitea/workflows/build.yaml aktualisiert
Some checks failed
Gitea CI/CD / Set Tag Name (push) Successful in 6s
Gitea CI/CD / build-and-test (push) Successful in 51s
Gitea CI/CD / Create Tag (push) Has been cancelled
Gitea CI/CD / docker-build-and-push (push) Has been cancelled
2025-10-04 00:34:47 +02:00
cb91ca3159 .gitea/workflows/build.yaml aktualisiert
All checks were successful
Gitea CI/CD / build-and-test (push) Successful in 1m5s
Gitea CI/CD / Set Tag Name (push) Successful in 7s
Gitea CI/CD / docker-build-and-push (push) Successful in 5m56s
Gitea CI/CD / Create Tag (push) Successful in 5s
2025-10-04 00:20:55 +02:00
340f92ed04 Merge pull request 'feature/service-detection' (#23) from feature/service-detection into staging
Some checks failed
Gitea CI/CD / Set Tag Name (push) Successful in 6s
Gitea CI/CD / build-and-test (push) Successful in 48s
Gitea CI/CD / Create Tag (push) Has been cancelled
Gitea CI/CD / docker-build-and-push (push) Has been cancelled
Reviewed-on: #23
2025-10-03 23:55:46 +02:00
2169b3d45f Changed Endpoint Names
Some checks failed
Gitea CI/CD / Set Tag Name (pull_request) Successful in 6s
Gitea CI/CD / build-and-test (pull_request) Successful in 1m7s
Gitea CI/CD / docker-build-and-push (pull_request) Successful in 8m59s
Gitea CI/CD / Create Tag (pull_request) Failing after 7s
2025-10-03 23:54:35 +02:00
27792ff7f4 Test und Log 2025-10-03 17:17:28 +02:00
2334287437 Merge pull request 'enhancement/pipeline-upgrade' (#22) from enhancement/pipeline-upgrade into staging
All checks were successful
Gitea CI/CD / Set Tag Name (push) Successful in 5s
Gitea CI/CD / build-and-test (push) Successful in 1m1s
Gitea CI/CD / docker-build-and-push (push) Successful in 9m13s
Gitea CI/CD / Create Tag (push) Successful in 6s
Reviewed-on: #22
2025-10-03 14:49:17 +02:00
3 changed files with 68 additions and 23 deletions

View File

@@ -5,21 +5,22 @@ on:
push:
branches: [ "development", "main", "staging"]
tags: [ "v*.*.*" ]
pull_request:
branches: [ "development", "main", "staging" ]
#pull_request:
#branches: [ "development", "main", "staging" ]
permissions:
contents: write
packages: write
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' }}
jobs:
build-and-test:
runs-on: ubuntu-latest
env:
RUNNER_TOOL_CACHE: /toolcache # Runner Tool Cache
steps:
- name: Checkout code
uses: actions/checkout@v4
@@ -45,12 +46,12 @@ jobs:
set-tag:
name: Set Tag Name
runs-on: ubuntu-latest
env:
RUNNER_TOOL_CACHE: /toolcache
outputs:
tag_name: ${{ steps.set_tag.outputs.tag_name }}
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Determine next semantic version tag
id: set_tag
@@ -75,17 +76,16 @@ jobs:
elif [[ "${GITHUB_REF}" == "refs/heads/development" ]]; then
minor=$((minor + 1))
patch=0
else
elif [[ "${GITHUB_REF}" == "refs/heads/staging" ]]; then
patch=$((patch + 1))
fi
new_tag="v${major}.${minor}.${patch}"
echo "Creating new version tag: ${new_tag}"
echo "tag_name=${new_tag}" >> $GITHUB_OUTPUT
docker-build-and-push:
runs-on: ubuntu-latest
env:
RUNNER_TOOL_CACHE: /toolcache # Runner Tool Cache
needs: [build-and-test, set-tag]
steps:
- name: Checkout code
@@ -112,21 +112,35 @@ jobs:
name: Create Tag
needs: [docker-build-and-push]
runs-on: ubuntu-latest
env:
RUNNER_TOOL_CACHE: /toolcache
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
token: ${{ secrets.GITHUB_TOKEN }}
- name: Set up Git user
- name: Check if tag already exists
id: check_tag
run: |
git config user.name "GitHub Actions"
git config user.email "actions@github.com"
git fetch --tags
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
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
if: steps.check_tag.outputs.exists == 'false'
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 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
View 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)

View File

@@ -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();
}