From 62b353d5f667ec384630a35ec3f3d57845031af7 Mon Sep 17 00:00:00 2001 From: Martin Dimitrov Date: Sat, 7 Mar 2026 11:39:19 -0800 Subject: [PATCH] seperate validate runner reload --- .gitea/workflows/gitainer-deploy.yaml | 16 +++++++++++++--- .gitea/workflows/reload-act-runner.yaml | 10 ++-------- .gitea/workflows/validate-runner.yaml | 24 ++++++++++++++++++++++++ 3 files changed, 39 insertions(+), 11 deletions(-) create mode 100644 .gitea/workflows/validate-runner.yaml diff --git a/.gitea/workflows/gitainer-deploy.yaml b/.gitea/workflows/gitainer-deploy.yaml index 2ff1cd8..858f689 100644 --- a/.gitea/workflows/gitainer-deploy.yaml +++ b/.gitea/workflows/gitainer-deploy.yaml @@ -6,6 +6,11 @@ on: stack_name: required: true type: string + delayed_silent: + description: Delay the webhook call using a detached container and always succeed. Used when rebuilding the runner executing the webhook. + required: false + type: boolean + default: false jobs: deploy-gitainer: @@ -18,6 +23,11 @@ jobs: - name: Call Gitainer stack webhooks continue-on-error: true - run: curl --request POST http://192.168.1.150:9080/api/stacks/${{ inputs.stack_name }}?pretty & - with: - workflow-status: ${{ steps.check-step.outcome }} + run: | + if [ "${{ inputs.delayed_silent }}" = "true" ]; then + echo "Delaying the webhook call by 10s using a detached container." + echo "This gives the runner time to report job completion and clean up before it restarts." + docker run --rm -d alpine sh -c "apk add --no-cache curl && sleep 10 && curl --request POST 'http://192.168.1.150:9080/api/stacks/${{ inputs.stack_name }}?pretty'" + else + curl --request POST "http://192.168.1.150:9080/api/stacks/${{ inputs.stack_name }}?pretty" + fi diff --git a/.gitea/workflows/reload-act-runner.yaml b/.gitea/workflows/reload-act-runner.yaml index 3aab305..0d5f224 100644 --- a/.gitea/workflows/reload-act-runner.yaml +++ b/.gitea/workflows/reload-act-runner.yaml @@ -17,11 +17,5 @@ jobs: uses: martin/chromart-gitea-actions/.gitea/workflows/gitainer-deploy.yaml@main with: stack_name: gitea_act_runner - - notify: - needs: diff - if: ${{ needs.diff.outputs.is_changed == 'false' }} - uses: martin/chromart-gitea-actions/.gitea/workflows/apprise-notify.yaml@main - with: - title: Skipped deploy on chromart-gitea-actions - message: No changes to deploy + # use this because this action kills the runner + delayed_silent: true diff --git a/.gitea/workflows/validate-runner.yaml b/.gitea/workflows/validate-runner.yaml new file mode 100644 index 0000000..f6bc6e6 --- /dev/null +++ b/.gitea/workflows/validate-runner.yaml @@ -0,0 +1,24 @@ +name: Validate Runner Reload +on: + workflow_run: + workflows: ["Reload Act Runner Stack to clear cache for workflows"] + types: + - completed + +jobs: + validate: + runs-on: ubuntu-22.04 + steps: + - name: Wait for Gitainer to restart the runner + run: sleep 30 + + - name: Check runner age is under 2 minutes + run: | + runner_start=$(docker run --rm --pid=host alpine stat -c %Y /proc/1) + now=$(date +%s) + age_seconds=$((now - runner_start)) + echo "Runner age: $age_seconds seconds" + if [ "$age_seconds" -gt 120 ]; then + echo "Validation Failed! Runner did not restart." + exit 1 + fi