We recently shipped an RWX package to create GitHub pull requests. It's the fastest and easiest way to automate opening PRs.
Speed of Implementation
I built an example for this blog post showing how to automate an npm update
– more information below on why we often prefer this over using tools like dependabot.
It only took a few minutes to build this workflow.
In the demo video I made a mistake in the first implementation and inadvertently showcased one of the biggest benefits of RWX's caching.
Running npm update
takes a little bit over 2 minutes.
I initially had a typo in my command to open the pull request.
Normally, this means I would have to wait a full 2 minutes again to check the fix.
However, since RWX had just run npm update
, the update execution was fully cached.
This meant that when I re-ran the workflow with the typo fixed, the run immediately skipped to creating the pull request, producing a cache hit on the npm update
.
Between the local CLI and caching mechanics, implementing workflows on RWX can be an order of magnitude faster than on CI/CD platforms without automatic caching.
Using the Create Pull Request Package
Because the default RWX GitHub App does not have permissions to create pull requests, you'll need to create a private GitHub App for your bot.
After that, automating pull requests is easy.
- Clone a git repository using the git/clone package. Remember to pass
preserve-git-dir: true
- Define a task to make the desired changes
- Call the
github/create-pull-request
package
Use Cases
You can use this package to automatically open PRs for anything that you want.
Running package manager updates is a fairly good use case. Although tools like dependabot and Mend Renovate can handle updates, they often work less well than the native package manager CLIs for a couple of reasons:
- The third-party tools don't always update transitive dependencies, which are relevant for security and bug fixes
- Third-party tools start blurring the lines of where configuration happens, sometimes pinning versions in the native package specification, and sometimes pinning in the third-party tool configuration
Code
1on:2cron:3- key: npm-update4schedule: '0 7 * * 1 America/New_York' # At 7am ET on Monday56base:7os: ubuntu 24.048tag: 1.1910tasks:11- key: code12call: git/clone 1.6.813with:14repository: https://github.com/rwx-cloud/rwx.com.git15ref: main16github-access-token: ${{ github-apps.rwx-cloud-bot.token }}17preserve-git-dir: true1819- key: tool-versions20use: code21call: rwx/tool-versions 1.0.422filter: [.tool-versions]2324- key: nodejs25call: nodejs/install 1.1.726with:27node-version: ${{ tasks.tool-versions.values.nodejs }}2829- key: npm-install30use: [nodejs, code]31run: npm install32filter: [package.json, package-lock.json]3334- key: npm-update35use: npm-install36run: |37npm update | tee $RWX_VALUES/update-output38(npm outdated || true) | tee $RWX_VALUES/outdated-output3940- key: create-pull-request41call: github/create-pull-request 1.0.142use: npm-update43with:44github-token: ${{ github-apps.rwx-cloud-bot.token }}45branch-prefix: npm-update46pull-request-title: npm update47pull-request-body: |48## Updated Packages4950```51${{ tasks.npm-update.values.update-output }}52```5354## Outdated Packages5556```57${{ tasks.npm-update.values.outdated-output }}58```
Demo
Related posts
Read more on updates and advice from the RWX engineering team