Skip to content

Commit

Permalink
feedback updates
Browse files Browse the repository at this point in the history
  • Loading branch information
Alex Boten committed Jan 23, 2023
1 parent 1641939 commit a383cb7
Show file tree
Hide file tree
Showing 2 changed files with 46 additions and 20 deletions.
7 changes: 6 additions & 1 deletion .github/workflows/create-dependabot-pr.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: dependabot-pr
name: Automation - Dependabot PR

on:
workflow_dispatch:
Expand All @@ -8,10 +8,15 @@ jobs:
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@v3
with:
go-version: 1.19

- name: Run dependabot-pr.sh
run: ./.github/workflows/scripts/dependabot-pr.sh
env:
Expand Down
59 changes: 40 additions & 19 deletions .github/workflows/scripts/dependabot-pr.sh
Original file line number Diff line number Diff line change
@@ -1,40 +1,61 @@
#!/bin/bash -ex
#!/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"

# shellcheck disable=SC2006
PR_NAME=dependabot-prs/$(date +'%Y-%m-%dT%H%M%S')
git checkout -b "$PR_NAME"
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' | sort )
requests=($( gh pr list --search "author:app/dependabot" --json title --jq '.[].title' ))
message=""
dirs=$(find . -type f -name "go.mod" -exec dirname {} \; | sort )
dirs=(`find . -type f -name "go.mod" -exec dirname {} \; | sort | egrep '^./'`)

declare -A mods

for line in $requests; do
if [[ $line != Bump* ]]; then
echo $line
if [[ $line != build\(deps\)* ]]; then
continue
fi

module=$(echo "$line" | cut -f 2 -d " ")
version=$(echo "$line" | cut -f 6 -d " ")

topdir=$(pwd)
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 $dir && if grep -q "$module " go.mod; then go get "$module"@v"$version"; fi
cd $topdir
done
message+=$line
message+=$'\n'
done

make tidy lint
make tidy lint build

git add --all
git commit -m "dependabot updates $(date)
git add go.sum go.mod
git add "**/go.sum" "**/go.mod"
git commit -m "dependabot updates `date`
$message"
git push origin "$PR_NAME"
git push origin $PR_NAME

gh pr create --title "[chore] dependabot updates $(date)" --body "$message" -l "dependencies"
gh pr create --title "dependabot updates `date`" --body "$message"

0 comments on commit a383cb7

Please sign in to comment.