forked from opensearch-project/opensearch-build
-
Notifications
You must be signed in to change notification settings - Fork 0
196 lines (193 loc) · 8.09 KB
/
osd-increment-plugin-versions.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
---
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 }}"