Skip to content

Commit 49f9f5d

Browse files
committed
Require artifact URL for auto proto conversion
Signed-off-by: xil <fridalu66@gmail.com>
1 parent 6304d3f commit 49f9f5d

1 file changed

Lines changed: 26 additions & 48 deletions

File tree

.github/workflows/convert-proto.yml

Lines changed: 26 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,18 @@ name: Auto Proto Convert
33
on:
44
workflow_dispatch:
55
inputs:
6+
artifact_download_url:
7+
description: 'Download URL for the api-spec build artifact zip.'
8+
required: true
9+
type: string
10+
api_spec_commit:
11+
description: 'Optional api-spec commit SHA for PR metadata.'
12+
required: false
13+
type: string
14+
api_spec_run_id:
15+
description: 'Optional api-spec workflow run ID for PR metadata.'
16+
required: false
17+
type: string
618
opensearch_version:
719
description: 'OpenSearch version. Leave empty to fetch latest.'
820
required: false
@@ -32,55 +44,21 @@ jobs:
3244
distribution: temurin
3345
java-version: 17
3446

35-
- name: Resolve API spec build artifact
47+
- name: Resolve provided artifact metadata
3648
id: api_spec_artifact
37-
uses: actions/github-script@d7906e4ad0b1822421a7e6a35d5ca353c962f410 # v6
38-
with:
39-
github-token: ${{ secrets.GITHUB_TOKEN }}
40-
script: |
41-
const owner = "opensearch-project";
42-
const repo = "opensearch-api-specification";
43-
const workflow_id = "build.yml";
44-
const branch = "main";
45-
46-
const response = await github.rest.actions.listWorkflowRuns({
47-
owner,
48-
repo,
49-
workflow_id,
50-
branch,
51-
event: "push",
52-
status: "completed",
53-
per_page: 1
54-
});
55-
const selectedRun = response.data.workflow_runs[0];
56-
57-
if (!selectedRun) {
58-
core.setFailed("Could not find a completed api-spec build run on main.");
59-
return;
60-
}
61-
62-
const artifacts = await github.rest.actions.listWorkflowRunArtifacts({
63-
owner,
64-
repo,
65-
run_id: selectedRun.id
66-
});
67-
const selectedArtifact = artifacts.data.artifacts.find(
68-
(artifact) => artifact.name === "build" && !artifact.expired
69-
);
70-
71-
if (!selectedArtifact) {
72-
core.setFailed(`Latest completed api-spec build run ${selectedRun.id} does not have a non-expired build artifact.`);
73-
return;
74-
}
49+
env:
50+
ARTIFACT_DOWNLOAD_URL: ${{ inputs.artifact_download_url || github.event.client_payload.artifact_download_url || '' }}
51+
API_SPEC_COMMIT: ${{ inputs.api_spec_commit || github.event.client_payload.api_spec_commit || '' }}
52+
API_SPEC_RUN_ID: ${{ inputs.api_spec_run_id || github.event.client_payload.api_spec_run_id || '' }}
53+
run: |
54+
if [ -z "$ARTIFACT_DOWNLOAD_URL" ]; then
55+
echo "artifact_download_url is required for both workflow_dispatch and repository_dispatch."
56+
exit 1
57+
fi
7558
76-
core.setOutput("source_commit", selectedRun.head_sha);
77-
core.setOutput("run_id", String(selectedRun.id));
78-
core.setOutput("run_conclusion", selectedRun.conclusion || "unknown");
79-
core.setOutput("artifact_id", String(selectedArtifact.id));
80-
core.setOutput("artifact_download_url", selectedArtifact.archive_download_url);
81-
console.log(
82-
`Using build artifact ${selectedArtifact.id} from run ${selectedRun.id} (${selectedRun.conclusion}) at commit ${selectedRun.head_sha}`
83-
);
59+
echo "artifact_download_url=$ARTIFACT_DOWNLOAD_URL" >> "$GITHUB_OUTPUT"
60+
echo "source_commit=${API_SPEC_COMMIT:-unknown}" >> "$GITHUB_OUTPUT"
61+
echo "run_id=${API_SPEC_RUN_ID:-unknown}" >> "$GITHUB_OUTPUT"
8462
8563
- name: Download API spec build artifact
8664
env:
@@ -218,7 +196,7 @@ jobs:
218196
219197
**OpenSearch Version**: ${{ steps.get_opensearch_version.outputs.version }}
220198
**API Spec Commit**: ${{ steps.api_spec_artifact.outputs.source_commit }}
221-
**API Spec Build Run**: ${{ steps.api_spec_artifact.outputs.run_id }} (${{ steps.api_spec_artifact.outputs.run_conclusion }})
199+
**API Spec Build Run**: ${{ steps.api_spec_artifact.outputs.run_id }}
222200
223201
---
224202

0 commit comments

Comments
 (0)