Compare commits
3 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 76628a118c | |||
| 364cc7df48 | |||
| f824789bbb |
20
Dockerfile
20
Dockerfile
@@ -17,10 +17,26 @@ RUN dotnet publish ServiceUpdater.csproj \
|
|||||||
|
|
||||||
FROM debian:bookworm-slim AS final
|
FROM debian:bookworm-slim AS final
|
||||||
WORKDIR /app
|
WORKDIR /app
|
||||||
RUN apt-get update && apt-get install -y --no-install-recommends \
|
RUN apt update && apt install --yes --no-install-recommends \
|
||||||
docker.io \
|
curl \
|
||||||
|
ca-certificates \
|
||||||
|
gnupg \
|
||||||
|
unzip \
|
||||||
|
dumb-init \
|
||||||
|
&& install -m 0755 -d /etc/apt/keyrings \
|
||||||
|
&& curl -fsSL https://download.docker.com/linux/debian/gpg | gpg --dearmor -o /etc/apt/keyrings/docker.gpg \
|
||||||
|
&& chmod a+r /etc/apt/keyrings/docker.gpg \
|
||||||
|
&& echo \
|
||||||
|
"deb [arch="$(dpkg --print-architecture)" signed-by=/etc/apt/keyrings/docker.gpg] https://download.docker.com/linux/debian \
|
||||||
|
"$(. /etc/os-release && echo "$VERSION_CODENAME")" stable" | \
|
||||||
|
tee /etc/apt/sources.list.d/docker.list > /dev/null \
|
||||||
|
&& apt update \
|
||||||
|
&& apt --yes --no-install-recommends install \
|
||||||
|
docker-ce-cli \
|
||||||
|
docker-compose-plugin \
|
||||||
&& rm -rf /var/lib/apt/lists/*
|
&& rm -rf /var/lib/apt/lists/*
|
||||||
COPY --from=build /app/publish/ServiceUpdater /app
|
COPY --from=build /app/publish/ServiceUpdater /app
|
||||||
COPY --from=build /app/publish/appsettings.json /app
|
COPY --from=build /app/publish/appsettings.json /app
|
||||||
RUN chmod +x /app/ServiceUpdater
|
RUN chmod +x /app/ServiceUpdater
|
||||||
|
ENV ASPNETCORE_URLS="http://0.0.0.0:5000"
|
||||||
ENTRYPOINT ["/app/ServiceUpdater"]
|
ENTRYPOINT ["/app/ServiceUpdater"]
|
||||||
|
|||||||
12
README.md
Normal file
12
README.md
Normal 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 }}
|
||||||
|
```
|
||||||
@@ -3,6 +3,9 @@
|
|||||||
namespace ServiceUpdater;
|
namespace ServiceUpdater;
|
||||||
|
|
||||||
public sealed class UpdateWorker(UpdaterConfig config) {
|
public sealed class UpdateWorker(UpdaterConfig config) {
|
||||||
|
|
||||||
|
private int LastExitCode { get; set; }
|
||||||
|
|
||||||
public async IAsyncEnumerable<string> UpdateService(string serviceName) {
|
public async IAsyncEnumerable<string> UpdateService(string serviceName) {
|
||||||
yield return $"Starting update for {serviceName}";
|
yield return $"Starting update for {serviceName}";
|
||||||
|
|
||||||
@@ -10,13 +13,14 @@ public sealed class UpdateWorker(UpdaterConfig config) {
|
|||||||
yield return line;
|
yield return line;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (LastExitCode != 0)
|
||||||
|
yield break;
|
||||||
|
|
||||||
yield return $"Downloaded changes for {serviceName}";
|
yield return $"Downloaded changes for {serviceName}";
|
||||||
|
|
||||||
await foreach (var line in RunProcess(serviceName, "compose up -d --remove-orphans")) {
|
await foreach (var line in RunProcess(serviceName, "compose up -d --remove-orphans")) {
|
||||||
yield return line;
|
yield return line;
|
||||||
}
|
}
|
||||||
|
|
||||||
yield return $"Successfully updated {serviceName}";
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private async IAsyncEnumerable<string> RunProcess(string folder, string arguments) {
|
private async IAsyncEnumerable<string> RunProcess(string folder, string arguments) {
|
||||||
@@ -48,11 +52,12 @@ public sealed class UpdateWorker(UpdaterConfig config) {
|
|||||||
else {
|
else {
|
||||||
var line = await error;
|
var line = await error;
|
||||||
if (line == null) break;
|
if (line == null) break;
|
||||||
yield return "[ERR] " + line;
|
yield return line;
|
||||||
error = process.StandardError.ReadLineAsync();
|
error = process.StandardError.ReadLineAsync();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
await process.WaitForExitAsync();
|
await process.WaitForExitAsync();
|
||||||
|
LastExitCode = process.ExitCode;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
16
action.yml
Normal file
16
action.yml
Normal file
@@ -0,0 +1,16 @@
|
|||||||
|
name: "Call Service Updater"
|
||||||
|
description: "Triggers the internal updater service via HTTP"
|
||||||
|
author: "Leon Hoppe"
|
||||||
|
|
||||||
|
inputs:
|
||||||
|
service:
|
||||||
|
description: "Name of the service to update"
|
||||||
|
required: true
|
||||||
|
|
||||||
|
runs:
|
||||||
|
using: "composite"
|
||||||
|
steps:
|
||||||
|
- name: Call updater
|
||||||
|
shell: sh
|
||||||
|
run: |
|
||||||
|
curl -N "http://updater:5000/update/${{ inputs.service }}"
|
||||||
Reference in New Issue
Block a user