Skip to content

Commit

Permalink
Handle core label creation
Browse files Browse the repository at this point in the history
Signed-off-by: Prudhvi Godithi <[email protected]>
  • Loading branch information
prudhvigodithi committed Jul 5, 2023
1 parent 6e9a8f2 commit abc3c52
Show file tree
Hide file tree
Showing 2 changed files with 158 additions and 147 deletions.
290 changes: 148 additions & 142 deletions .github/workflows/os-increment-plugin-versions.yml
Original file line number Diff line number Diff line change
@@ -1,143 +1,149 @@
---
name: Increment OpenSearch 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:
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
entry:
- {repo: alerting}
- {repo: anomaly-detection}
- {repo: asynchronous-search}
- {repo: common-utils}
- {repo: cross-cluster-replication}
- {repo: geospatial}
- {repo: index-management}
- {repo: job-scheduler}
- {repo: k-NN}
- {repo: neural-search}
- {repo: ml-commons}
- {repo: notifications, path: notifications}
- {repo: observability}
- {repo: performance-analyzer}
- {repo: performance-analyzer-rca}
- {repo: reporting}
- {repo: security}
- {repo: security-analytics}
- {repo: sql}
branch:
- '1.3'
- 2.x
- '2.8'
- main
- '2.9'
exclude:
- {entry: {repo: geospatial}, branch: '1.3'}
- {entry: {repo: neural-search}, branch: '1.3'}
- {entry: {repo: security-analytics}, branch: '1.3'}
- {entry: {repo: notifications, path: notifications}, branch: '1.3'}
steps:
- name: Check out OpenSearch repo
uses: actions/checkout@v3
with:
repository: opensearch-project/OpenSearch
ref: ${{ matrix.branch }}
- name: Fetch OpenSearch version
run: |
OPENSEARCH_VERSION=$(cat buildSrc/version.properties | grep opensearch | cut -d= -f2 | grep -oE '[0-9.]+')
echo "OPENSEARCH_VERSION_NUMBER=$OPENSEARCH_VERSION" >> $GITHUB_ENV
OPENSEARCH_VERSION=$OPENSEARCH_VERSION-SNAPSHOT
echo "OPENSEARCH_VERSION=$OPENSEARCH_VERSION" >> $GITHUB_ENV
- name: Check out plugin repo
uses: actions/checkout@v3
with:
repository: opensearch-project/${{ matrix.entry.repo }}
ref: ${{ matrix.branch }}
- name: Increment Version in ${{ matrix.entry.repo }}
run: |
echo "OpenSearch Core repo version on branch ${{ matrix.branch }} is ${{ env.OPENSEARCH_VERSION_NUMBER }}"
if [ ${{ matrix.entry.path }} ]; then
echo "The gradle path is ${{ matrix.entry.path }}"
cd ${{ matrix.entry.path }}
fi
./gradlew updateVersion -DnewVersion=${{ env.OPENSEARCH_VERSION }}
- 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 and Create label
id: check_create_label
uses: actions/github-script@v6
with:
github-token: ${{ steps.github_app_token.outputs.token }}
result-encoding: string
script: |
const labelName = "v${{ env.OPENSEARCH_VERSION_NUMBER }}";
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
id: cpr
uses: peter-evans/create-pull-request@v4
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.OPENSEARCH_VERSION }}
Signed-off-by: opensearch-ci-bot <[email protected]>
delete-branch: true
branch: create-pull-request/${{ env.OPENSEARCH_VERSION }}
title: '[AUTO] Increment version to ${{ env.OPENSEARCH_VERSION }}'
labels: |
v${{ env.OPENSEARCH_VERSION_NUMBER }}
body: |
- Incremented version to **${{ env.OPENSEARCH_VERSION }}**.
- name: Check outputs
run: |-
echo "Pull Request Number - ${{ steps.cpr.outputs.pull-request-number }}"
echo "Pull Request URL - ${{ steps.cpr.outputs.pull-request-url }}"
name: Increment OpenSearch Plugins Version

Check failure on line 2 in .github/workflows/os-increment-plugin-versions.yml

View workflow job for this annotation

GitHub Actions / yaml-lint

2:5 [indentation] wrong indentation: expected 0 but found 4

Check failure on line 3 in .github/workflows/os-increment-plugin-versions.yml

View workflow job for this annotation

GitHub Actions / yaml-lint

3:1 [trailing-spaces] trailing spaces
on:
schedule:
- cron: 0 0 * * *
workflow_dispatch:
inputs:
logLevel:
description: Log level
required: true
default: warning
type: choice
options:
- info
- warning
- debug

Check failure on line 18 in .github/workflows/os-increment-plugin-versions.yml

View workflow job for this annotation

GitHub Actions / yaml-lint

18:1 [trailing-spaces] trailing spaces
jobs:
plugin-version-increment-sync:
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
entry:
## Adding the core repo OpenSearch for the label creation automation

Check warning on line 26 in .github/workflows/os-increment-plugin-versions.yml

View workflow job for this annotation

GitHub Actions / yaml-lint

26:14 [comments-indentation] comment not indented like content
- {repo: OpenSearch}
- {repo: alerting}
- {repo: anomaly-detection}
- {repo: asynchronous-search}
- {repo: common-utils}
- {repo: cross-cluster-replication}
- {repo: geospatial}
- {repo: index-management}
- {repo: job-scheduler}
- {repo: k-NN}
- {repo: neural-search}
- {repo: ml-commons}
- {repo: notifications, path: notifications}
- {repo: observability}
- {repo: performance-analyzer}
- {repo: performance-analyzer-rca}
- {repo: reporting}
- {repo: security}
- {repo: security-analytics}
- {repo: sql}
branch:
- '1.3'
- 2.x
- '2.8'
- main
- '2.9'
exclude:
- {entry: {repo: geospatial}, branch: '1.3'}
- {entry: {repo: neural-search}, branch: '1.3'}
- {entry: {repo: security-analytics}, branch: '1.3'}
- {entry: {repo: notifications, path: notifications}, branch: '1.3'}
steps:
- name: Check out OpenSearch repo
uses: actions/checkout@v3
with:
repository: opensearch-project/OpenSearch
ref: ${{ matrix.branch }}
- name: Fetch OpenSearch version
run: |
OPENSEARCH_VERSION=$(cat buildSrc/version.properties | grep opensearch | cut -d= -f2 | grep -oE '[0-9.]+')
echo "OPENSEARCH_VERSION_NUMBER=$OPENSEARCH_VERSION" >> $GITHUB_ENV
OPENSEARCH_VERSION=$OPENSEARCH_VERSION-SNAPSHOT
echo "OPENSEARCH_VERSION=$OPENSEARCH_VERSION" >> $GITHUB_ENV
- name: Check out plugin repo
if: ${{ matrix.entry.repo != 'OpenSearch' }}
uses: actions/checkout@v3
with:
repository: opensearch-project/${{ matrix.entry.repo }}
ref: ${{ matrix.branch }}
- name: Increment Version in ${{ matrix.entry.repo }}
if: ${{ matrix.entry.repo != 'OpenSearch' }}
run: |
echo "OpenSearch Core repo version on branch ${{ matrix.branch }} is ${{ env.OPENSEARCH_VERSION_NUMBER }}"
if [ ${{ matrix.entry.path }} ]; then
echo "The gradle path is ${{ matrix.entry.path }}"
cd ${{ matrix.entry.path }}
fi
./gradlew updateVersion -DnewVersion=${{ env.OPENSEARCH_VERSION }}
- 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 and Create label
id: check_create_label
uses: actions/github-script@v6
with:
github-token: ${{ steps.github_app_token.outputs.token }}
result-encoding: string
script: |
const labelName = "v${{ env.OPENSEARCH_VERSION_NUMBER }}";
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
if: ${{ matrix.entry.repo != 'OpenSearch' }}
id: cpr
uses: peter-evans/create-pull-request@v4
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.OPENSEARCH_VERSION }}

Check failure on line 136 in .github/workflows/os-increment-plugin-versions.yml

View workflow job for this annotation

GitHub Actions / yaml-lint

136:1 [trailing-spaces] trailing spaces
Signed-off-by: opensearch-ci-bot <[email protected]>
delete-branch: true
branch: create-pull-request/${{ env.OPENSEARCH_VERSION }}
title: '[AUTO] Increment version to ${{ env.OPENSEARCH_VERSION }}'
labels: |
v${{ env.OPENSEARCH_VERSION_NUMBER }}
body: |
- Incremented version to **${{ env.OPENSEARCH_VERSION }}**.
- name: Check outputs
run: |-
echo "Pull Request Number - ${{ steps.cpr.outputs.pull-request-number }}"
echo "Pull Request URL - ${{ steps.cpr.outputs.pull-request-url }}"

Check failure on line 149 in .github/workflows/os-increment-plugin-versions.yml

View workflow job for this annotation

GitHub Actions / yaml-lint

149:5 [new-line-at-end-of-file] no new line character at the end of file

Check failure on line 149 in .github/workflows/os-increment-plugin-versions.yml

View workflow job for this annotation

GitHub Actions / yaml-lint

149:1 [trailing-spaces] trailing spaces
15 changes: 10 additions & 5 deletions .github/workflows/osd-increment-plugin-versions.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ jobs:
fail-fast: false
matrix:
entry:
## Adding the core repo OpenSearch-Dashboards for the label creation automation

Check warning on line 25 in .github/workflows/osd-increment-plugin-versions.yml

View workflow job for this annotation

GitHub Actions / yaml-lint

25:10 [comments-indentation] comment not indented like content
- {repo: OpenSearch-Dashboards}
- {repo: dashboards-observability}
- {repo: dashboards-reporting}
- {repo: dashboards-visualizations, path: gantt-chart}
Expand Down Expand Up @@ -50,6 +52,7 @@ jobs:
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 }}
Expand All @@ -60,18 +63,19 @@ jobs:
with:
node-version-file: './OpenSearch-Dashboards/.nvmrc'
registry-url: 'https://registry.npmjs.org'
- name: Install Yarn
- 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: |
DASHBOARD_VERSION=$(node -p "require('./OpenSearch-Dashboards/package.json').version")
echo "DASHBOARD_VERSION=$DASHBOARD_VERSION" >> $GITHUB_ENV
cd OpenSearch-Dashboards/plugins/${{ matrix.entry.repo }}
if [ ${{ matrix.entry.path }} ]; then
yarn osd bootstrap
Expand All @@ -85,7 +89,7 @@ jobs:
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 "$DASHBOARD_VERSION" '.version = $DASHBOARD_VERSION' package.json > package-tmp.json
jq --arg DASHBOARD_VERSION "${{ env.DASHBOARD_VERSION }}" '.version = ${{ env.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
Expand Down Expand Up @@ -126,7 +130,7 @@ jobs:
repo: "${{ matrix.entry.repo }}",
name: labelName,
color: randomColor,
description: "Issues targeting release ${{labelName}}"
description: "Issues targeting release " + labelName
};
await github.rest.issues.createLabel(newLabel);
labelFound = true;
Expand All @@ -137,6 +141,7 @@ jobs:
console.log(labelFound);
return labelFound
- name: Create Pull Request
if: ${{ matrix.entry.repo != 'OpenSearch-Dashboards' }}
id: cpr
uses: peter-evans/create-pull-request@v5
with:
Expand Down

0 comments on commit abc3c52

Please sign in to comment.