Skip to content

Commit f244ec1

Browse files
EMaherCopilot
andcommitted
refactor: remove secrets contract from called workflows, add validation step
Called workflows now access secrets via their environment declaration instead of requiring the caller to pass them. Each called workflow includes a 'Validate Required Secrets' step that fails fast with a clear error if any secret is missing from the environment. This eliminates the need for repo-level secret duplication. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
1 parent c26fb74 commit f244ec1

4 files changed

Lines changed: 29 additions & 54 deletions

File tree

.github/skills/integration-test-prerequisites/SKILL.md

Lines changed: 4 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ These workflows expect:
2121
- GitHub environment `integration-test` (shared by all integration workflows)
2222
- Azure identity with enough permissions to deploy resources and create role assignments in test resource groups
2323

24-
The `release-tests.yml` orchestrator calls `ci.yml` (no Azure prereqs), then `integration-test.yml` and `integration-redact-secrets.yml` (both use the `integration-test` environment). Secrets are passed through from the orchestrator's repo-level secrets to the called workflows' environment.
24+
The `release-tests.yml` orchestrator calls `ci.yml` (no Azure prereqs), then `integration-test.yml` and `integration-redact-secrets.yml`. The called workflows access secrets directly from the `integration-test` environment — no secret pass-through from the orchestrator is needed.
2525

2626
Preferred identity model: user-assigned managed identity (UAMI).
2727

@@ -146,29 +146,11 @@ gh secret set APIM_PUBLISHER_EMAIL \
146146
--body "${APIM_PUBLISHER_EMAIL}"
147147
```
148148

149-
### 6) Set Repo-Level Secrets (for release-tests orchestrator)
149+
### 6) Verify Called Workflows Can Access Environment Secrets
150150

151-
The `release-tests.yml` orchestrator passes secrets to called workflows via explicit `secrets:` mapping. Since the orchestrator itself does not declare an `environment:`, it reads from **repo-level** secrets. Set the same values at the repo level:
151+
The `release-tests.yml` orchestrator does **not** pass secrets to called workflows. Instead, the called workflows (`integration-test.yml`, `integration-redact-secrets.yml`) access secrets directly via their `environment: integration-test` declaration. Each called workflow includes a "Validate Required Secrets" step that fails fast with a clear error if any secret is missing.
152152

153-
```bash
154-
gh secret set AZURE_CLIENT_ID \
155-
--repo "${GITHUB_OWNER}/${GITHUB_REPO}" \
156-
--body "${IDENTITY_CLIENT_ID}"
157-
158-
gh secret set AZURE_TENANT_ID \
159-
--repo "${GITHUB_OWNER}/${GITHUB_REPO}" \
160-
--body "${TENANT_ID}"
161-
162-
gh secret set AZURE_SUBSCRIPTION_ID \
163-
--repo "${GITHUB_OWNER}/${GITHUB_REPO}" \
164-
--body "${SUBSCRIPTION_ID}"
165-
166-
gh secret set APIM_PUBLISHER_EMAIL \
167-
--repo "${GITHUB_OWNER}/${GITHUB_REPO}" \
168-
--body "${APIM_PUBLISHER_EMAIL}"
169-
```
170-
171-
> **Note:** If you only have environment-level secrets without matching repo-level secrets, the `release-tests.yml` workflow will fail because `${{ secrets.* }}` in the orchestrator resolves from repo scope. The called workflows still use the `integration-test` environment for OIDC token issuance.
153+
No repo-level secrets are required — all secrets are scoped to the `integration-test` environment.
172154

173155
## Verification
174156

.github/workflows/integration-redact-secrets.yml

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -48,15 +48,6 @@ on:
4848
required: false
4949
type: string
5050
default: Verbose
51-
secrets:
52-
AZURE_CLIENT_ID:
53-
required: true
54-
AZURE_TENANT_ID:
55-
required: true
56-
AZURE_SUBSCRIPTION_ID:
57-
required: true
58-
APIM_PUBLISHER_EMAIL:
59-
required: true
6051

6152
permissions:
6253
id-token: write
@@ -84,6 +75,19 @@ jobs:
8475

8576
- run: npm ci && npm run build
8677

78+
- name: Validate Required Secrets
79+
shell: bash
80+
run: |
81+
missing=()
82+
[[ -z "${{ secrets.AZURE_CLIENT_ID }}" ]] && missing+=("AZURE_CLIENT_ID")
83+
[[ -z "${{ secrets.AZURE_TENANT_ID }}" ]] && missing+=("AZURE_TENANT_ID")
84+
[[ -z "${{ secrets.AZURE_SUBSCRIPTION_ID }}" ]] && missing+=("AZURE_SUBSCRIPTION_ID")
85+
[[ -z "${{ secrets.APIM_PUBLISHER_EMAIL }}" ]] && missing+=("APIM_PUBLISHER_EMAIL")
86+
if [[ ${#missing[@]} -gt 0 ]]; then
87+
echo "::error::Missing required secrets: ${missing[*]}"
88+
exit 1
89+
fi
90+
8791
- name: Azure Login
8892
uses: azure/login@v3
8993
with:

.github/workflows/integration-test.yml

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -66,17 +66,6 @@ on:
6666
required: false
6767
type: string
6868
default: Verbose
69-
secrets:
70-
AZURE_CLIENT_ID:
71-
required: true
72-
AZURE_TENANT_ID:
73-
required: true
74-
AZURE_SUBSCRIPTION_ID:
75-
required: true
76-
APIM_PUBLISHER_EMAIL:
77-
required: true
78-
APIM_SKU:
79-
required: false
8069

8170
permissions:
8271
id-token: write
@@ -110,7 +99,18 @@ jobs:
11099

111100
- run: npm ci && npm run build
112101

113-
- name: Resolve Workflow Settings
102+
- name: Validate Required Secrets
103+
shell: bash
104+
run: |
105+
missing=()
106+
[[ -z "${{ secrets.AZURE_CLIENT_ID }}" ]] && missing+=("AZURE_CLIENT_ID")
107+
[[ -z "${{ secrets.AZURE_TENANT_ID }}" ]] && missing+=("AZURE_TENANT_ID")
108+
[[ -z "${{ secrets.AZURE_SUBSCRIPTION_ID }}" ]] && missing+=("AZURE_SUBSCRIPTION_ID")
109+
[[ -z "${{ secrets.APIM_PUBLISHER_EMAIL }}" ]] && missing+=("APIM_PUBLISHER_EMAIL")
110+
if [[ ${#missing[@]} -gt 0 ]]; then
111+
echo "::error::Missing required secrets: ${missing[*]}"
112+
exit 1
113+
fi
114114
id: settings
115115
shell: pwsh
116116
run: |

.github/workflows/release-tests.yml

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,6 @@ on:
3737
default: Verbose
3838

3939
permissions:
40-
id-token: write
4140
contents: read
4241

4342
jobs:
@@ -53,11 +52,6 @@ jobs:
5352
sku: ${{ inputs.sku || 'StandardV2' }}
5453
location: ${{ inputs.location || 'centralus' }}
5554
log_level: ${{ inputs.log_level || 'Verbose' }}
56-
secrets:
57-
AZURE_CLIENT_ID: ${{ secrets.AZURE_CLIENT_ID }}
58-
AZURE_TENANT_ID: ${{ secrets.AZURE_TENANT_ID }}
59-
AZURE_SUBSCRIPTION_ID: ${{ secrets.AZURE_SUBSCRIPTION_ID }}
60-
APIM_PUBLISHER_EMAIL: ${{ secrets.APIM_PUBLISHER_EMAIL }}
6155

6256
redact-secrets-integration:
6357
name: Redact Secrets Integration Test
@@ -67,8 +61,3 @@ jobs:
6761
sku: ${{ inputs.sku || 'StandardV2' }}
6862
location: ${{ inputs.location || 'centralus' }}
6963
log_level: ${{ inputs.log_level || 'Verbose' }}
70-
secrets:
71-
AZURE_CLIENT_ID: ${{ secrets.AZURE_CLIENT_ID }}
72-
AZURE_TENANT_ID: ${{ secrets.AZURE_TENANT_ID }}
73-
AZURE_SUBSCRIPTION_ID: ${{ secrets.AZURE_SUBSCRIPTION_ID }}
74-
APIM_PUBLISHER_EMAIL: ${{ secrets.APIM_PUBLISHER_EMAIL }}

0 commit comments

Comments
 (0)