Add path input
This commit is contained in:
parent
4c018f4174
commit
1e09ec2f22
6 changed files with 19 additions and 9 deletions
10
README.md
10
README.md
|
@ -33,15 +33,17 @@ Create Pull Request action will:
|
||||||
|
|
||||||
You can also pin to a [specific release](https://github.com/peter-evans/create-pull-request/releases) version in the format `@v2.x.x`
|
You can also pin to a [specific release](https://github.com/peter-evans/create-pull-request/releases) version in the format `@v2.x.x`
|
||||||
|
|
||||||
|
### Action inputs
|
||||||
|
|
||||||
|
With the exception of `token`, all inputs are **optional**. If not set, sensible default values will be used.
|
||||||
|
|
||||||
**Note**: If you want pull requests created by this action to trigger an `on: pull_request` workflow then you must use a [Personal Access Token](https://help.github.com/en/articles/creating-a-personal-access-token-for-the-command-line) instead of the default `GITHUB_TOKEN`.
|
**Note**: If you want pull requests created by this action to trigger an `on: pull_request` workflow then you must use a [Personal Access Token](https://help.github.com/en/articles/creating-a-personal-access-token-for-the-command-line) instead of the default `GITHUB_TOKEN`.
|
||||||
See [this issue](https://github.com/peter-evans/create-pull-request/issues/48) for further details.
|
See [this issue](https://github.com/peter-evans/create-pull-request/issues/48) for further details.
|
||||||
|
|
||||||
### Action inputs
|
|
||||||
|
|
||||||
These inputs are *all optional*. If not set, sensible default values will be used.
|
|
||||||
|
|
||||||
| Name | Description | Default |
|
| Name | Description | Default |
|
||||||
| --- | --- | --- |
|
| --- | --- | --- |
|
||||||
|
| `token` | `GITHUB_TOKEN` or a `repo` scoped [PAT](https://help.github.com/en/github/authenticating-to-github/creating-a-personal-access-token-for-the-command-line). | |
|
||||||
|
| `path` | Relative path under `$GITHUB_WORKSPACE` to the repository. | `$GITHUB_WORKSPACE` |
|
||||||
| `commit-message` | The message to use when committing changes. | `[create-pull-request] automated change` |
|
| `commit-message` | The message to use when committing changes. | `[create-pull-request] automated change` |
|
||||||
| `committer` | The committer name and email address in the format `Display Name <email@address.com>`. | Defaults to the GitHub Actions bot user. See [Committer and author](#committer-and-author) for details. |
|
| `committer` | The committer name and email address in the format `Display Name <email@address.com>`. | Defaults to the GitHub Actions bot user. See [Committer and author](#committer-and-author) for details. |
|
||||||
| `author` | The author name and email address in the format `Display Name <email@address.com>`. | Defaults to the GitHub Actions bot user. See [Committer and author](#committer-and-author) for details. |
|
| `author` | The author name and email address in the format `Display Name <email@address.com>`. | Defaults to the GitHub Actions bot user. See [Committer and author](#committer-and-author) for details. |
|
||||||
|
|
|
@ -2,8 +2,10 @@ name: 'Create Pull Request'
|
||||||
description: 'Creates a pull request for changes to your repository in the actions workspace'
|
description: 'Creates a pull request for changes to your repository in the actions workspace'
|
||||||
inputs:
|
inputs:
|
||||||
token:
|
token:
|
||||||
description: 'The GitHub authentication token'
|
description: 'GITHUB_TOKEN or a repo scoped PAT'
|
||||||
required: true
|
required: true
|
||||||
|
path:
|
||||||
|
description: 'Relative path under $GITHUB_WORKSPACE to the repository.'
|
||||||
commit-message:
|
commit-message:
|
||||||
description: 'The message to use when committing changes.'
|
description: 'The message to use when committing changes.'
|
||||||
committer:
|
committer:
|
||||||
|
|
2
dist/index.js
vendored
2
dist/index.js
vendored
|
@ -1024,6 +1024,7 @@ async function run() {
|
||||||
// Fetch action inputs
|
// Fetch action inputs
|
||||||
const inputs = {
|
const inputs = {
|
||||||
token: core.getInput("token"),
|
token: core.getInput("token"),
|
||||||
|
path: core.getInput("path"),
|
||||||
commitMessage: core.getInput("commit-message"),
|
commitMessage: core.getInput("commit-message"),
|
||||||
committer: core.getInput("committer"),
|
committer: core.getInput("committer"),
|
||||||
author: core.getInput("author"),
|
author: core.getInput("author"),
|
||||||
|
@ -1044,6 +1045,7 @@ async function run() {
|
||||||
|
|
||||||
// Set environment variables from inputs.
|
// Set environment variables from inputs.
|
||||||
if (inputs.token) process.env.GITHUB_TOKEN = inputs.token;
|
if (inputs.token) process.env.GITHUB_TOKEN = inputs.token;
|
||||||
|
if (inputs.path) process.env.CPR_PATH = inputs.path;
|
||||||
if (inputs.commitMessage) process.env.CPR_COMMIT_MESSAGE = inputs.commitMessage;
|
if (inputs.commitMessage) process.env.CPR_COMMIT_MESSAGE = inputs.commitMessage;
|
||||||
if (inputs.committer) process.env.CPR_COMMITTER = inputs.committer;
|
if (inputs.committer) process.env.CPR_COMMITTER = inputs.committer;
|
||||||
if (inputs.author) process.env.CPR_AUTHOR = inputs.author;
|
if (inputs.author) process.env.CPR_AUTHOR = inputs.author;
|
||||||
|
|
5
dist/src/create_pull_request.py
vendored
5
dist/src/create_pull_request.py
vendored
|
@ -96,6 +96,7 @@ def set_committer_author(repo, committer, author):
|
||||||
github_token = os.environ["GITHUB_TOKEN"]
|
github_token = os.environ["GITHUB_TOKEN"]
|
||||||
github_repository = os.environ["GITHUB_REPOSITORY"]
|
github_repository = os.environ["GITHUB_REPOSITORY"]
|
||||||
# Get environment variables with defaults
|
# Get environment variables with defaults
|
||||||
|
path = os.getenv("CPR_PATH", os.getcwd())
|
||||||
branch = os.getenv("CPR_BRANCH", DEFAULT_BRANCH)
|
branch = os.getenv("CPR_BRANCH", DEFAULT_BRANCH)
|
||||||
commit_message = os.getenv("CPR_COMMIT_MESSAGE", DEFAULT_COMMIT_MESSAGE)
|
commit_message = os.getenv("CPR_COMMIT_MESSAGE", DEFAULT_COMMIT_MESSAGE)
|
||||||
# Get environment variables with a default of 'None'
|
# Get environment variables with a default of 'None'
|
||||||
|
@ -103,8 +104,8 @@ committer = os.environ.get("CPR_COMMITTER")
|
||||||
author = os.environ.get("CPR_AUTHOR")
|
author = os.environ.get("CPR_AUTHOR")
|
||||||
base = os.environ.get("CPR_BASE")
|
base = os.environ.get("CPR_BASE")
|
||||||
|
|
||||||
# Set the repo to the working directory
|
# Set the repo path
|
||||||
repo = Repo(os.getcwd())
|
repo = Repo(path)
|
||||||
|
|
||||||
# Determine if the checked out ref is a valid base for a pull request
|
# Determine if the checked out ref is a valid base for a pull request
|
||||||
# The action needs the checked out HEAD ref to be a branch
|
# The action needs the checked out HEAD ref to be a branch
|
||||||
|
|
2
index.js
2
index.js
|
@ -22,6 +22,7 @@ async function run() {
|
||||||
// Fetch action inputs
|
// Fetch action inputs
|
||||||
const inputs = {
|
const inputs = {
|
||||||
token: core.getInput("token"),
|
token: core.getInput("token"),
|
||||||
|
path: core.getInput("path"),
|
||||||
commitMessage: core.getInput("commit-message"),
|
commitMessage: core.getInput("commit-message"),
|
||||||
committer: core.getInput("committer"),
|
committer: core.getInput("committer"),
|
||||||
author: core.getInput("author"),
|
author: core.getInput("author"),
|
||||||
|
@ -42,6 +43,7 @@ async function run() {
|
||||||
|
|
||||||
// Set environment variables from inputs.
|
// Set environment variables from inputs.
|
||||||
if (inputs.token) process.env.GITHUB_TOKEN = inputs.token;
|
if (inputs.token) process.env.GITHUB_TOKEN = inputs.token;
|
||||||
|
if (inputs.path) process.env.CPR_PATH = inputs.path;
|
||||||
if (inputs.commitMessage) process.env.CPR_COMMIT_MESSAGE = inputs.commitMessage;
|
if (inputs.commitMessage) process.env.CPR_COMMIT_MESSAGE = inputs.commitMessage;
|
||||||
if (inputs.committer) process.env.CPR_COMMITTER = inputs.committer;
|
if (inputs.committer) process.env.CPR_COMMITTER = inputs.committer;
|
||||||
if (inputs.author) process.env.CPR_AUTHOR = inputs.author;
|
if (inputs.author) process.env.CPR_AUTHOR = inputs.author;
|
||||||
|
|
|
@ -96,6 +96,7 @@ def set_committer_author(repo, committer, author):
|
||||||
github_token = os.environ["GITHUB_TOKEN"]
|
github_token = os.environ["GITHUB_TOKEN"]
|
||||||
github_repository = os.environ["GITHUB_REPOSITORY"]
|
github_repository = os.environ["GITHUB_REPOSITORY"]
|
||||||
# Get environment variables with defaults
|
# Get environment variables with defaults
|
||||||
|
path = os.getenv("CPR_PATH", os.getcwd())
|
||||||
branch = os.getenv("CPR_BRANCH", DEFAULT_BRANCH)
|
branch = os.getenv("CPR_BRANCH", DEFAULT_BRANCH)
|
||||||
commit_message = os.getenv("CPR_COMMIT_MESSAGE", DEFAULT_COMMIT_MESSAGE)
|
commit_message = os.getenv("CPR_COMMIT_MESSAGE", DEFAULT_COMMIT_MESSAGE)
|
||||||
# Get environment variables with a default of 'None'
|
# Get environment variables with a default of 'None'
|
||||||
|
@ -103,8 +104,8 @@ committer = os.environ.get("CPR_COMMITTER")
|
||||||
author = os.environ.get("CPR_AUTHOR")
|
author = os.environ.get("CPR_AUTHOR")
|
||||||
base = os.environ.get("CPR_BASE")
|
base = os.environ.get("CPR_BASE")
|
||||||
|
|
||||||
# Set the repo to the working directory
|
# Set the repo path
|
||||||
repo = Repo(os.getcwd())
|
repo = Repo(path)
|
||||||
|
|
||||||
# Determine if the checked out ref is a valid base for a pull request
|
# Determine if the checked out ref is a valid base for a pull request
|
||||||
# The action needs the checked out HEAD ref to be a branch
|
# The action needs the checked out HEAD ref to be a branch
|
||||||
|
|
Loading…
Reference in a new issue