Skip to content

Commit 3dab14d

Browse files
authored
Extract the bump-agent-versions workflow into a script (#4521)
When the script is in the multiline YAML it breaks the desired formatting of the commit message. Also editing this script separately is a better developer experience.
1 parent 09b7410 commit 3dab14d

File tree

2 files changed

+33
-30
lines changed

2 files changed

+33
-30
lines changed
+32
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
#!/bin/bash
2+
set -e
3+
4+
version_requirements=$(mage integration:updateVersions)
5+
changes=$(git status -s -uno .agent-versions.json)
6+
if [ -z "$changes" ]
7+
then
8+
echo "The versions file didn't change, skipping..."
9+
else
10+
echo "The versions file changed"
11+
open=$(gh pr list --repo "$GITHUB_REPOSITORY" --label="update-versions" --limit 1 --state open --base "$GITHUB_REF_NAME")
12+
if [ -n "$open" ]
13+
then
14+
echo "Another PR for $GITHUB_REF_NAME is in review, skipping..."
15+
exit 0
16+
fi
17+
git diff -p
18+
git config --global user.name 'apmmachine'
19+
git config --global user.email 'apmmachine@users.noreply.github.com'
20+
git add ".agent-versions.json"
21+
git commit -m "[$GITHUB_REF_NAME](automation) Update .agent-versions.json" -m "This file is used for picking agent versions in integration tests.\n\nThe file's content is based on responses from https://www.elastic.co/api/product_versions and https://snapshots.elastic.co\n\nThe current update is generated based on the following requirements:\n\`\`\`json\n$version_requirements\n\`\`\`"
22+
git push --set-upstream origin "update-agent-versions-$GITHUB_RUN_ID"
23+
gh pr create \
24+
--base "$GITHUB_REF_NAME" \
25+
--fill-first \
26+
--head "update-agent-versions-$GITHUB_RUN_ID" \
27+
--label 'Team:Elastic-Agent' \
28+
--label 'update-versions' \
29+
--label 'skip-changelog' \
30+
--label 'backport-skip' \
31+
--repo $GITHUB_REPOSITORY
32+
fi

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

+1-30
Original file line numberDiff line numberDiff line change
@@ -33,33 +33,4 @@ jobs:
3333
- name: Update versions file
3434
env:
3535
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
36-
run: |
37-
version_requirements=$(mage integration:updateVersions)
38-
changes=$(git status -s -uno .agent-versions.json)
39-
if [ -z "$changes" ]
40-
then
41-
echo "The versions file didn't change, skipping..."
42-
else
43-
echo "The versions file changed"
44-
open=$(gh pr list --repo "$GITHUB_REPOSITORY" --label="update-versions" --limit 1 --state open --base "$GITHUB_REF_NAME")
45-
if [ -n "$open" ]
46-
then
47-
echo "Another PR for $GITHUB_REF_NAME is in review, skipping..."
48-
exit 0
49-
fi
50-
git diff -p
51-
git config --global user.name 'apmmachine'
52-
git config --global user.email 'apmmachine@users.noreply.github.com'
53-
git add ".agent-versions.json"
54-
git commit -m "[$GITHUB_REF_NAME](automation) Update .agent-versions.json" -m "This file is used for picking agent versions in integration tests.\n\nThe file's content is based on responses from https://www.elastic.co/api/product_versions and https://snapshots.elastic.co\n\nThe current update is generated based on the following requirements:\n\`\`\`json\n$version_requirements\n\`\`\`"
55-
git push --set-upstream origin "update-agent-versions-$GITHUB_RUN_ID"
56-
gh pr create \
57-
--base "$GITHUB_REF_NAME" \
58-
--fill-first \
59-
--head "update-agent-versions-$GITHUB_RUN_ID" \
60-
--label 'Team:Elastic-Agent' \
61-
--label 'update-versions' \
62-
--label 'skip-changelog' \
63-
--label 'backport-skip' \
64-
--repo $GITHUB_REPOSITORY
65-
fi
36+
run: ./.github/workflows/bump-agent-versions.sh

0 commit comments

Comments
 (0)