Skip to content

Commit 73e9f13

Browse files
authored
Merge branch 'main' into add-security-insights
2 parents 0ee42e2 + 209adb7 commit 73e9f13

5 files changed

Lines changed: 267 additions & 78 deletions

File tree

Lines changed: 141 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,141 @@
1+
// @ts-nocheck
2+
3+
/** @param {{ github: any, core: any }} param0 */
4+
export default async ({ github, core }) => {
5+
try {
6+
const remoteOwner = core.getInput("OWNER", { required: true });
7+
const remoteRepo = core.getInput("REPO", { required: true });
8+
const remoteWorkflowFile = core.getInput("WORKFLOW_FILE", {
9+
required: true,
10+
});
11+
const dispatchStartedAt = core.getInput("DISPATCH_STARTED_AT", {
12+
required: true,
13+
});
14+
15+
const maxWaitSeconds = Number(core.getInput("MAX_WAIT_SECONDS") || "900"); // Default to 15 minutes
16+
const pollIntervalSeconds = Number(
17+
core.getInput("POLL_INTERVAL_SECONDS") || "10",
18+
);
19+
20+
/** @param {number} ms */
21+
const sleep = (ms) => new Promise((resolve) => setTimeout(resolve, ms));
22+
23+
core.info(
24+
`Waiting for remote workflow run in ${remoteOwner}/${remoteRepo}...`,
25+
);
26+
27+
const findLatestRun = async () => {
28+
const response = await github.rest.actions.listWorkflowRuns({
29+
owner: remoteOwner,
30+
repo: remoteRepo,
31+
workflow_id: remoteWorkflowFile,
32+
event: "repository_dispatch",
33+
per_page: 20,
34+
});
35+
36+
const candidateRuns = (response.data.workflow_runs || [])
37+
/** @param {any} run */
38+
.filter((run) => run.created_at >= dispatchStartedAt)
39+
/** @param {any} left @param {any} right */
40+
.sort((left, right) => left.created_at.localeCompare(right.created_at));
41+
42+
return candidateRuns.length > 0
43+
? candidateRuns[candidateRuns.length - 1]
44+
: undefined;
45+
};
46+
47+
let run;
48+
for (
49+
let elapsed = 0;
50+
elapsed < maxWaitSeconds;
51+
elapsed += pollIntervalSeconds
52+
) {
53+
run = await findLatestRun();
54+
if (run) {
55+
break;
56+
}
57+
58+
await sleep(pollIntervalSeconds * 1000);
59+
}
60+
61+
if (!run) {
62+
core.setFailed(
63+
`Timed out waiting for remote workflow run to start: https://github.com/${remoteOwner}/${remoteRepo}/actions/workflows/${remoteWorkflowFile}`,
64+
);
65+
return;
66+
}
67+
68+
const runUrl =
69+
run.html_url ||
70+
`https://github.com/${remoteOwner}/${remoteRepo}/actions/runs/${run.id}`;
71+
72+
core.info(`Monitoring remote run id: ${run.id}`);
73+
core.info(`Remote workflow run URL: ${runUrl}`);
74+
75+
for (
76+
let elapsed = 0;
77+
elapsed < maxWaitSeconds;
78+
elapsed += pollIntervalSeconds
79+
) {
80+
const runResponse = await github.rest.actions.getWorkflowRun({
81+
owner: remoteOwner,
82+
repo: remoteRepo,
83+
run_id: run.id,
84+
});
85+
86+
const status = runResponse.data.status;
87+
const conclusion = runResponse.data.conclusion || "";
88+
89+
if (status === "completed") {
90+
core.setOutput("run_id", String(run.id));
91+
core.setOutput("run_url", runUrl);
92+
core.setOutput("conclusion", conclusion);
93+
94+
if (conclusion === "success") {
95+
core.info("Remote workflow completed successfully");
96+
return;
97+
}
98+
99+
const jobsResponse = await github.rest.actions.listJobsForWorkflowRun({
100+
owner: remoteOwner,
101+
repo: remoteRepo,
102+
run_id: run.id,
103+
per_page: 100,
104+
});
105+
106+
const failedJobs = (jobsResponse.data.jobs || []).filter(
107+
/** @param {any} job */
108+
(job) => job.conclusion !== "success",
109+
);
110+
const failedJobText = failedJobs
111+
/** @param {any} job */
112+
.map((job) => {
113+
const failedSteps = (job.steps || [])
114+
/** @param {any} step */
115+
.filter((step) => step.conclusion === "failure")
116+
/** @param {any} step */
117+
.map((step) => ` - Step: ${step.name}`)
118+
.join("\n");
119+
120+
return `- Job: ${job.name} [${job.conclusion}]${failedSteps ? `\n${failedSteps}` : ""}`;
121+
})
122+
.join("\n");
123+
124+
core.setFailed(
125+
`Remote workflow failed with conclusion: ${conclusion}\nRemote workflow run: ${runUrl}${failedJobText ? `\nFailed jobs/steps:\n${failedJobText}` : ""}`,
126+
);
127+
return;
128+
}
129+
130+
await sleep(pollIntervalSeconds * 1000);
131+
}
132+
133+
core.setOutput("run_id", String(run.id));
134+
core.setOutput("run_url", runUrl);
135+
core.setFailed(
136+
`Timed out waiting for remote workflow completion: ${runUrl}`,
137+
);
138+
} catch (error) {
139+
core.setFailed(error instanceof Error ? error.message : String(error));
140+
}
141+
};

.github/workflows/build.yaml

Lines changed: 55 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -59,9 +59,6 @@ env:
5959
# URL to get source code for building the image
6060
IMAGE_SRC: https://github.com/radius-project/radius
6161

62-
# bicep-types ACR url for uploading Radius Bicep types
63-
BICEP_TYPES_REGISTRY: biceptypes.azurecr.io
64-
6562
jobs:
6663
changes:
6764
name: Changes
@@ -356,15 +353,14 @@ jobs:
356353
helm push ${{ env.ARTIFACT_DIR }}/${{ env.HELM_PACKAGE_DIR }}/radius-${{ env.CHART_VERSION }}.tgz oci://${{ env.OCI_REGISTRY }}/${{ env.OCI_REPOSITORY }}
357354
358355
build-and-push-bicep-types:
359-
name: Publish Radius bicep types to ACR
356+
name: Dispatch Bicep Types publish
360357
runs-on: ubuntu-24.04
361-
timeout-minutes: 5
358+
timeout-minutes: 15
362359
needs: [changes]
363-
if: needs.changes.outputs.only_changed != 'true'
360+
if: github.repository == 'radius-project/radius' && needs.changes.outputs.only_changed != 'true' && (startsWith(github.ref, 'refs/tags/v') || github.ref == 'refs/heads/main')
364361
environment: publish-bicep
365362
permissions:
366363
contents: read # Required for actions/checkout
367-
id-token: write # Required for azure/login
368364
steps:
369365
- name: Checkout
370366
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
@@ -379,49 +375,64 @@ jobs:
379375
- name: Parse release version and set environment variables
380376
run: python ./.github/scripts/get_release_version.py
381377

382-
- name: Setup Go
383-
uses: actions/setup-go@7a3fe6cf4cb3a834922a1244abfce67bcef6a0c5 # v6.2.0
384-
with:
385-
go-version-file: go.mod
386-
cache-dependency-path: go.sum
387-
cache: true
388-
389-
- name: Setup Node.js
390-
uses: actions/setup-node@6044e13b5dc448c55e2357c09f80417699197238 # v6.2.0
378+
- name: Get App Token
379+
uses: actions/create-github-app-token@29824e69f54612133e76f7eaac726eef6c875baf # v2.2.1
380+
id: get-token
391381
with:
392-
node-version-file: .node-version
393-
394-
- name: Generate Bicep extensibility types from OpenAPI specs
382+
app-id: ${{ secrets.RADIUS_PUBLISHER_BOT_APP_ID }}
383+
private-key: ${{ secrets.RADIUS_PUBLISHER_BOT_PRIVATE_KEY }}
384+
permission-metadata: read
385+
permission-actions: read
386+
permission-contents: write
387+
owner: azure-octo
388+
repositories: |
389+
radius-publisher
390+
391+
- name: Capture dispatch start time
392+
id: dispatch-start
393+
shell: bash
395394
run: |
396-
make generate-bicep-types VERSION=${{ env.REL_CHANNEL == 'edge' && 'latest' || env.REL_CHANNEL }}
395+
echo "started_at=$(date -u +%Y-%m-%dT%H:%M:%SZ)" >> "$GITHUB_OUTPUT"
397396
398-
- name: Upload Radius Bicep types artifacts
399-
uses: actions/upload-artifact@b7c566a772e6b6bfb58ed0dc250532a479d7789f # v6.0.0
397+
- name: Repository Dispatch
398+
id: repository-dispatch
399+
uses: peter-evans/repository-dispatch@28959ce8df70de7be546dd1250a005dd32156697 # v4.0.1
400400
with:
401-
name: radius-bicep-types
402-
path: ./hack/bicep-types-radius/generated
403-
if-no-files-found: error
404-
405-
- name: Login via Azure CLI
406-
if: github.repository == 'radius-project/radius' && ((startsWith(github.ref, 'refs/tags/v') || github.ref == 'refs/heads/main'))
407-
uses: azure/login@a457da9ea143d694b1b9c7c869ebb04ebe844ef5 # v2.3.0
401+
token: ${{ steps.get-token.outputs.token }}
402+
repository: azure-octo/radius-publisher
403+
event-type: bicep-types
404+
client-payload: |-
405+
{
406+
"source_repository": "${{ github.repository }}",
407+
"source_ref": "${{ github.ref }}",
408+
"source_sha": "${{ github.sha }}",
409+
"rel_channel": "${{ env.REL_CHANNEL }}",
410+
"registry_target": "radius"
411+
}
412+
413+
- name: Monitor remote workflow
414+
id: monitor-remote-workflow
415+
uses: actions/github-script@ed597411d8f924073f98dfc5c65a23a2325f34cd # v8.0.0
408416
with:
409-
client-id: ${{ secrets.BICEPTYPES_CLIENT_ID }}
410-
tenant-id: ${{ secrets.BICEPTYPES_TENANT_ID }}
411-
subscription-id: ${{ secrets.BICEPTYPES_SUBSCRIPTION_ID }}
412-
413-
- name: Setup and verify bicep CLI
414-
if: github.repository == 'radius-project/radius' && ((startsWith(github.ref, 'refs/tags/v') || github.ref == 'refs/heads/main'))
415-
run: |
416-
curl -Lo bicep https://github.com/Azure/bicep/releases/latest/download/bicep-linux-x64
417-
chmod +x ./bicep
418-
sudo mv ./bicep /usr/local/bin/bicep
419-
bicep --version
420-
421-
- name: Publish bicep types
422-
if: github.repository == 'radius-project/radius' && ((startsWith(github.ref, 'refs/tags/v') || github.ref == 'refs/heads/main'))
417+
github-token: ${{ steps.get-token.outputs.token }}
418+
script: |
419+
const { default: script } = await import(`${process.env.GITHUB_WORKSPACE}/.github/scripts/monitor-remote-workflow.mjs`)
420+
await script({context, github, core})
421+
env:
422+
INPUT_OWNER: azure-octo
423+
INPUT_REPO: radius-publisher
424+
INPUT_WORKFLOW_FILE: publish-bicep-types.yml
425+
INPUT_DISPATCH_STARTED_AT: ${{ steps.dispatch-start.outputs.started_at }}
426+
INPUT_MAX_WAIT_SECONDS: "600"
427+
INPUT_POLL_INTERVAL_SECONDS: "15"
428+
429+
- name: Show failed logs
430+
if: failure() && steps.monitor-remote-workflow.outputs.run_id != ''
431+
shell: bash
432+
env:
433+
GH_TOKEN: ${{ steps.get-token.outputs.token }}
423434
run: |
424-
bicep publish-extension ./hack/bicep-types-radius/generated/index.json --target br:${{ env.BICEP_TYPES_REGISTRY }}/radius:${{ env.REL_CHANNEL == 'edge' && 'latest' || env.REL_CHANNEL }} --force
435+
gh run view "${{ steps.monitor-remote-workflow.outputs.run_id }}" --repo azure-octo/radius-publisher --log-failed || true
425436
426437
publish-release:
427438
name: Publish GitHub Release

.github/workflows/functional-test-cloud.yaml

Lines changed: 50 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -387,39 +387,64 @@ jobs:
387387
message: |
388388
:hourglass: Publishing Bicep Recipes for functional tests...
389389
390-
- name: Setup Node.js
391-
uses: actions/setup-node@6044e13b5dc448c55e2357c09f80417699197238 # v6.2.0
390+
- name: Get App Token (radius-publisher)
391+
uses: actions/create-github-app-token@29824e69f54612133e76f7eaac726eef6c875baf # v2.2.1
392+
id: get_publisher_token
392393
with:
393-
node-version-file: .node-version
394+
app-id: ${{ secrets.RADIUS_PUBLISHER_BOT_APP_ID }}
395+
private-key: ${{ secrets.RADIUS_PUBLISHER_BOT_PRIVATE_KEY }}
396+
permission-metadata: read
397+
permission-actions: read
398+
permission-contents: write
399+
owner: azure-octo
400+
repositories: |
401+
radius-publisher
394402
395-
- name: Generate Bicep extensibility types from OpenAPI specs
403+
- name: Capture dispatch start time
404+
id: dispatch-start
405+
shell: bash
396406
run: |
397-
make generate-bicep-types VERSION=${{ env.REL_VERSION == 'edge' && 'latest' || env.REL_VERSION }}
407+
echo "started_at=$(date -u +%Y-%m-%dT%H:%M:%SZ)" >> "$GITHUB_OUTPUT"
398408
399-
- name: Upload Radius Bicep types artifacts
400-
uses: actions/upload-artifact@b7c566a772e6b6bfb58ed0dc250532a479d7789f # v6.0.0
409+
- name: Repository Dispatch (publish test bicep types)
410+
id: repository-dispatch
411+
uses: peter-evans/repository-dispatch@28959ce8df70de7be546dd1250a005dd32156697 # v4.0.1
401412
with:
402-
name: radius_bicep_types_cloud
403-
path: ./hack/bicep-types-radius/generated
404-
if-no-files-found: error
413+
token: ${{ steps.get_publisher_token.outputs.token }}
414+
repository: azure-octo/radius-publisher
415+
event-type: bicep-types
416+
client-payload: |-
417+
{
418+
"source_repository": "${{ github.repository }}",
419+
"source_ref": "${{ github.ref }}",
420+
"source_sha": "${{ github.sha }}",
421+
"rel_channel": "${{ env.REL_VERSION }}",
422+
"registry_target": "test/radius"
423+
}
405424
406-
- name: Login via Azure CLI
407-
uses: azure/login@a457da9ea143d694b1b9c7c869ebb04ebe844ef5 # v2.3.0
425+
- name: Monitor remote workflow
426+
id: monitor-remote-workflow
427+
uses: actions/github-script@ed597411d8f924073f98dfc5c65a23a2325f34cd # v8.0.0
408428
with:
409-
client-id: ${{ secrets.BICEPTYPES_CLIENT_ID }}
410-
tenant-id: ${{ secrets.BICEPTYPES_TENANT_ID }}
411-
subscription-id: ${{ secrets.BICEPTYPES_SUBSCRIPTION_ID }}
412-
413-
- name: Setup and verify bicep CLI
414-
run: |
415-
curl -Lo bicep https://github.com/Azure/bicep/releases/latest/download/bicep-linux-x64
416-
chmod +x ./bicep
417-
sudo mv ./bicep /usr/local/bin/bicep
418-
bicep --version
419-
420-
- name: Publish bicep types
429+
github-token: ${{ steps.get_publisher_token.outputs.token }}
430+
script: |
431+
const { default: script } = await import(`${process.env.GITHUB_WORKSPACE}/.github/scripts/monitor-remote-workflow.mjs`)
432+
await script({context, github, core})
433+
env:
434+
INPUT_OWNER: azure-octo
435+
INPUT_REPO: radius-publisher
436+
INPUT_WORKFLOW_FILE: publish-bicep-types.yml
437+
INPUT_DISPATCH_STARTED_AT: ${{ steps.dispatch-start.outputs.started_at }}
438+
INPUT_MAX_WAIT_SECONDS: "900"
439+
INPUT_POLL_INTERVAL_SECONDS: "10"
440+
441+
- name: Show failed logs
442+
if: failure() && steps.monitor-remote-workflow.outputs.run_id != ''
443+
shell: bash
444+
env:
445+
GH_TOKEN: ${{ steps.get_publisher_token.outputs.token }}
421446
run: |
422-
bicep publish-extension ./hack/bicep-types-radius/generated/index.json --target br:${{ env.BICEP_TYPES_REGISTRY }}/test/radius:${{ env.REL_VERSION == 'edge' && 'latest' || env.REL_VERSION }} --force
447+
gh run view "${{ steps.monitor-remote-workflow.outputs.run_id }}" --repo azure-octo/radius-publisher --log-failed || true
423448
424449
- name: Generate test bicepconfig.json
425450
run: |

.vscode/mcp.json

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,14 @@
55
"url": "https://api.githubcopilot.com/mcp/"
66
},
77
"terraform": {
8+
"type": "stdio",
89
"command": "docker",
9-
"args": ["run", "-i", "--rm", "hashicorp/terraform-mcp-server:0.3"]
10+
"args": ["run", "-i", "--rm", "hashicorp/terraform-mcp-server:0.4.0"]
11+
},
12+
"gopls": {
13+
"type": "stdio",
14+
"command": "gopls",
15+
"args": ["mcp"]
1016
}
1117
}
1218
}

0 commit comments

Comments
 (0)