Skip to content

Increment OpenSearch Dashboards Plugins Version #559

Increment OpenSearch Dashboards Plugins Version

Increment OpenSearch Dashboards Plugins Version #559

---
name: Increment OpenSearch Dashboards Plugins Version
on:
schedule:
- cron: 0 0 * * *
workflow_dispatch:
inputs:
logLevel:
description: Log level
required: true
default: warning
type: choice
options:
- info
- warning
- debug
jobs:
plugin-version-increment-sync:
if: github.repository == 'opensearch-project/opensearch-build'
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
entry:
# Adding the core repo OpenSearch-Dashboards for the label creation automation
- {repo: OpenSearch-Dashboards}
- {repo: dashboards-observability}
- {repo: dashboards-reporting}
- {repo: dashboards-visualizations}
- {repo: dashboards-query-workbench}
- {repo: dashboards-assistant}
- {repo: dashboards-maps}
- {repo: anomaly-detection-dashboards-plugin}
- {repo: ml-commons-dashboards}
- {repo: index-management-dashboards-plugin}
- {repo: dashboards-notifications}
- {repo: alerting-dashboards-plugin}
- {repo: security-analytics-dashboards-plugin}
- {repo: security-dashboards-plugin}
- {repo: dashboards-search-relevance}
- {repo: opensearch-dashboards-functional-test}
branch:
- 1.x
- '1.3'
- 2.x
- main
- '2.12'
- '2.13'
- '2.14'
steps:
- name: Check out OpenSearch Dashboards repo
uses: actions/checkout@v3
with:
repository: opensearch-project/OpenSearch-Dashboards
ref: ${{ matrix.branch }}
path: OpenSearch-Dashboards
- name: Check out plugin repo
if: ${{ matrix.entry.repo != 'OpenSearch-Dashboards' }}
uses: actions/checkout@v3
with:
repository: opensearch-project/${{ matrix.entry.repo }}
ref: ${{ matrix.branch }}
path: OpenSearch-Dashboards/plugins/${{ matrix.entry.repo }}
- name: Setup Node
uses: actions/setup-node@v3
with:
node-version-file: './OpenSearch-Dashboards/.nvmrc'
registry-url: 'https://registry.npmjs.org'
- name: Install Yarn and Setup Dashboard Version
shell: bash
run: |
YARN_VERSION=$(node -p "require('./OpenSearch-Dashboards/package.json').engines.yarn")
echo "Installing yarn@$YARN_VERSION"
npm i -g yarn@$YARN_VERSION
DASHBOARD_VERSION=$(node -p "require('./OpenSearch-Dashboards/package.json').version")
echo "DASHBOARD_VERSION=$DASHBOARD_VERSION" >> $GITHUB_ENV
- run: node -v
- run: yarn -v
- name: Bootstrap and Version Increment
if: ${{ matrix.entry.repo != 'OpenSearch-Dashboards' }}
run: |
cd OpenSearch-Dashboards/plugins/${{ matrix.entry.repo }}
if [ ${{ matrix.entry.path }} ]; then
yarn osd bootstrap
cp -R ${{ matrix.entry.path }} ../
cd ../${{ matrix.entry.path }}
node ../../scripts/plugin_helpers version --sync legacy
OSD_PLUGIN_VERSION=$(node -p "require('./package.json').version")
echo "OSD_PLUGIN_VERSION=$OSD_PLUGIN_VERSION" >> $GITHUB_ENV
cd ../
cp -R ${{ matrix.entry.path }} ${{ matrix.entry.repo }}/
cd ${{ matrix.entry.repo }}/
# tmp `elif` solution for opensearch-dashboards-functional-test (ref: https://github.com/opensearch-project/OpenSearch-Dashboards/issues/1801#issuecomment-1545947935)
elif [ ${{ matrix.entry.repo }} == "opensearch-dashboards-functional-test" ]; then
jq --arg DASHBOARD_VERSION "${{ env.DASHBOARD_VERSION }}" '.version = $DASHBOARD_VERSION' package.json > package-tmp.json
mv package-tmp.json package.json
OSD_PLUGIN_VERSION=$(node -p "require('./package.json').version")
echo "OSD_PLUGIN_VERSION=$OSD_PLUGIN_VERSION" >> $GITHUB_ENV
else
yarn osd bootstrap
node ../../scripts/plugin_helpers version --sync legacy
OSD_PLUGIN_VERSION=$(node -p "require('./package.json').version")
echo "OSD_PLUGIN_VERSION=$OSD_PLUGIN_VERSION" >> $GITHUB_ENV
fi
- name: GitHub App token
id: github_app_token
uses: tibdex/[email protected]
with:
app_id: ${{ secrets.APP_ID }}
private_key: ${{ secrets.APP_PRIVATE_KEY }}
installation_id: 22958780
- name: Check if label exists
id: check_label
uses: actions/github-script@v6
with:
github-token: ${{ steps.github_app_token.outputs.token }}
result-encoding: string
script: |
const labelName = "v${{ env.DASHBOARD_VERSION }}";
let labelFound = false;
try {
const label = await github.rest.issues.getLabel({
owner: context.repo.owner,
repo: "${{ matrix.entry.repo }}",
name: labelName
});
labelFound = true;
} catch (error) {
if (error.status === 404) {
const randomColor = Math.floor(Math.random() * 16777215).toString(16);
const newLabel = {
owner: context.repo.owner,
repo: "${{ matrix.entry.repo }}",
name: labelName,
color: randomColor,
description: "Issues targeting release " + labelName
};
await github.rest.issues.createLabel(newLabel);
labelFound = true;
} else {
throw error;
}
}
console.log(labelFound);
return labelFound
- name: Create Pull Request for plugins
if: ${{ matrix.entry.repo != 'OpenSearch-Dashboards' && matrix.entry.repo
!= 'opensearch-dashboards-functional-test' }}
id: cpr
uses: peter-evans/create-pull-request@v5
with:
token: ${{ steps.github_app_token.outputs.token }}
committer: opensearch-ci-bot <[email protected]>
author: opensearch-ci-bot <[email protected]>
commit-message: |
Increment version to ${{ env.OSD_PLUGIN_VERSION }}
Signed-off-by: opensearch-ci-bot <[email protected]>
delete-branch: true
branch: create-pull-request/${{ env.OSD_PLUGIN_VERSION }}
title: '[AUTO] Increment version to ${{ env.OSD_PLUGIN_VERSION }}'
labels: |
v${{ env.DASHBOARD_VERSION }}
body: |
- Incremented version to **${{ env.OSD_PLUGIN_VERSION }}**.
path: 'OpenSearch-Dashboards/plugins/${{ matrix.entry.repo }}'
add-paths: |
opensearch_dashboards.json
package.json
- name: Create Pull Request for opensearch-dashboards-functional-test
if: ${{ matrix.entry.repo == 'opensearch-dashboards-functional-test' }}
id: cprft
uses: peter-evans/create-pull-request@v5
with:
token: ${{ steps.github_app_token.outputs.token }}
committer: opensearch-ci-bot <[email protected]>
author: opensearch-ci-bot <[email protected]>
commit-message: |
Increment version to ${{ env.OSD_PLUGIN_VERSION }}
Signed-off-by: opensearch-ci-bot <[email protected]>
delete-branch: true
branch: create-pull-request/${{ env.OSD_PLUGIN_VERSION }}
title: '[AUTO] Increment version to ${{ env.OSD_PLUGIN_VERSION }}'
labels: |
v${{ env.DASHBOARD_VERSION }}
body: |
- Incremented version to **${{ env.OSD_PLUGIN_VERSION }}**.
path: 'OpenSearch-Dashboards/plugins/${{ matrix.entry.repo }}'
add-paths: |
package.json
- name: Check outputs
run: |-
echo "Pull Request Number - ${{ steps.cprft.outputs.pull-request-number }}"
echo "Pull Request URL - ${{ steps.cprft.outputs.pull-request-url }}"