Compare commits
3 Commits
2026.02.21
...
2026.02.21
| Author | SHA1 | Date | |
|---|---|---|---|
| 2f1a200bdc | |||
| dfa8dc079b | |||
| 321e53be5b |
45
.gitea/workflows/build.yaml
Normal file
45
.gitea/workflows/build.yaml
Normal file
@@ -0,0 +1,45 @@
|
||||
name: Build on push
|
||||
run-name: Build on push
|
||||
on:
|
||||
push:
|
||||
branches:
|
||||
- master
|
||||
|
||||
jobs:
|
||||
prepare:
|
||||
runs-on: [runner]
|
||||
container: git.sh-edraft.de/sh-edraft.de/act-runner:latest
|
||||
steps:
|
||||
- uses: https://git.sh-edraft.de/sh-edraft.de/actions/set-version@master
|
||||
env:
|
||||
CI_ACCESS_TOKEN: ${{ secrets.CI_ACCESS_TOKEN }}
|
||||
|
||||
build:
|
||||
runs-on: [runner]
|
||||
needs: prepare
|
||||
container: git.sh-edraft.de/sh-edraft.de/act-runner:latest
|
||||
steps:
|
||||
- name: Clone Repository
|
||||
uses: https://github.com/actions/checkout@v3
|
||||
with:
|
||||
token: ${{ secrets.CI_ACCESS_TOKEN }}
|
||||
|
||||
- name: Download build version artifact
|
||||
uses: actions/download-artifact@v3
|
||||
with:
|
||||
name: version
|
||||
|
||||
- name: Build single file executables
|
||||
run: |
|
||||
cd sh.actions.package-cleanup
|
||||
|
||||
# Build for Linux x64
|
||||
dotnet publish -c Release -r linux-x64 -p:Version=$(cat ../version.txt) -o publish/linux-x64
|
||||
|
||||
- name: Upload to Gitea Generic Package Registry
|
||||
run: |
|
||||
cd sh.actions.package-cleanup
|
||||
curl -X PUT \
|
||||
-H "Authorization: token ${{ secrets.CI_ACCESS_TOKEN }}" \
|
||||
-T publish/linux-x64/sh.actions.package-cleanup \
|
||||
"https://git.sh-edraft.de/api/packages/sh-edraft.de/generic/package-cleanup/$(cat ../version.txt)/package-cleanup-linux-x64"
|
||||
@@ -1,5 +1,6 @@
|
||||
namespace sh.actions.package_cleanup.Service;
|
||||
|
||||
using System;
|
||||
using System.Net.Http.Json;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using sh.actions.package_cleanup.Models;
|
||||
@@ -10,8 +11,10 @@ public class GiteaPackageService(
|
||||
HttpClient httpClient)
|
||||
: IGiteaPackageService
|
||||
{
|
||||
private static string EncodePathSegment(string? s) => Uri.EscapeDataString((s ?? string.Empty));
|
||||
|
||||
private string GetBaseUrl() =>
|
||||
$"{configuration["URL"]?.TrimEnd('/')}/packages/{configuration["OWNER"]}";
|
||||
$"{configuration["URL"]?.TrimEnd('/')}/packages/{EncodePathSegment(configuration["OWNER"]) }";
|
||||
|
||||
private void AddAuthorizationHeader(HttpRequestMessage request)
|
||||
{
|
||||
@@ -45,7 +48,10 @@ public class GiteaPackageService(
|
||||
|
||||
while (true)
|
||||
{
|
||||
var url = $"{baseUrl}/{type}/{name}?page={page}";
|
||||
var encodedType = EncodePathSegment(type);
|
||||
var encodedName = EncodePathSegment(name);
|
||||
|
||||
var url = $"{baseUrl}/{encodedType}/{encodedName}?page={page}";
|
||||
logger.LogInformation("Fetching packages from Gitea: {Url}", url);
|
||||
|
||||
var request = new HttpRequestMessage(HttpMethod.Get, url);
|
||||
@@ -126,7 +132,11 @@ public class GiteaPackageService(
|
||||
try
|
||||
{
|
||||
var baseUrl = GetBaseUrl();
|
||||
var url = $"{baseUrl}/{package.Type}/{package.Name}/{package.Version}";
|
||||
var encodedType = EncodePathSegment(package.Type);
|
||||
var encodedName = EncodePathSegment(package.Name);
|
||||
var encodedVersion = EncodePathSegment(package.Version);
|
||||
|
||||
var url = $"{baseUrl}/{encodedType}/{encodedName}/{encodedVersion}";
|
||||
logger.LogInformation("Deleting package {PackageName} (ID: {PackageId}) from Gitea",
|
||||
package.Name, package.Id);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user