2 Commits
v1.0.1 ... main

Author SHA1 Message Date
76628a118c Added readme 2026-02-25 12:23:29 +01:00
364cc7df48 Added error handling
All checks were successful
Updater CI/CD / publish (push) Successful in 48s
2026-02-24 19:31:15 +01:00
2 changed files with 20 additions and 3 deletions

12
README.md Normal file
View File

@@ -0,0 +1,12 @@
To use the service in your ci, add the following Task:
```yaml
deploy:
runs-on: ubuntu-latest
if: startsWith(github.ref, 'refs/tags/')
needs: publish
steps:
- name: Run updater action
uses: https://git.leon-hoppe.de/leon.hoppe/ServiceUpdater@main
with:
service: ${{ inputs.service }}
```

View File

@@ -3,6 +3,9 @@
namespace ServiceUpdater;
public sealed class UpdateWorker(UpdaterConfig config) {
private int LastExitCode { get; set; }
public async IAsyncEnumerable<string> UpdateService(string serviceName) {
yield return $"Starting update for {serviceName}";
@@ -10,13 +13,14 @@ public sealed class UpdateWorker(UpdaterConfig config) {
yield return line;
}
if (LastExitCode != 0)
yield break;
yield return $"Downloaded changes for {serviceName}";
await foreach (var line in RunProcess(serviceName, "compose up -d --remove-orphans")) {
yield return line;
}
yield return $"Successfully updated {serviceName}";
}
private async IAsyncEnumerable<string> RunProcess(string folder, string arguments) {
@@ -48,11 +52,12 @@ public sealed class UpdateWorker(UpdaterConfig config) {
else {
var line = await error;
if (line == null) break;
yield return "[ERR] " + line;
yield return line;
error = process.StandardError.ReadLineAsync();
}
}
await process.WaitForExitAsync();
LastExitCode = process.ExitCode;
}
}