|
| 1 | +#!/bin/zsh -ex |
| 2 | + |
| 3 | +# Copyright The OpenTelemetry Authors |
| 4 | +# |
| 5 | +# Licensed under the Apache License, Version 2.0 (the "License"); |
| 6 | +# you may not use this file except in compliance with the License. |
| 7 | +# You may obtain a copy of the License at |
| 8 | +# |
| 9 | +# http://www.apache.org/licenses/LICENSE-2.0 |
| 10 | +# |
| 11 | +# Unless required by applicable law or agreed to in writing, software |
| 12 | +# distributed under the License is distributed on an "AS IS" BASIS, |
| 13 | +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 14 | +# See the License for the specific language governing permissions and |
| 15 | +# limitations under the License. |
| 16 | + |
| 17 | +git config user.name $GITHUB_ACTOR |
| 18 | +git config user.email $GITHUB_ACTOR@users.noreply.github.com |
| 19 | + |
| 20 | +PR_NAME=dependabot-prs/`date +'%Y-%m-%dT%H%M%S'` |
| 21 | +git checkout -b $PR_NAME |
| 22 | + |
| 23 | +IFS=$'\n' |
| 24 | +requests=($(gh pr list --search "author:app/dependabot" --json number,title --template '{{range .}}{{tablerow .title}}{{end}}')) |
| 25 | +message="" |
| 26 | +dirs=(`find . -type f -name "go.mod" -exec dirname {} \; | sort | egrep '^./'`) |
| 27 | + |
| 28 | +declare -A mods |
| 29 | + |
| 30 | +for line in $requests; do |
| 31 | + echo $line |
| 32 | + if [[ $line != Bump* ]]; then |
| 33 | + continue |
| 34 | + fi |
| 35 | + |
| 36 | + module=$(echo $line | cut -f 2 -d " ") |
| 37 | + if [[ $module == go.opentelemetry.io/otel* ]]; then |
| 38 | + continue |
| 39 | + fi |
| 40 | + version=$(echo $line | cut -f 6 -d " ") |
| 41 | + |
| 42 | + mods[$module]=$version |
| 43 | + message+=$line |
| 44 | + message+=$'\n' |
| 45 | +done |
| 46 | + |
| 47 | +for module version in ${(kv)mods}; do |
| 48 | + topdir=`pwd` |
| 49 | + for dir in $dirs; do |
| 50 | + echo "checking $dir" |
| 51 | + cd $dir && if grep -q "$module " go.mod; then go get "$module"@v"$version"; fi |
| 52 | + cd $topdir |
| 53 | + done |
| 54 | +done |
| 55 | + |
| 56 | +make go-mod-tidy |
| 57 | +make build |
| 58 | + |
| 59 | +git add go.sum go.mod |
| 60 | +git add "**/go.sum" "**/go.mod" |
| 61 | +git commit -m "dependabot updates `date` |
| 62 | +$message" |
| 63 | +git push origin $PR_NAME |
| 64 | + |
| 65 | +gh pr create --title "dependabot updates `date`" --body "$message" -l "Skip Changelog" |
0 commit comments