metadata-update-and-push-and-pull-request.js 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. // In order for this script to work:
  2. //
  3. // * Install `hub` command line tool: `brew install hub`
  4. // * Create a "Personal Access Token" in GitHub account settings (just "repo_public" would be enough)
  5. // * Tell `hub` to use the token for creating GitHub pull requests: `echo "---\ngithub.com:\n- protocol: https\n user: GITHUB_USERNAME\n oauth_token: TOKEN" >> ~/.config/hub`
  6. import update_metadata from './modules/update-metadata.js'
  7. import commit from './modules/commit.js'
  8. import exec from './modules/exec.js'
  9. if (update_metadata())
  10. {
  11. commit()
  12. console.log()
  13. console.log('========================================')
  14. console.log('= Pushing changes =')
  15. console.log('========================================')
  16. console.log()
  17. // Delete previous `update-metadata` remote branch
  18. // (if it already exists)
  19. if (exec('git ls-remote --heads origin update-metadata'))
  20. {
  21. console.log(exec('git push origin update-metadata --delete'))
  22. }
  23. // Push the local `update-metadata` branch to GitHub
  24. console.log(exec('git push origin update-metadata'))
  25. console.log()
  26. console.log('========================================')
  27. console.log('= Pushed. Creating Pull Request. =')
  28. console.log('========================================')
  29. console.log()
  30. console.log(exec('hub pull-request -m "Updated metadata" -b catamphetamine/libphonenumber-js:master -h update-metadata'))
  31. console.log()
  32. console.log('========================================')
  33. console.log('= Pull Request created =')
  34. console.log('========================================')
  35. console.log()
  36. console.log(exec('git checkout master'))
  37. console.log(exec('git branch -D update-metadata'))
  38. }