Skip to content

Commit e39f08b

Browse files
mergify[bot]rdner
andauthored
Add support for running version updates on multiple branches (#6310) (#6311)
Now the script can be run on a matrix for multiple release branches. (cherry picked from commit 275c748) Co-authored-by: Denis <denis.rechkunov@elastic.co>
1 parent bb32f59 commit e39f08b

File tree

1 file changed

+10
-7
lines changed

1 file changed

+10
-7
lines changed

.github/workflows/bump-agent-versions.sh

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -8,28 +8,31 @@ if [ -z "$changes" ]
88
then
99
echo "The version files didn't change, skipping..."
1010
else
11+
# because this script is running on the matrix, we need to fetch the current branch on every run
12+
current_ref=$(git rev-parse --abbrev-ref HEAD)
1113
echo "The version file(s) changed"
1214
git diff -p
13-
open=$(gh pr list --repo "$GITHUB_REPOSITORY" --label="update-versions" --limit 1 --state open --base "$GITHUB_REF_NAME")
15+
open=$(gh pr list --repo "$GITHUB_REPOSITORY" --label="update-versions" --limit 1 --state open --base "$current_ref")
1416
if [ -n "$open" ]
1517
then
16-
echo "Another PR for $GITHUB_REF_NAME is in review, skipping..."
18+
echo "Another PR for $current_ref is in review, skipping..."
1719
exit 0
1820
fi
21+
pr_branch="$current_ref-update-agent-versions-$GITHUB_RUN_ID"
1922
# the mage target above requires to be on a release branch
2023
# so, the new branch should not be created before the target is run
21-
git checkout -b update-agent-versions-$GITHUB_RUN_ID
24+
git checkout -b "$pr_branch"
2225
git add testing/integration/testdata/.upgrade-test-agent-versions.yml .package-version
2326

2427
nl=$'\n' # otherwise the new line character is not recognized properly
2528
commit_desc="These files are used for picking the starting (pre-upgrade) or ending (post-upgrade) agent versions in upgrade integration tests.${nl}${nl}The content is based on responses from https://www.elastic.co/api/product_versions and https://snapshots.elastic.co${nl}${nl}The current update is generated based on the following requirements:${nl}${nl}Package version: ${package_version}${nl}${nl}\`\`\`json${nl}${version_requirements}${nl}\`\`\`"
2629

27-
git commit -m "[$GITHUB_REF_NAME][Automation] Update versions" -m "$commit_desc"
28-
git push --set-upstream origin "update-agent-versions-$GITHUB_RUN_ID"
30+
git commit -m "[$current_ref][Automation] Update versions" -m "$commit_desc"
31+
git push --set-upstream origin "$pr_branch"
2932
pr=$(gh pr create \
30-
--base "$GITHUB_REF_NAME" \
33+
--base "$current_ref" \
3134
--fill-first \
32-
--head "update-agent-versions-$GITHUB_RUN_ID" \
35+
--head "$pr_branch" \
3336
--label 'Team:Elastic-Agent' \
3437
--label 'Team:Elastic-Agent-Control-Plane' \
3538
--label 'update-versions' \

0 commit comments

Comments
 (0)