77 branches :
88 - " *"
99env :
10- OPENSEARCH_DASHBOARDS_VERSION : ' main'
11- QUERY_INSIGHTS_BRANCH : ' main'
1210 GRADLE_VERSION : ' 7.6.1'
1311 CYPRESS_VIDEO : true
1412 CYPRESS_SCREENSHOT_ON_RUN_FAILURE : true
@@ -32,11 +30,31 @@ jobs:
3230 TERM : xterm
3331 steps :
3432
35- - name : Set up JDK
36- uses : actions/setup-java@v4
37- with :
38- java-version : 21
39- distribution : temurin
33+ - uses : actions/checkout@v4
34+
35+ - name : Set env
36+ run : |
37+ opensearch_version=$(node -p "require('./package.json').opensearchDashboards.version")
38+ plugin_version=$(node -p "require('./package.json').version")
39+ major_version=$(echo $opensearch_version | cut -d. -f1)
40+ minor_version=$(echo $opensearch_version | cut -d. -f2)
41+ branch_version=${major_version}.${minor_version}
42+ opensearch_branch=$branch_version
43+ opensearch_dashboards_branch=$branch_version
44+ query_insights_branch=$branch_version
45+ base_branch=${{ github.base_ref }}
46+ echo "base_branch $base_branch"
47+ if [ "$base_branch" = "main" ]; then
48+ opensearch_branch=main
49+ opensearch_dashboards_branch=main
50+ query_insights_branch=main
51+ fi
52+ echo "QUERY_INSIGHTS_BRANCH=$query_insights_branch" >> $GITHUB_ENV
53+ echo "OPENSEARCH_BRANCH=$opensearch_branch" >> $GITHUB_ENV
54+ echo "OPENSEARCH_DASHBOARDS_BRANCH=$opensearch_dashboards_branch" >> $GITHUB_ENV
55+ echo "OPENSEARCH_VERSION=$opensearch_version" >> $GITHUB_ENV
56+ echo "PLUGIN_VERSION=$plugin_version" >> $GITHUB_ENV
57+ shell : bash
4058
4159 - name : Checkout Query Insights
4260 uses : actions/checkout@v4
@@ -58,39 +76,11 @@ jobs:
5876 echo "Listing files:"
5977 ls -la
6078
61- - name : Fetch OpenSearch version from build.gradle
62- run : |
63- # Navigate to the query-insights directory
64- cd query-insights
65-
66- # Check if build.gradle exists
67- if [ -f "build.gradle" ]; then
68- echo "build.gradle file exists!"
69- else
70- echo "build.gradle file not found!"
71- exit 1
72- fi
73-
74- # Print the content of build.gradle for debugging
75- echo "Printing build.gradle content:"
76- cat build.gradle
77-
78- # Extract the version from build.gradle using Node.js with the updated regex
79- opensearch_version=$(node -e "
80- const fs = require('fs');
81- const gradleFile = fs.readFileSync('build.gradle', 'utf-8');
82- const match = gradleFile.match(/opensearch_version\\s*=\\s*System\\.getProperty\\(['\"][^'\"]+['\"],\\s*['\"]([^'\"]+)['\"]\\)/);
83- console.log(match ? match[1] : 'No version found');
84- ")
85-
86- # Set the OpenSearch version as an environment variable
87- echo "OPENSEARCH_VERSION=$opensearch_version" >> $GITHUB_ENV
88- echo "PLUGIN_VERSION=$opensearch_version" >> $GITHUB_ENV
89-
90- # Print the version for debugging
91- echo "Using OpenSearch version: $opensearch_version"
92- shell : bash
93-
79+ - name : Set up JDK
80+ uses : actions/setup-java@v4
81+ with :
82+ java-version : 21
83+ distribution : temurin
9484
9585 - name : Verify OpenSearch version
9686 run : |
@@ -179,7 +169,7 @@ jobs:
179169 with :
180170 repository : opensearch-project/OpenSearch-Dashboards
181171 path : OpenSearch-Dashboards
182- ref : ${{ env.OPENSEARCH_DASHBOARDS_VERSION }}
172+ ref : ${{ env.OPENSEARCH_DASHBOARDS_BRANCH }}
183173
184174 - name : Checkout Query Insights Dashboards plugin
185175 uses : actions/checkout@v4
0 commit comments