Files
Duy Dao 1ab09d4344
All checks were successful
Caddy Manager CI build / docker (push) Successful in 1m35s
chore: implement retry mechanism for container publishing in CI workflow
2025-07-28 23:08:39 +07:00

59 lines
2.3 KiB
YAML

name: Caddy Manager CI build
run-name: ${{ gitea.actor }} is running CI pipeline
on:
push:
branches:
- main
jobs:
docker:
env:
RUNNER_TOOL_CACHE: /toolcache
NUGET_PACKAGES: ${{ gitea.workspace }}/.nuget/packages
runs-on: ubuntu-latest
steps:
-
name: Login to Gitea
uses: docker/login-action@v3
with:
registry: http://${{ vars.DOCKER_GITEA_DOMAIN }}
username: ${{ vars.DOCKER_GITEA_USERNAME }}
password: ${{ secrets.DOCKER_GITEA_PAT }}
config-inline: |
[registry."${{ vars.DOCKER_GITEA_DOMAIN }}"]
http = true
insecure = true
- uses: actions/checkout@v4
- uses: actions/setup-dotnet@v3
with:
dotnet-version: '9' # SDK Version to use.
dotnet-quality: 'ga'
cache: true
cache-dependency-path: '**/packages.lock.json'
- name: Restore dependencies
run: dotnet restore --locked-mode
- name: Application metadata
id: metadata
run: |
echo "COMMIT_HASH=$(git rev-parse --short HEAD)" >> $GITHUB_OUTPUT
echo "APP_VERSION=$(grep 'public static readonly string Version' CaddyManager/Configurations/Application/ApplicationInfo.cs | sed -E 's/.*"([^"]+)".*/\1/')" >> $GITHUB_OUTPUT
- name: Patch application info
run: |
sed -i "s/public static readonly string CommitHash = \"\[DEVELOPMENT\]\";/public static readonly string CommitHash = \"${{ steps.metadata.outputs.COMMIT_HASH }}\";/" CaddyManager/Configurations/Application/ApplicationInfo.cs
- name: Publish container
uses: nick-fields/retry@v3
with:
timeout_minutes: 10
max_attempts: 3
command: |
dotnet publish \
--configuration Release --os linux --arch x64 \
/t:PublishContainer -p ContainerRegistry=${{ vars.DOCKER_GITEA_DOMAIN }} \
-p ContainerRepository=ebolo/caddy-manager -p:ContainerImageTags='"${{ steps.metadata.outputs.APP_VERSION }};latest"'
- name: Deploy to Komodo
uses: fjogeleit/http-request-action@v1
if: success()
with:
url: '${{ vars.WINDMILL_DOMAIN }}/komodo/pull-stack/${{ secrets.KOMODO_STACK_ID }}'
method: 'PUT'
customHeaders: '{"Auth-Key": "${{ secrets.WINDMILL_KEY }}"}'