@@ -3,6 +3,18 @@ name: Auto Proto Convert
33on :
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,32 +44,42 @@ jobs:
3244 distribution : temurin
3345 java-version : 17
3446
35- - name : Download Release Assets
36- uses : robinraju/release-downloader@28fc21f50d76778e7023361aa1f863e717d3d56f # v1
37- with :
38- repository : ' opensearch-project/opensearch-api-specification'
39- latest : true
40- fileName : ' opensearch-openapi.yaml'
41- tag : ' main-latest'
42- preRelease : true
43-
44- - name : Get Latest Commit ID
45- id : get_commit
46- uses : actions/github-script@d7906e4ad0b1822421a7e6a35d5ca353c962f410 # v6
47- with :
48- github-token : ${{ secrets.GITHUB_TOKEN }}
49- script : |
50- const owner = "opensearch-project";
51- const repo = "opensearch-api-specification";
52- const commits = await github.rest.repos.listCommits({
53- owner,
54- repo,
55- sha: "main",
56- per_page: 1
57- });
58- const latestCommit = commits.data[0].sha;
59- core.setOutput("latest_commit", latestCommit);
60- console.log("Latest commit: " + latestCommit);
47+ - name : Resolve provided artifact metadata
48+ id : api_spec_artifact
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
58+
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"
62+
63+ - name : Download API spec build artifact
64+ env :
65+ GH_TOKEN : ${{ secrets.GITHUB_TOKEN }}
66+ run : |
67+ curl -L \
68+ -H "Authorization: Bearer $GH_TOKEN" \
69+ -H "Accept: application/vnd.github+json" \
70+ -o api-spec-build.zip \
71+ "${{ steps.api_spec_artifact.outputs.artifact_download_url }}"
72+
73+ rm -rf api-spec-build
74+ unzip -q api-spec-build.zip -d api-spec-build
75+
76+ SPEC_PATH=$(find api-spec-build -name opensearch-openapi.yaml -print -quit)
77+ if [ -z "$SPEC_PATH" ]; then
78+ echo "Could not find opensearch-openapi.yaml in downloaded artifact"
79+ exit 1
80+ fi
81+
82+ cp "$SPEC_PATH" opensearch-openapi.yaml
6183
6284 - name : Get Latest OpenSearch Core Version
6385 id : get_opensearch_version
@@ -164,7 +186,7 @@ jobs:
164186 token : ${{ secrets.GITHUB_TOKEN }}
165187 branch : auto-pr-branch
166188 commit-message : " Protobuf schema change detected"
167- title : " [Automated PR]: Update generated protobuf schema (OpenSearch: ${{ steps.get_opensearch_version.outputs.version }}, spec commit: ${{ steps.get_commit .outputs.latest_commit }})"
189+ title : " [Automated PR]: Update generated protobuf schema (OpenSearch: ${{ steps.get_opensearch_version.outputs.version }}, spec commit: ${{ steps.api_spec_artifact .outputs.source_commit }})"
168190 signoff : true
169191 base : main
170192 delete-branch : true
@@ -173,7 +195,8 @@ jobs:
173195 This pull request was automatically generated by GitHub Actions.
174196
175197 **OpenSearch Version**: ${{ steps.get_opensearch_version.outputs.version }}
176- **API Spec Commit**: ${{ steps.get_commit.outputs.latest_commit }}
198+ **API Spec Commit**: ${{ steps.api_spec_artifact.outputs.source_commit }}
199+ **API Spec Build Run**: ${{ steps.api_spec_artifact.outputs.run_id }}
177200
178201 ---
179202
0 commit comments