@@ -3,13 +3,14 @@ name: Auto Proto Convert
33on :
44 workflow_dispatch :
55 inputs :
6- input_param :
7- description : ' '
6+ opensearch_version :
7+ description : ' OpenSearch version (e.g., 3.4, 3.3.2). Leave empty to fetch latest. '
88 required : false
9+ type : string
910jobs :
1011 auto-proto-convert :
1112 runs-on : ubuntu-latest
12- if : github.repository == 'opensearch-project/opensearch-protobufs'
13+ # if: github.repository == 'opensearch-project/opensearch-protobufs'
1314 steps :
1415 - name : Checkout Repository
1516 uses : actions/checkout@v4
5758 core.setOutput("latest_commit", latestCommit);
5859 console.log("Latest commit: " + latestCommit);
5960
61+ - name : Get Latest OpenSearch Core Version
62+ id : get_opensearch_version
63+ uses : actions/github-script@v6
64+ with :
65+ github-token : ${{ secrets.GITHUB_TOKEN }}
66+ script : |
67+ // Check if version was provided as input
68+ const inputVersion = "${{ inputs.opensearch_version }}";
69+ if (inputVersion && inputVersion.trim() !== "") {
70+ core.setOutput("version", inputVersion.trim());
71+ console.log("Using provided OpenSearch version: " + inputVersion.trim());
72+ return;
73+ }
74+
75+ // Otherwise fetch version from buildSrc/version.properties on main branch
76+ try {
77+ const response = await github.request(
78+ 'GET /repos/{owner}/{repo}/contents/{path}',
79+ {
80+ owner: 'opensearch-project',
81+ repo: 'OpenSearch',
82+ path: 'buildSrc/version.properties',
83+ ref: 'main'
84+ }
85+ );
86+
87+ // Decode the file content
88+ const content = Buffer.from(response.data.content, 'base64').toString('utf-8');
89+
90+ // Extract opensearch version (e.g., "opensearch = 3.4.0")
91+ const match = content.match(/opensearch\s*=\s*([^\s]+)/);
92+
93+ if (match && match[1]) {
94+ const version = match[1].trim();
95+ core.setOutput("version", version);
96+ console.log("Fetched OpenSearch version from source: " + version);
97+ } else {
98+ console.log("Warning: Could not parse version from buildSrc/version.properties");
99+ core.setOutput("version", "unknown");
100+ }
101+ } catch (error) {
102+ console.log("Warning: Could not fetch OpenSearch version: " + error.message);
103+ core.setOutput("version", "unknown");
104+ }
105+
60106 - name : Run Proto Conversion
61- run : npm ci && npm run preprocessing
107+ env :
108+ OPENSEARCH_VERSION : ${{ steps.get_opensearch_version.outputs.version }}
109+ run : npm ci && npm run preprocessing -- --opensearch-version "$OPENSEARCH_VERSION"
62110
63111 - name : Clone Protobuf Generator Repository
64112 run : |
@@ -105,10 +153,13 @@ jobs:
105153 token : ${{ secrets.GITHUB_TOKEN }}
106154 branch : auto-pr-branch
107155 commit-message : " Protobuf schema change detected"
108- title : " [Automated PR]: Update generated protobuf schema (spec commit: ${{ steps.get_commit.outputs.latest_commit }})"
156+ title : " [Automated PR]: Update generated protobuf schema (OpenSearch: ${{ steps.get_opensearch_version.outputs.version }}, spec commit: ${{ steps.get_commit.outputs.latest_commit }})"
109157 signoff : true
110158 base : main
111159 delete-branch : true
112160 labels : skip-changelog
113161 body : |
114162 This pull request was automatically generated by GitHub Actions.
163+
164+ **OpenSearch Version**: ${{ steps.get_opensearch_version.outputs.version }}
165+ **API Spec Commit**: ${{ steps.get_commit.outputs.latest_commit }}
0 commit comments