Skip to content

ci: automatically update OTel components #8288

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
File renamed without changes.
75 changes: 75 additions & 0 deletions .ci/updatecli/update-otel.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
---
name: Update OTel
pipelineid: 'updatecli-update-otel-{{ requiredEnv "BRANCH_NAME" }}'

scms:
default:
kind: github
spec:
user: '{{ requiredEnv "GITHUB_ACTOR" }}'
username: '{{ requiredEnv "GITHUB_ACTOR" }}'
owner: '{{ .scm.owner }}'
repository: '{{ .scm.repository }}'
token: '{{ requiredEnv "GITHUB_TOKEN" }}'
branch: '{{ requiredEnv "BRANCH_NAME" }}'
commitusingapi: true

sources:
current_core_beta:
kind: golang/gomod
name: Get current OTel Collector core beta version in go.mod
spec:
module: go.opentelemetry.io/collector/receiver/otlpreceiver
latest_core_beta:
kind: golang/module
name: Get latest OTel Collector core beta version
spec:
module: go.opentelemetry.io/collector/receiver/otlpreceiver
latest_core_stable:
kind: golang/module
name: Get latest OTel Collector core stable version
spec:
module: go.opentelemetry.io/collector/component
current_contrib:
kind: golang/gomod
name: Get current OTel Collector contrib version in go.mod
spec:
module: github.com/open-telemetry/opentelemetry-collector-contrib/connector/routingconnector
latest_contrib:
kind: golang/module
name: Get latest OTel Collector contrib version
spec:
module: github.com/open-telemetry/opentelemetry-collector-contrib/connector/routingconnector

conditions:
is-new-version:
name: Succeeds if the latest core or contrib OTel Collector version is different than the one in go.mod
kind: shell
disablesourceinput: true
scmid: default
spec:
command: '[ {{ source "current_core_beta" }} != {{ source "latest_core_beta" }} ] || [ {{ source "current_contrib" }} != {{ source "latest_contrib" }} ]'

targets:
update-otel:
name: Update OTel version
kind: shell
disablesourceinput: true
spec:
command: .ci/scripts/update-otel.sh {{ source "latest_core_beta" }} {{ source "latest_core_stable" }} {{ source "latest_contrib" }}

actions:
default:
title: '[{{ requiredEnv "BRANCH_NAME" }}][Automation] Update OTel to {{ source "latest_contrib" }}'
kind: github/pullrequest
scmid: default
spec:
automerge: false
labels:
- automation
- skip-changelog
- "Team:Elastic-Agent-Control-Plane"
description: |
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" }})
and contrib [{{ source "latest_contrib" }}](https://github.com/open-telemetry/opentelemetry-collector-contrib/releases/{{ source "latest_contrib" }})
on branch `{{ requiredEnv "BRANCH_NAME" }}`.'
63 changes: 63 additions & 0 deletions .github/workflows/bump-otel-version.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
name: bump-otel-version

on:
workflow_dispatch:
schedule:
- cron: '24 5 * * 1-5'

permissions:
contents: read

env:
JOB_URL: "${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}"

jobs:
filter:
runs-on: ubuntu-latest
timeout-minutes: 1
outputs:
matrix: ${{ steps.generator.outputs.matrix }}
permissions:
contents: read
steps:
- id: generator
uses: elastic/oblt-actions/elastic/active-branches@v1
with:
# Only run on `main` and `8.19` branches
exclude-branches: "7.17,8.17,8.18,9.0"
filter-branches: true

update-otel:
permissions:
contents: write
pull-requests: write
needs:
- filter
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix: ${{ fromJson(needs.filter.outputs.matrix) }}
steps:
- uses: actions/checkout@v4
with:
ref: ${{ matrix.branch }}

- name: Set up Go
uses: actions/setup-go@v5
with:
go-version-file: 'go.mod'

- name: Run Updatecli in Apply mode
uses: elastic/oblt-actions/updatecli/run@v1
with:
command: apply --config .ci/updatecli/update-otel.yml --values .ci/updatecli/values.d/scm.yml
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
BRANCH_NAME: ${{ matrix.branch }}

- if: ${{ failure() }}
uses: elastic/oblt-actions/slack/send@v1
with:
bot-token: ${{ secrets.SLACK_BOT_TOKEN }}
channel-id: "#ingest-notifications"
message: ":traffic_cone: updatecli failed for `${{ github.repository }}@${{ github.ref_name }}`, `@agent-team` please look what's going on <${{ env.JOB_URL }}|here>"