Skip to content

Commit

Permalink
Update versions file automation (#4512)
Browse files Browse the repository at this point in the history
* Fix missing snapshots due to not fetched branches
* Improve PR description + add the version requirements to the
description/commit message
  • Loading branch information
rdner authored Apr 4, 2024
1 parent c923f2e commit 09b7410
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 5 deletions.
13 changes: 9 additions & 4 deletions .github/workflows/bump-agent-versions.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,10 @@ jobs:
steps:
- name: Checkout
uses: actions/checkout@v4
with:
# no depth limit
# so, we can generate snapshot versions based on release branches
fetch-depth: 0

- name: Set up Go
uses: actions/setup-go@v4
Expand All @@ -20,16 +24,17 @@ jobs:
- name: Set up branch
run: git checkout -b update-agent-versions-$GITHUB_RUN_ID

- name: Update the agent version file
- name: Install mage
uses: magefile/mage-action@v3
with:
version: v1.13.0
args: integration:updateVersions
install-only: true

- name: Check for file changes
- name: Update versions file
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
version_requirements=$(mage integration:updateVersions)
changes=$(git status -s -uno .agent-versions.json)
if [ -z "$changes" ]
then
Expand All @@ -46,7 +51,7 @@ jobs:
git config --global user.name 'apmmachine'
git config --global user.email '[email protected]'
git add ".agent-versions.json"
git commit -m "[$GITHUB_REF_NAME](automation) Update .agent-versions.json" -m "This file is used for picking agent versions in integration tests. It's content is based on the reponse from https://artifacts-api.elastic.co/v1/versions/"
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\`\`\`"
git push --set-upstream origin "update-agent-versions-$GITHUB_RUN_ID"
gh pr create \
--base "$GITHUB_REF_NAME" \
Expand Down
2 changes: 1 addition & 1 deletion magefile.go
Original file line number Diff line number Diff line change
Expand Up @@ -1612,7 +1612,7 @@ func (Integration) UpdateVersions(ctx context.Context) error {
SnapshotBranches: branches,
}
b, _ := json.MarshalIndent(reqs, "", " ")
fmt.Printf("Current version requirements: \n%s\n", b)
fmt.Println(string(b))

pvc := pv.NewProductVersionsClient()
sc := snapshots.NewSnapshotsClient()
Expand Down

0 comments on commit 09b7410

Please sign in to comment.