Skip to content

Commit

Permalink
Merge pull request #5 from nnichols/batch-mode
Browse files Browse the repository at this point in the history
First stab at updating all dependencies in one PR
  • Loading branch information
nnichols committed Jan 30, 2021
2 parents 73f636b + 81df4a4 commit b369888
Show file tree
Hide file tree
Showing 4 changed files with 47 additions and 16 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# Changelog

## v3 - 01/30/2021

- Enable a batch update mode

## v2 - 01/09/2021

- Use Docker image with dependencies pre-loaded
Expand Down
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ jobs:
uses: actions/checkout@v1

- name: Check deps
uses: nnichols/clojure-dependency-update-action@v2
uses: nnichols/clojure-dependency-update-action@v3
with:
github-token: ${{ secrets.github_token }}
```
Expand All @@ -35,6 +35,7 @@ jobs:
* `excludes`: Artifact names to be excluded from the `antq` check. Defaults to an empty list. See [antq-action](https://github.com/liquidz/antq-action#inputs) for more information.
* `directories`: Directories to search for project files in. Defaults to the root of the repository. See [antq-action](https://github.com/liquidz/antq-action#inputs) for more information.
* `skips`: Build tools/files to skip by default. Defaults to an empty list. See [antq-action](https://github.com/liquidz/antq-action#inputs) for more information.
* `batch`: Updates all outdated dependencies in a single pull request. Set to "true" to enable

## Acknowledgements

Expand Down
5 changes: 5 additions & 0 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,10 @@ inputs:
description: 'Project types to skip to search (space separated). Must be one of `boot`, `clojure-cli`, `github-action`, `pom`, `shadow-cljs` and `leiningen`.'
required: true
default: ''
batch:
description: 'Updates all outdated dependencies in a single pull request. Set to "true" to enable'
required: true
default: 'false'

runs:
using: docker
Expand All @@ -48,3 +52,4 @@ runs:
EXCLUDE: ${{ inputs.excludes }}
DIRECTORY: ${{ inputs.directories }}
SKIP: ${{ inputs.skips }}
BATCH: ${{ inputs.batch }}
51 changes: 36 additions & 15 deletions dependency-check.sh
Original file line number Diff line number Diff line change
Expand Up @@ -23,23 +23,44 @@ done
PREFETCH=$(clojure -Stree -Sdeps '{:deps {antq/antq {:mvn/version "RELEASE"}}}')
UPGRADES=$(clojure -Sdeps '{:deps {antq/antq {:mvn/version "RELEASE"}}}' -m antq.core --reporter=format --error-format="{{name}},{{version}},{{latest-version}}" $EXCLUDES $DIRECTORIES $SKIPS | sed '/Failed to fetch/d' | sed '/Unable to fetch/d' | sed '/Logging initialized/d')

for upgrade in $UPGRADES; do
IFS=',' temp=($upgrade)
DEP_NAME=${temp[0]}
OLD_VERSION=${temp[1]}
NEW_VERSION=${temp[2]}
BRANCH_NAME="dependencies/clojure/$DEP_NAME-$NEW_VERSION"
echo "Updating" $DEP_NAME "version" $OLD_VERSION "to" $NEW_VERSION
if [ $BATCH = 'true' ]; then
BRANCH_NAME="dependencies/clojure/$(date +"%Y-%m-%d-%H-%M-%S")"
git checkout -b $BRANCH_NAME
if [[ $? == 0 ]]; then
for upgrade in $UPGRADES; do
IFS=',' temp=($upgrade)
DEP_NAME=${temp[0]}
OLD_VERSION=${temp[1]}
NEW_VERSION=${temp[2]}
echo "Updating" $DEP_NAME "version" $OLD_VERSION "to" $NEW_VERSION
ESCAPED_DEP_NAME=`echo $DEP_NAME | sed 's/\//\\\\\//'`
sed -e "/$ESCAPED_DEP_NAME/s/$OLD_VERSION/$NEW_VERSION/" deps.edn > deps2.edn
mv deps2.edn deps.edn
git add deps.edn
git add .
git commit -m "Bump $DEP_NAME from $OLD_VERSION to $NEW_VERSION"
git push -u "https://$GITHUB_ACTOR:$TOKEN@github.com/$GITHUB_REPOSITORY.git" $BRANCH_NAME
gh pr create --fill --head $BRANCH_NAME --base $BRANCH
echo
git checkout $BRANCH
fi
done
done
git push -u "https://$GITHUB_ACTOR:$TOKEN@github.com/$GITHUB_REPOSITORY.git" $BRANCH_NAME
gh pr create --fill --head $BRANCH_NAME --base $BRANCH
echo
git checkout $BRANCH
else
for upgrade in $UPGRADES; do
IFS=',' temp=($upgrade)
DEP_NAME=${temp[0]}
OLD_VERSION=${temp[1]}
NEW_VERSION=${temp[2]}
BRANCH_NAME="dependencies/clojure/$DEP_NAME-$NEW_VERSION"
echo "Updating" $DEP_NAME "version" $OLD_VERSION "to" $NEW_VERSION
git checkout -b $BRANCH_NAME
if [[ $? == 0 ]]; then
ESCAPED_DEP_NAME=`echo $DEP_NAME | sed 's/\//\\\\\//'`
sed -e "/$ESCAPED_DEP_NAME/s/$OLD_VERSION/$NEW_VERSION/" deps.edn > deps2.edn
mv deps2.edn deps.edn
git add .
git commit -m "Bump $DEP_NAME from $OLD_VERSION to $NEW_VERSION"
git push -u "https://$GITHUB_ACTOR:$TOKEN@github.com/$GITHUB_REPOSITORY.git" $BRANCH_NAME
gh pr create --fill --head $BRANCH_NAME --base $BRANCH
echo
git checkout $BRANCH
fi
done
fi

0 comments on commit b369888

Please sign in to comment.