Skip to content

Commit 5f189c2

Browse files
OgeonX-Airoot
andauthored
fix(health): separate monitored runner identity (#2269)
* fix(health): separate monitored runner identity * fix(health): align runner email alerts --------- Co-authored-by: root <root@Kimi.localdomain>
1 parent 2090ce0 commit 5f189c2

3 files changed

Lines changed: 25 additions & 6 deletions

File tree

.github/workflows/runner-health.yml

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -16,15 +16,15 @@ jobs:
1616
timeout-minutes: 15
1717
env:
1818
GH_TOKEN: ${{ secrets.RUNNER_PAT || github.token }}
19-
RUNNER_NAME: MyLocalPC
19+
MONITORED_RUNNER_NAME: CAS-Workstation-Kim
2020
EMAIL_TO: ${{ secrets.EMAIL_TO }}
2121
steps:
2222
- name: Check runner status
2323
id: status
2424
run: |
2525
set -euo pipefail
2626
status=""
27-
if ! status="$(gh api repos/${GITHUB_REPOSITORY}/actions/runners --jq ".runners[] | select(.name==\"${RUNNER_NAME}\") | .status")"; then
27+
if ! status="$(gh api repos/${GITHUB_REPOSITORY}/actions/runners --jq ".runners[] | select(.name==\"${MONITORED_RUNNER_NAME}\") | .status")"; then
2828
status="unknown"
2929
fi
3030
if [ -z "${status}" ]; then
@@ -36,15 +36,15 @@ jobs:
3636
if: steps.status.outputs.runner_status != 'online'
3737
run: |
3838
set -euo pipefail
39-
title="Runner offline: ${RUNNER_NAME}"
39+
title="Runner offline: ${MONITORED_RUNNER_NAME}"
4040
marker="Autopilot Runner Health"
4141
status="${{ steps.status.outputs.runner_status }}"
4242
gh label create runner-offline --color "B60205" --description "Runner offline alerts" --force --repo "${GITHUB_REPOSITORY}" || true
4343
existing="$(gh issue list -s open -l runner-offline -S "${title}" --repo "${GITHUB_REPOSITORY}" --json number --jq '.[0].number')"
4444
body=$(cat <<EOF
4545
${marker}
4646
47-
Runner: ${RUNNER_NAME}
47+
Runner: ${MONITORED_RUNNER_NAME}
4848
Status: ${status}
4949
Repo: ${GITHUB_REPOSITORY}
5050
Time: $(date -u +"%Y-%m-%dT%H:%M:%SZ")
@@ -76,9 +76,9 @@ jobs:
7676
server_port: ${{ env.SMTP_PORT }}
7777
username: ${{ env.SMTP_USERNAME }}
7878
password: ${{ env.SMTP_PASSWORD }}
79-
subject: "Runner offline: MyLocalPC"
79+
subject: "Runner offline: ${{ env.MONITORED_RUNNER_NAME }}"
8080
body: |
81-
Runner: MyLocalPC
81+
Runner: ${{ env.MONITORED_RUNNER_NAME }}
8282
Repo: ${{ github.repository }}
8383
Status: ${{ steps.status.outputs.runner_status }}
8484
to: ${{ env.EMAIL_TO }}
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
# Runner health target variable
2+
3+
Issue Description: Runner Health Monitor created alerts for its GitHub-hosted monitor instead of the intended self-hosted runner.
4+
State: The workflow defined `RUNNER_NAME`, which GitHub Actions reserves for the executing runner and overwrote at runtime.
5+
Action: Renamed the target variable to `MONITORED_RUNNER_NAME` and added a regression test for the workflow contract.
6+
Result: Health checks now query and report the configured self-hosted runner name.
7+
Diff Patch: Updated `.github/workflows/runner-health.yml` and added `tests/test_runner_health_workflow.py`.
8+
Rationale: Workflow environment variables must not collide with GitHub Actions built-ins.
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
from pathlib import Path
2+
3+
4+
def test_runner_health_uses_non_reserved_target_name() -> None:
5+
workflow = Path(".github/workflows/runner-health.yml").read_text(encoding="utf-8")
6+
7+
assert "MONITORED_RUNNER_NAME: CAS-Workstation-Kim" in workflow
8+
assert "${MONITORED_RUNNER_NAME}" in workflow
9+
assert "RUNNER_NAME: MyLocalPC" not in workflow
10+
assert 'subject: "Runner offline: ${{ env.MONITORED_RUNNER_NAME }}"' in workflow
11+
assert "Runner: ${{ env.MONITORED_RUNNER_NAME }}" in workflow

0 commit comments

Comments
 (0)