|
| 1 | +name: 'Update Kibana dependencies - Prepare changes' |
| 2 | + |
| 3 | +on: |
| 4 | + workflow_dispatch: |
| 5 | + inputs: |
| 6 | + dependencies: |
| 7 | + description: JSON-serialized map of dependencies to update |
| 8 | + type: string |
| 9 | + required: true |
| 10 | + workflow_call: |
| 11 | + inputs: |
| 12 | + dependencies: |
| 13 | + description: JSON-serialized map of dependencies to update |
| 14 | + type: string |
| 15 | + required: true |
| 16 | + outputs: |
| 17 | + branch_name: |
| 18 | + description: Name of the branch created in the elastic/eui-kibana repository |
| 19 | + value: ${{ jobs.update.outputs.branch_name }} |
| 20 | + |
| 21 | +permissions: |
| 22 | + id-token: write |
| 23 | + |
| 24 | +jobs: |
| 25 | + update: |
| 26 | + name: Prepare changes |
| 27 | + runs-on: ubuntu-latest |
| 28 | + outputs: |
| 29 | + branch_name: ${{ steps.git_branch.outputs.BRANCH_NAME }} |
| 30 | + steps: |
| 31 | + - name: Verify dependencies input |
| 32 | + env: |
| 33 | + DEPENDENCIES: ${{ inputs.dependencies }} |
| 34 | + # language=bash |
| 35 | + run: | |
| 36 | + num_deps=$(jq 'map(select(has("name") and has("version"))) | length' <<< "$DEPENDENCIES") || exit_code=$? |
| 37 | + if [[ "$exit_code" -ne 0 ]]; then |
| 38 | + echo "::error::Invalid dependencies input" |
| 39 | + exit 2 |
| 40 | + elif [[ "$num_deps" -eq 0 ]]; then |
| 41 | + echo "::warning::No dependencies to update" |
| 42 | + exit 1 |
| 43 | + else |
| 44 | + echo "$num_deps dependencies to update" |
| 45 | + fi |
| 46 | + - name: Checkout the upstream elastic/kibana repository |
| 47 | + uses: actions/checkout@v6 |
| 48 | + with: |
| 49 | + repository: elastic/kibana |
| 50 | + fetch-depth: 1 |
| 51 | + persist-credentials: false # We use different credentials for other git operations |
| 52 | + - name: Setup Node |
| 53 | + uses: actions/setup-node@v6 |
| 54 | + with: |
| 55 | + node-version-file: .nvmrc |
| 56 | + package-manager-cache: false # Don't cache anything as it's a different repository |
| 57 | + - name: Fetch ephemeral GitHub token |
| 58 | + id: fetch_ephemeral_token |
| 59 | + uses: elastic/ci-gh-actions/fetch-github-token@v1.5.0 |
| 60 | + with: |
| 61 | + vault-instance: ci-prod |
| 62 | + vault-role: token-policy-4fabc48bd03f |
| 63 | + - name: Configure git |
| 64 | + env: |
| 65 | + GH_TOKEN: ${{ steps.fetch_ephemeral_token.outputs.token }} |
| 66 | + # language=bash |
| 67 | + run: | |
| 68 | + gh auth setup-git |
| 69 | + git config --global user.name 'github-actions[bot]' |
| 70 | + git config --global user.email '41898282+github-actions[bot]@users.noreply.github.com' |
| 71 | + git remote add fork https://github.com/elastic/eui-kibana.git |
| 72 | + - name: Create new branch |
| 73 | + id: git_branch |
| 74 | + # language=bash |
| 75 | + run: | |
| 76 | + branch_name="update-dependencies/$(date +%s)" |
| 77 | + git checkout -b "$branch_name" |
| 78 | + echo "BRANCH_NAME=$branch_name" >> "$GITHUB_OUTPUT" |
| 79 | + echo "::debug::Created branch '$branch_name'" |
| 80 | + - name: Update dependency versions |
| 81 | + env: |
| 82 | + DEPENDENCIES: ${{ inputs.dependencies }} |
| 83 | + # language=bash |
| 84 | + run: | |
| 85 | + jq -j '.[] | .name, "\u0000", .version, "\u0000"' <<< "$DEPENDENCIES" | |
| 86 | + xargs -0 -n 2 bash -c ' |
| 87 | + pkg="$0" |
| 88 | + ver="$1" |
| 89 | + if [[ $(npm pkg get "devDependencies.$pkg") != "{}" ]]; then |
| 90 | + npm pkg set "devDependencies.$pkg=$ver" |
| 91 | + elif [[ $(npm pkg get "dependencies.$pkg") != "{}" ]]; then |
| 92 | + npm pkg set "dependencies.$pkg=$ver" |
| 93 | + else |
| 94 | + echo "::warning::Skipping $pkg: Not found in either dependencies or devDependencies"; |
| 95 | + fi' |
| 96 | + - name: Run Kibana bootstrap scripts |
| 97 | + # language=bash |
| 98 | + run: yarn kbn bootstrap |
| 99 | + - name: Commit changed files |
| 100 | + # language=bash |
| 101 | + run: | |
| 102 | + git add package.json yarn.lock src/platform/packages/private/kbn-ui-shared-deps-npm/version_dependencies.txt |
| 103 | + git commit -m "chore: update dependencies" |
| 104 | + - name: Push branch to elastic/eui-kibana |
| 105 | + env: |
| 106 | + GH_TOKEN: ${{ steps.fetch_ephemeral_token.outputs.token }} |
| 107 | + BRANCH_NAME: ${{ steps.git_branch.outputs.BRANCH_NAME }} |
| 108 | + # language=bash |
| 109 | + run: git push -u fork "$BRANCH_NAME" |
0 commit comments