forked from elastic/eui
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathupdate_kibana_dependencies__prepare_changes.yml
More file actions
109 lines (106 loc) · 3.94 KB
/
update_kibana_dependencies__prepare_changes.yml
File metadata and controls
109 lines (106 loc) · 3.94 KB
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
name: 'Update Kibana dependencies - Prepare changes'
on:
workflow_dispatch:
inputs:
dependencies:
description: JSON-serialized map of dependencies to update
type: string
required: true
workflow_call:
inputs:
dependencies:
description: JSON-serialized map of dependencies to update
type: string
required: true
outputs:
branch_name:
description: Name of the branch created in the elastic/eui-kibana repository
value: ${{ jobs.update.outputs.branch_name }}
permissions:
id-token: write
jobs:
update:
name: Prepare changes
runs-on: ubuntu-latest
outputs:
branch_name: ${{ steps.git_branch.outputs.BRANCH_NAME }}
steps:
- name: Verify dependencies input
env:
DEPENDENCIES: ${{ inputs.dependencies }}
# language=bash
run: |
num_deps=$(jq 'map(select(has("name") and has("version"))) | length' <<< "$DEPENDENCIES") || exit_code=$?
if [[ "$exit_code" -ne 0 ]]; then
echo "::error::Invalid dependencies input"
exit 2
elif [[ "$num_deps" -eq 0 ]]; then
echo "::warning::No dependencies to update"
exit 1
else
echo "$num_deps dependencies to update"
fi
- name: Checkout the upstream elastic/kibana repository
uses: actions/checkout@v6
with:
repository: elastic/kibana
fetch-depth: 1
persist-credentials: false # We use different credentials for other git operations
- name: Setup Node
uses: actions/setup-node@v6
with:
node-version-file: .nvmrc
package-manager-cache: false # Don't cache anything as it's a different repository
- name: Fetch ephemeral GitHub token
id: fetch_ephemeral_token
uses: elastic/ci-gh-actions/fetch-github-token@v1.5.0
with:
vault-instance: ci-prod
vault-role: token-policy-4fabc48bd03f
- name: Configure git
env:
GH_TOKEN: ${{ steps.fetch_ephemeral_token.outputs.token }}
# language=bash
run: |
gh auth setup-git
git config --global user.name 'github-actions[bot]'
git config --global user.email '41898282+github-actions[bot]@users.noreply.github.com'
git remote add fork https://github.com/elastic/eui-kibana.git
- name: Create new branch
id: git_branch
# language=bash
run: |
branch_name="update-dependencies/$(date +%s)"
git checkout -b "$branch_name"
echo "BRANCH_NAME=$branch_name" >> "$GITHUB_OUTPUT"
echo "::debug::Created branch '$branch_name'"
- name: Update dependency versions
env:
DEPENDENCIES: ${{ inputs.dependencies }}
# language=bash
run: |
jq -j '.[] | .name, "\u0000", .version, "\u0000"' <<< "$DEPENDENCIES" |
xargs -0 -n 2 bash -c '
pkg="$0"
ver="$1"
if [[ $(npm pkg get "devDependencies.$pkg") != "{}" ]]; then
npm pkg set "devDependencies.$pkg=$ver"
elif [[ $(npm pkg get "dependencies.$pkg") != "{}" ]]; then
npm pkg set "dependencies.$pkg=$ver"
else
echo "::warning::Skipping $pkg: Not found in either dependencies or devDependencies";
fi'
- name: Run Kibana bootstrap scripts
# language=bash
run: yarn kbn bootstrap
- name: Commit changed files
# language=bash
run: |
git add package.json yarn.lock src/platform/packages/private/kbn-ui-shared-deps-npm/version_dependencies.txt
git commit -m "chore: update dependencies"
- name: Push branch to elastic/eui-kibana
env:
GH_TOKEN: ${{ steps.fetch_ephemeral_token.outputs.token }}
BRANCH_NAME: ${{ steps.git_branch.outputs.BRANCH_NAME }}
# language=bash
run: git push -u fork "$BRANCH_NAME"