Skip to content

Commit

Permalink
task: automatically update atlas sdk go (#2392)
Browse files Browse the repository at this point in the history
Co-authored-by: Gustavo Bazan <[email protected]>
  • Loading branch information
wtrocki and gssbzn authored Oct 24, 2023
1 parent 200f5df commit 36fe46e
Show file tree
Hide file tree
Showing 3 changed files with 59 additions and 4 deletions.
35 changes: 35 additions & 0 deletions .github/workflows/autoupdate-sdk.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
name: Update SDK
on:
schedule:
- cron: 30 8 * * TUE
workflow_dispatch:

jobs:
update-sdk:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- uses: actions/setup-go@v4
with:
go-version-file: 'go.mod'
- name: update
run: |
go install github.com/icholy/gomajor@latest
make update-atlas-sdk
- name: Verify Changed files
uses: tj-actions/verify-changed-files@78dc414e915e0664bcf0d2b42465a86cd47bcc3c
id: verify-changed-files
with:
files: |
./internal/**/*
- uses: peter-evans/create-pull-request@v5
if: steps.verify-changed-files.outputs.files_changed == 'true'

with:
title: "APIBot: Atlas GO SDK update"
commit-message: "build(deps): bump go.mongodb.org/atlas-sdk"
delete-branch: true
branch: atlas-sdk-update
body: |
Automatic update for MongoDB Atlas Go Client SDK
5 changes: 1 addition & 4 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -193,10 +193,7 @@ check-library-owners: ## Check that all the dependencies in go.mod has a owner i

.PHONY: update-atlas-sdk
update-atlas-sdk: ## Update the atlas-sdk dependency
@echo "==> Updating SDK to latest major version"
gomajor get go.mongodb.org/atlas-sdk/v20230201001@latest
go mod tidy
@echo "==> Done, remember to update build/ci/library_owners.json"
./scripts/update-sdk.sh

.PHONY: help
.DEFAULT_GOAL := help
Expand Down
23 changes: 23 additions & 0 deletions scripts/update-sdk.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
#!/usr/bin/env bash

# Copyright 2023 MongoDB Inc
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

set -euo pipefail

LATEST_SDK_RELEASE=$(curl -sSfL -X GET https://api.github.com/repos/mongodb/atlas-sdk-go/releases/latest | jq -r '.tag_name' | cut -d '.' -f 1)
echo "==> Updating SDK to latest major version $LATEST_SDK_RELEASE"
gomajor get "go.mongodb.org/atlas-sdk/$LATEST_SDK_RELEASE@latest"
go mod tidy
echo "Done, remember to update build/ci/library_owners.json"

0 comments on commit 36fe46e

Please sign in to comment.