Add CircleCI job to automatically submit a PR if npm audit fix changes anything
MODIFY
.circleci/config.yml
.circleci/config.yml
@@ -77,7 +77,24 @@ jobs:
command: |
cd integration-test
npm run test:post-release
-
+ npm_audit_node_11: &npm_audit
+ docker:
+ - image: circleci/golang:1.12.0-node
+ steps:
+ - checkout
+ - run:
+ name: Update npm
+ command: 'sudo npm install -g npm@latest'
+ - run:
+ name: install hub
+ command: |
+ set -xe
+ go get -u -d github.com/github/hub
+ cd /go/src/github.com/github/hub
+ go install github.com/github/hub
+ - run:
+ name: Submit PR if npm audit fix makes changes
+ command: ./scripts/npm-audit-fix.sh
workflows:
version: 2
@@ -95,3 +112,4 @@ workflows:
- master
jobs:
- post_release_test_integration
+ - npm_audit_node_11

ADD
scripts/npm-audit-fix.sh
+git clone https://github.com/AgoricBot/harden.git
+cd harden
+git remote add upstream https://github.com/Agoric/harden.git
+git fetch upstream
+git checkout master
+git rebase upstream/master
+git config user.email "kate+agoricbot@agoric.com"
+git config user.name "AgoricBot"
+hub push origin master
+git checkout -b npm-audit-fix
+
+if npm audit ; then
+ echo "Nothing to fix"
+else
+ npm audit fix
+ files_changed=true
+fi
+
+# Do the same thing with the package.json in the integration-test folder
+cd integration-test
+if npm audit ; then
+ echo "Nothing to fix"
+else
+ npm audit fix
+ files_changed=true
+fi
+cd ..
+
+if [ "$files_changed" = true ] ; then
+ git add .
+ git commit -m "results of running npm audit fix"
+ git remote set-url origin https://AgoricBot:$GITHUB_TOKEN@github.com/AgoricBot/harden.git
+ git push origin npm-audit-fix
+ hub pull-request --no-edit --base Agoric/harden:master
+fi

Add CircleCI job to automatically submit a PR if npm audit fix changes anything (#24)