Skip to content

Commit 44be80a

Browse files
andrzej-stencelmichel-laterman
authored andcommitted
ci: automatically update OTel components (elastic#8288)
* automatically update OTel components Creates a new GitHub Actions workflow that runs Updatecli daily to check if a new version of OTel components is available. If it is, Updatecli runs the `update-otel.sh` script and creates a new PR with the changes. These automated updates are currently configured to run for the `main` branch and for the `8.19` branch. * restore `go mod tidy` in `update-otel.sh` Forward-porting elastic#8326 * fix: install changelog tool if missing * fix: add missing env vars to Updatecli target config * define branch matrix as a static list * run Updatecli script from the main branch
1 parent 0efcf96 commit 44be80a

File tree

3 files changed

+129
-0
lines changed

3 files changed

+129
-0
lines changed

.ci/scripts/otel-update.sh renamed to .ci/scripts/update-otel.sh

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,12 @@ mage otel:readme
4444

4545
echo "=> Creating changelog fragment"
4646
changelog_fragment_name="update-otel-components-to-$next_contrib"
47+
if command -v elastic-agent-changelog-tool &>/dev/null; then
48+
echo "=> Using elastic-agent-changelog-tool to create changelog fragment"
49+
else
50+
echo "=> elastic-agent-changelog-tool not found, installing it"
51+
go install github.com/elastic/elastic-agent-changelog-tool@latest
52+
fi
4753
elastic-agent-changelog-tool new "$changelog_fragment_name"
4854
sed -i.bak "s/^kind:.*$/kind: enhancement/" ./changelog/fragments/*-"${changelog_fragment_name}".yaml
4955
sed -i.bak "s/^summary:.*$/summary: Update OTel components to ${next_contrib}/" ./changelog/fragments/*-"${changelog_fragment_name}".yaml

.ci/updatecli/update-otel.yml

Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
---
2+
name: Update OTel
3+
pipelineid: 'updatecli-update-otel-{{ requiredEnv "BRANCH_NAME" }}'
4+
5+
scms:
6+
default:
7+
kind: github
8+
spec:
9+
user: '{{ requiredEnv "GITHUB_ACTOR" }}'
10+
username: '{{ requiredEnv "GITHUB_ACTOR" }}'
11+
owner: '{{ .scm.owner }}'
12+
repository: '{{ .scm.repository }}'
13+
token: '{{ requiredEnv "GITHUB_TOKEN" }}'
14+
branch: '{{ requiredEnv "BRANCH_NAME" }}'
15+
commitusingapi: true
16+
17+
sources:
18+
current_core_beta:
19+
kind: golang/gomod
20+
name: Get current OTel Collector core beta version in go.mod
21+
spec:
22+
module: go.opentelemetry.io/collector/receiver/otlpreceiver
23+
latest_core_beta:
24+
kind: golang/module
25+
name: Get latest OTel Collector core beta version
26+
spec:
27+
module: go.opentelemetry.io/collector/receiver/otlpreceiver
28+
latest_core_stable:
29+
kind: golang/module
30+
name: Get latest OTel Collector core stable version
31+
spec:
32+
module: go.opentelemetry.io/collector/component
33+
current_contrib:
34+
kind: golang/gomod
35+
name: Get current OTel Collector contrib version in go.mod
36+
spec:
37+
module: github.com/open-telemetry/opentelemetry-collector-contrib/connector/routingconnector
38+
latest_contrib:
39+
kind: golang/module
40+
name: Get latest OTel Collector contrib version
41+
spec:
42+
module: github.com/open-telemetry/opentelemetry-collector-contrib/connector/routingconnector
43+
44+
conditions:
45+
is-new-version:
46+
name: Succeeds if the latest core or contrib OTel Collector version is different than the one in go.mod
47+
kind: shell
48+
disablesourceinput: true
49+
scmid: default
50+
spec:
51+
command: '[ {{ source "current_core_beta" }} != {{ source "latest_core_beta" }} ] || [ {{ source "current_contrib" }} != {{ source "latest_contrib" }} ]'
52+
53+
targets:
54+
update-otel:
55+
name: Update OTel version
56+
kind: shell
57+
disablesourceinput: true
58+
spec:
59+
command: .ci/scripts/update-otel.sh {{ source "latest_core_beta" }} {{ source "latest_core_stable" }} {{ source "latest_contrib" }}
60+
environments:
61+
- name: PATH
62+
- name: HOME
63+
64+
actions:
65+
default:
66+
title: '[{{ requiredEnv "BRANCH_NAME" }}][Automation] Update OTel to {{ source "latest_contrib" }}'
67+
kind: github/pullrequest
68+
scmid: default
69+
spec:
70+
automerge: false
71+
labels:
72+
- automation
73+
- skip-changelog
74+
- "Team:Elastic-Agent-Control-Plane"
75+
description: |
76+
Updates OTel components to core [{{ source "latest_core_stable" }}/{{ source "latest_core_beta" }}](https://github.com/open-telemetry/opentelemetry-collector/releases/{{ source "latest_core_beta" }})
77+
and contrib [{{ source "latest_contrib" }}](https://github.com/open-telemetry/opentelemetry-collector-contrib/releases/{{ source "latest_contrib" }})
78+
on branch `{{ requiredEnv "BRANCH_NAME" }}`.'
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
name: bump-otel-version
2+
3+
on:
4+
workflow_dispatch:
5+
schedule:
6+
- cron: '24 5 * * 1-5'
7+
8+
permissions:
9+
contents: read
10+
11+
env:
12+
JOB_URL: "${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}"
13+
14+
jobs:
15+
update-otel:
16+
permissions:
17+
contents: write
18+
pull-requests: write
19+
runs-on: ubuntu-latest
20+
strategy:
21+
fail-fast: false
22+
matrix:
23+
branch: ["main", "8.19"]
24+
steps:
25+
- uses: actions/checkout@v4
26+
27+
- name: Set up Go
28+
uses: actions/setup-go@v5
29+
with:
30+
go-version-file: 'go.mod'
31+
32+
- name: Run Updatecli in Apply mode
33+
uses: elastic/oblt-actions/updatecli/run@v1
34+
with:
35+
command: apply --config .ci/updatecli/update-otel.yml --values .ci/updatecli/values.d/scm.yml
36+
env:
37+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
38+
BRANCH_NAME: ${{ matrix.branch }}
39+
40+
- if: ${{ failure() }}
41+
uses: elastic/oblt-actions/slack/send@v1
42+
with:
43+
bot-token: ${{ secrets.SLACK_BOT_TOKEN }}
44+
channel-id: "#ingest-notifications"
45+
message: ":traffic_cone: updatecli failed for `${{ github.repository }}@${{ github.ref_name }}`, `@agent-team` please look what's going on <${{ env.JOB_URL }}|here>"

0 commit comments

Comments
 (0)