|
1 | 1 | #!/bin/bash
|
2 | 2 | set -e
|
3 | 3 |
|
| 4 | +package_version=$(mage integration:updatePackageVersion) |
4 | 5 | version_requirements=$(mage integration:updateVersions)
|
5 |
| -changes=$(git status -s -uno .agent-versions.json) |
| 6 | +changes=$(git status -s -uno .agent-versions.json .package-version) |
6 | 7 | if [ -z "$changes" ]
|
7 | 8 | then
|
8 |
| - echo "The versions file didn't change, skipping..." |
| 9 | + echo "The version files didn't change, skipping..." |
9 | 10 | else
|
10 |
| - echo "The versions file changed" |
| 11 | + echo "The version file(s) changed" |
| 12 | + git diff -p |
11 | 13 | open=$(gh pr list --repo "$GITHUB_REPOSITORY" --label="update-versions" --limit 1 --state open --base "$GITHUB_REF_NAME")
|
12 | 14 | if [ -n "$open" ]
|
13 | 15 | then
|
14 | 16 | echo "Another PR for $GITHUB_REF_NAME is in review, skipping..."
|
15 | 17 | exit 0
|
16 | 18 | fi
|
17 |
| - git diff -p |
18 |
| - git add ".agent-versions.json" |
| 19 | + git add .agent-versions.json .package-version |
19 | 20 |
|
20 | 21 | nl=$'\n' # otherwise the new line character is not recognized properly
|
21 |
| - commit_desc="This file is used for picking agent versions in integration tests.${nl}${nl}The file's 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}\`\`\`json${nl}${version_requirements}${nl}\`\`\`" |
| 22 | + commit_desc="These files are used for picking agent versions in 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}\`\`\`" |
22 | 23 |
|
23 |
| - git commit -m "[$GITHUB_REF_NAME][Automation] Update .agent-versions.json" -m "$commit_desc" |
| 24 | + git commit -m "[$GITHUB_REF_NAME][Automation] Update versions" -m "$commit_desc" |
24 | 25 | git push --set-upstream origin "update-agent-versions-$GITHUB_RUN_ID"
|
25 | 26 | pr=$(gh pr create \
|
26 | 27 | --base "$GITHUB_REF_NAME" \
|
|
33 | 34 | --label 'backport-skip' \
|
34 | 35 | --repo $GITHUB_REPOSITORY)
|
35 | 36 | echo "pr=$pr" >> "$GITHUB_OUTPUT" # set the step output for Slack notifications
|
36 |
| - echo "Created a PR with the file update: $pr" |
| 37 | + echo "Created a PR with the an update: $pr" |
37 | 38 | fi
|
0 commit comments