Skip to content

Commit 7346552

Browse files
fix(ci): composite action cannot read github/secrets/job — caller passes them as inputs
The nr-ci-event composite action referenced github.*/secrets.*/job.status in its own env: block; GitHub rejects those contexts inside a composite action (TemplateValidationException 'Unrecognized named-value'). Move all resolution to the caller's with: block (which CAN read those contexts) and have the action read only inputs.*. Adds event-name + actor inputs. Callers now pass repo/workflow/ branch/commit-sha/log-url/event-name/actor from the github context. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
1 parent aa9114c commit 7346552

4 files changed

Lines changed: 52 additions & 17 deletions

File tree

.github/actions/nr-ci-event/action.yml

Lines changed: 31 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -45,24 +45,28 @@ inputs:
4545
Logical suite name, e.g. build-and-test, coverage, playwright, pr-smoke,
4646
e2e-prod, deploy-gate. The dashboard FACETs on this.
4747
required: true
48+
# NOTE: composite actions cannot read the `github` context in their own
49+
# expressions, so the caller MUST pass these from its `with:` block (e.g.
50+
# repo: ${{ github.repository }}). The defaults below only apply when a caller
51+
# omits them entirely.
4852
repo:
49-
description: 'Repository (owner/name). Default ${{ github.repository }}.'
53+
description: 'Repository (owner/name). Caller passes ${{ github.repository }}.'
5054
required: false
5155
default: ''
5256
workflow:
53-
description: 'Workflow name. Default ${{ github.workflow }}.'
57+
description: 'Workflow name. Caller passes ${{ github.workflow }}.'
5458
required: false
5559
default: ''
5660
branch:
57-
description: 'Branch ref name. Default ${{ github.ref_name }}.'
61+
description: 'Branch ref name. Caller passes ${{ github.ref_name }}.'
5862
required: false
5963
default: ''
6064
commit-sha:
61-
description: 'Commit SHA under test. Default ${{ github.sha }}.'
65+
description: 'Commit SHA under test. Caller passes ${{ github.sha }}.'
6266
required: false
6367
default: ''
6468
pr-number:
65-
description: 'PR number (empty on push). Default ${{ github.event.pull_request.number }}.'
69+
description: 'PR number (empty on push). Caller passes ${{ github.event.pull_request.number }}.'
6670
required: false
6771
default: ''
6872
duration-ms:
@@ -74,8 +78,15 @@ inputs:
7478
required: false
7579
default: ''
7680
log-url:
77-
description: >-
78-
URL to the run logs for triage. Default the run's GitHub Actions URL.
81+
description: 'URL to the run logs for triage. Caller passes the run URL.'
82+
required: false
83+
default: ''
84+
event-name:
85+
description: 'GitHub event name. Caller passes ${{ github.event_name }}.'
86+
required: false
87+
default: ''
88+
actor:
89+
description: 'GitHub actor. Caller passes ${{ github.actor }}.'
7990
required: false
8091
default: ''
8192

@@ -85,24 +96,27 @@ runs:
8596
- name: Emit CI result to New Relic (no-op without secret)
8697
shell: bash
8798
env:
88-
# All untrusted/free-form values flow through env, never interpolated
89-
# into the shell body — same injection-safe posture as ci.yml's
90-
# dispatch-auth-contract-e2e job.
99+
# Composite actions may reference ONLY `inputs` (+ env/runner/steps) in
100+
# their expressions — `secrets`, `job`, and `github` are NOT available
101+
# here, so the CALLER resolves those and passes them as inputs. All
102+
# untrusted/free-form values flow through env, never interpolated into
103+
# the shell body (injection-safe — same posture as ci.yml's
104+
# dispatch-auth-contract-e2e job).
91105
NR_LICENSE_KEY: ${{ inputs.license-key }}
92106
NR_ACCOUNT_ID: ${{ inputs.account-id }}
93107
NR_REGION: ${{ inputs.nr-region }}
94108
EV_RESULT: ${{ inputs.result }}
95109
EV_SUITE: ${{ inputs.suite }}
96-
EV_REPO: ${{ inputs.repo != '' && inputs.repo || github.repository }}
97-
EV_WORKFLOW: ${{ inputs.workflow != '' && inputs.workflow || github.workflow }}
98-
EV_BRANCH: ${{ inputs.branch != '' && inputs.branch || github.ref_name }}
99-
EV_COMMIT: ${{ inputs.commit-sha != '' && inputs.commit-sha || github.sha }}
110+
EV_REPO: ${{ inputs.repo }}
111+
EV_WORKFLOW: ${{ inputs.workflow }}
112+
EV_BRANCH: ${{ inputs.branch }}
113+
EV_COMMIT: ${{ inputs.commit-sha }}
100114
EV_PR: ${{ inputs.pr-number }}
101115
EV_DURATION_MS: ${{ inputs.duration-ms }}
102116
EV_FAILED_STEP: ${{ inputs.failed-step }}
103-
EV_LOG_URL: ${{ inputs.log-url != '' && inputs.log-url || format('{0}/{1}/actions/runs/{2}', github.server_url, github.repository, github.run_id) }}
104-
EV_EVENT_NAME: ${{ github.event_name }}
105-
EV_ACTOR: ${{ github.actor }}
117+
EV_LOG_URL: ${{ inputs.log-url }}
118+
EV_EVENT_NAME: ${{ inputs.event-name }}
119+
EV_ACTOR: ${{ inputs.actor }}
106120
run: |
107121
set -uo pipefail
108122

.github/workflows/ci.yml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -194,6 +194,13 @@ jobs:
194194
suite: build-and-test
195195
pr-number: ${{ github.event.pull_request.number }}
196196
failed-step: ${{ job.status != 'success' && 'go build / vet / test (-short -race -p 1)' || '' }}
197+
repo: ${{ github.repository }}
198+
workflow: ${{ github.workflow }}
199+
branch: ${{ github.ref_name }}
200+
commit-sha: ${{ github.sha }}
201+
log-url: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}
202+
event-name: ${{ github.event_name }}
203+
actor: ${{ github.actor }}
197204

198205
# E2E requires a live Kubernetes stack (see repo CLAUDE.md). This job does not
199206
# run on push/PR — only on schedule or manual dispatch — so default CI stays fast.

.github/workflows/coverage.yml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -221,3 +221,10 @@ jobs:
221221
suite: coverage
222222
pr-number: ${{ github.event.pull_request.number }}
223223
failed-step: ${{ job.status != 'success' && 'coverage gate (100% patch / 95% floor)' || '' }}
224+
repo: ${{ github.repository }}
225+
workflow: ${{ github.workflow }}
226+
branch: ${{ github.ref_name }}
227+
commit-sha: ${{ github.sha }}
228+
log-url: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}
229+
event-name: ${{ github.event_name }}
230+
actor: ${{ github.actor }}

.github/workflows/deploy.yml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -338,3 +338,10 @@ jobs:
338338
result: ${{ job.status == 'success' && 'pass' || 'fail' }}
339339
suite: deploy
340340
failed-step: ${{ job.status != 'success' && 'deploy (test gate / build / rollout / healthz SHA gate)' || '' }}
341+
repo: ${{ github.repository }}
342+
workflow: ${{ github.workflow }}
343+
branch: ${{ github.ref_name }}
344+
commit-sha: ${{ github.sha }}
345+
log-url: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}
346+
event-name: ${{ github.event_name }}
347+
actor: ${{ github.actor }}

0 commit comments

Comments
 (0)