Skip to content

Commit eacbfa0

Browse files
Add update-javaagent gitlab job (#3305)
1 parent 14e2319 commit eacbfa0

File tree

2 files changed

+65
-0
lines changed

2 files changed

+65
-0
lines changed

.gitlab-ci.yml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -144,6 +144,16 @@ update-openjdk:
144144
- .gitlab/install-gh-cli.sh
145145
- .gitlab/update-openjdk.sh
146146

147+
update-javaagent:
148+
only:
149+
- schedules
150+
stage: update-deps
151+
needs: []
152+
dependencies: []
153+
script:
154+
- .gitlab/install-gh-cli.sh
155+
- .gitlab/update-javaagent.sh
156+
147157
tidy-dependabot-pr:
148158
rules:
149159
- if: $CI_COMMIT_BRANCH =~ /^dependabot\/go_modules\/.*/ && $CI_COMMIT_AUTHOR =~ /^dependabot.*/

.gitlab/update-javaagent.sh

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
#!/usr/bin/env bash
2+
set -euo pipefail
3+
4+
# NOTE: this script is meant to be run on the GitLab CI, it depends on GitLab CI variables
5+
# Based on https://github.com/signalfx/splunk-otel-java/blob/c9134906c84e9a32a974dec4b380453fe1757410/scripts/propagate-version.sh
6+
7+
SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
8+
9+
# shellcheck source-path=SCRIPTDIR
10+
source "${SCRIPT_DIR}/common.sh"
11+
12+
ROOT_DIR="${SCRIPT_DIR}/../"
13+
cd "${ROOT_DIR}"
14+
15+
create_collector_pr() {
16+
local repo="signalfx/splunk-otel-collector"
17+
local repo_url="https://srv-gh-o11y-gdi:${GITHUB_TOKEN}@github.com/${repo}.git"
18+
local branch="create-pull-request/update-javaagent"
19+
local message="Update splunk-otel-javaagent to latest"
20+
21+
echo ">>> Cloning the $repo repository ..."
22+
git clone "$repo_url" collector-mirror
23+
cd collector-mirror
24+
25+
setup_branch "$branch" "$repo_url"
26+
27+
echo ">>> Getting latest splunk-otel-javaagent release ..."
28+
tag="$( gh release view --repo "https://github.com/signalfx/splunk-otel-java" --json tagName --jq 'select(.isDraft|not and .isPrelease|not) | .tagName' )"
29+
if [[ -n "$tag" ]]; then
30+
echo ">>> Updating splunk-otel-javaagent version to $tag ..."
31+
echo "$tag" > instrumentation/packaging/java-agent-release.txt
32+
else
33+
echo "ERROR: Failed to get latest release tag from https://github.com/signalfx/splunk-otel-java !" >&2
34+
exit 1
35+
fi
36+
37+
# Only create the PR if there are changes
38+
if ! git diff --exit-code >/dev/null 2>&1; then
39+
git commit -S -am "$message"
40+
git push -f "$repo_url" "$branch"
41+
echo ">>> Creating the PR ..."
42+
gh pr create \
43+
--draft \
44+
--repo "$repo" \
45+
--title "$message" \
46+
--body "$message" \
47+
--base main \
48+
--head "$branch"
49+
fi
50+
}
51+
52+
setup_gpg
53+
import_gpg_secret_key "$GITHUB_BOT_GPG_KEY"
54+
setup_git
55+
create_collector_pr

0 commit comments

Comments
 (0)