forked from open-telemetry/opentelemetry-go-instrumentation
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add the dependabot PR unification workflow (open-telemetry#335)
- Loading branch information
Showing
2 changed files
with
85 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
name: Automation - 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: Setup Go | ||
uses: actions/setup-go@v4 | ||
with: | ||
go-version: "~1.21.1" | ||
check-latest: true | ||
|
||
- name: Run dependabot-pr.sh | ||
run: ./.github/workflows/scripts/dependabot-pr.sh | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.OPENTELEMETRYBOT_GITHUB_TOKEN }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
#!/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 opentelemetrybot | ||
git config user.email 107717825+opentelemetrybot@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 title --jq '.[].title' )) | ||
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 " ") | ||
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 tidy lint 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 "[chore] dependabot updates `date`" --body "$message" |