mirror of
https://github.com/open-telemetry/opentelemetry-go.git
synced 2025-01-10 00:29:12 +02:00
Add workflow to automate bundling dependabot PRs (#2997)
Signed-off-by: Anthony J Mirabella <a9@aneurysm9.com>
This commit is contained in:
parent
ac0221e3a3
commit
eb9e0583f7
18
.github/workflows/create-dependabot-pr.yml
vendored
Normal file
18
.github/workflows/create-dependabot-pr.yml
vendored
Normal file
@ -0,0 +1,18 @@
|
||||
name: dependabot-pr
|
||||
|
||||
on:
|
||||
workflow_dispatch:
|
||||
|
||||
jobs:
|
||||
create-pr:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
|
||||
- name: Install zsh
|
||||
run: sudo apt-get update; sudo apt-get install zsh
|
||||
|
||||
- name: Run dependabot-pr.sh
|
||||
run: ./.github/workflows/scripts/dependabot-pr.sh
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
65
.github/workflows/scripts/dependabot-pr.sh
vendored
Executable file
65
.github/workflows/scripts/dependabot-pr.sh
vendored
Executable file
@ -0,0 +1,65 @@
|
||||
#!/bin/zsh -ex
|
||||
|
||||
# Copyright The OpenTelemetry Authors
|
||||
#
|
||||
# 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.
|
||||
|
||||
git config user.name $GITHUB_ACTOR
|
||||
git config user.email $GITHUB_ACTOR@users.noreply.github.com
|
||||
|
||||
PR_NAME=dependabot-prs/`date +'%Y-%m-%dT%H%M%S'`
|
||||
git checkout -b $PR_NAME
|
||||
|
||||
IFS=$'\n'
|
||||
requests=($(gh pr list --search "author:app/dependabot" --json number,title --template '{{range .}}{{tablerow .title}}{{end}}'))
|
||||
message=""
|
||||
dirs=(`find . -type f -name "go.mod" -exec dirname {} \; | sort | egrep '^./'`)
|
||||
|
||||
declare -A mods
|
||||
|
||||
for line in $requests; do
|
||||
echo $line
|
||||
if [[ $line != Bump* ]]; then
|
||||
continue
|
||||
fi
|
||||
|
||||
module=$(echo $line | cut -f 2 -d " ")
|
||||
if [[ $module == go.opentelemetry.io/otel* ]]; then
|
||||
continue
|
||||
fi
|
||||
version=$(echo $line | cut -f 6 -d " ")
|
||||
|
||||
mods[$module]=$version
|
||||
message+=$line
|
||||
message+=$'\n'
|
||||
done
|
||||
|
||||
for module version in ${(kv)mods}; do
|
||||
topdir=`pwd`
|
||||
for dir in $dirs; do
|
||||
echo "checking $dir"
|
||||
cd $dir && if grep -q "$module " go.mod; then go get "$module"@v"$version"; fi
|
||||
cd $topdir
|
||||
done
|
||||
done
|
||||
|
||||
make go-mod-tidy
|
||||
make build
|
||||
|
||||
git add go.sum go.mod
|
||||
git add "**/go.sum" "**/go.mod"
|
||||
git commit -m "dependabot updates `date`
|
||||
$message"
|
||||
git push origin $PR_NAME
|
||||
|
||||
gh pr create --title "dependabot updates `date`" --body "$message" -l "Skip Changelog"
|
Loading…
Reference in New Issue
Block a user