Skip to content

A GitHub action that commits file(s) to a different target repository, and creates a pull request.

License

Notifications You must be signed in to change notification settings

Fondeadora/auto-cross-pr

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

15 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Auto Cross Pull Requester

A simple GitHub action that, given some file(s), commits any changes and submits a pull request to the target repository, on the specified branch and directory.

A use case for this is to generate some files (eg. TypeScript definitions) during a build in one repo (eg. API service), and commit them to another (eg. web app).

Note: Although this action can be quite useful, it likely will not always be the best approach. I recommend you have a look at the Alternative Options section just in case.

Usage

- uses: actions/checkout@v2
- name: Create PR to my-org/target-repo
  uses: TickX/[email protected]
  with:
    token: ${{ secrets.GH_TOKEN }}
    item: path/to/file.ext
    repo: target-repo
    repo_owner: my-org

Action Inputs

Here's the full list of inputs:

Input Description Default
token A GitHub access token (see section)
item The file or directory to commit
repo The target repository
repo_owner The target repository owner
repo_base_branch A new branch will be created from this one before submitting the PR master
repo_target_dir The chosen item will be committed to this directory auto-update/${REPO_BASE_BRANCH}
commit_author The author of the commit "Auto Cross Pull Requester"
commit_email The email associated with the commit [email protected]
commit_message The commit message "Auto update"
pr_title The PR title "Auto Update"
pr_body The PR body content "This is an automatic update."

GitHub Access Token

The token input requires a scoped Personal Access Token; You can use GitHub's GITHUB_TOKEN environment variable for that. However, if you do, PRs created by this action will not trigger other on: [push] and on: [pull_request] workflows.

For more information about this limitation and its workarounds, see this action's brilliant documentation.

If you just want a solid workaround, use a GitHub App for the sole purpose of creating a token:

  1. Create an app:
    • This can be minimal; Enter any valid URL value for the Homepage URL field, eg. your repo's github pages URL my-org.github.io/my-repo, and uncheck Active under Webhook.
    • Under Repository permissions: Contents select Access: Read & write.
    • Under Repository permissions: Pull requests select Access: Read & write.
  2. Create and download a Private Key from the app's settings page.
  3. Install the app on the repositories involved in this action.
  4. In your workflow, obtain a token by using tibdex/github-app-token, which takes your app's ID and private key and generates a temporary auth token.
  5. Pass the generated token to this action's token input.

Alternative Options

Depending on your case, you may want to look at alternative options that can achieve similar results, and potentially be better.

Some of these options are:

About

A GitHub action that commits file(s) to a different target repository, and creates a pull request.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • Shell 100.0%