mirror of
https://forgejo.stefka.eu/jiriks74/create-pull-request.git
synced 2025-01-18 16:01:06 +01:00
update naming and docs
This commit is contained in:
parent
1bbb69d9dd
commit
cff1ab2c9e
6 changed files with 33 additions and 26 deletions
20
README.md
20
README.md
|
@ -46,6 +46,7 @@ All inputs are **optional**. If not set, sensible defaults will be used.
|
||||||
| --- | --- | --- |
|
| --- | --- | --- |
|
||||||
| `token` | `GITHUB_TOKEN` (`contents: write`, `pull-requests: write`) or a `repo` scoped [Personal Access Token (PAT)](https://docs.github.com/en/github/authenticating-to-github/creating-a-personal-access-token). | `GITHUB_TOKEN` |
|
| `token` | `GITHUB_TOKEN` (`contents: write`, `pull-requests: write`) or a `repo` scoped [Personal Access Token (PAT)](https://docs.github.com/en/github/authenticating-to-github/creating-a-personal-access-token). | `GITHUB_TOKEN` |
|
||||||
| `path` | Relative path under `GITHUB_WORKSPACE` to the repository. | `GITHUB_WORKSPACE` |
|
| `path` | Relative path under `GITHUB_WORKSPACE` to the repository. | `GITHUB_WORKSPACE` |
|
||||||
|
| `add-paths` | A comma or newline-separated list of file paths to commit. Paths should follow git's [pathspec](https://git-scm.com/docs/gitglossary#Documentation/gitglossary.txt-aiddefpathspecapathspec) syntax. Defaults to adding all new and modified files. See [Controlling committed files](#controlling-committed-files). | `-A` |
|
||||||
| `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. | `GitHub <noreply@github.com>` |
|
| `committer` | The committer name and email address in the format `Display Name <email@address.com>`. Defaults to the GitHub Actions bot user. | `GitHub <noreply@github.com>` |
|
||||||
| `author` | The author name and email address in the format `Display Name <email@address.com>`. Defaults to the user who triggered the workflow run. | `${{ github.actor }} <${{ github.actor }}@users.noreply.github.com>` |
|
| `author` | The author name and email address in the format `Display Name <email@address.com>`. Defaults to the user who triggered the workflow run. | `${{ github.actor }} <${{ github.actor }}@users.noreply.github.com>` |
|
||||||
|
@ -63,7 +64,6 @@ All inputs are **optional**. If not set, sensible defaults will be used.
|
||||||
| `team-reviewers` | A comma or newline-separated list of GitHub teams to request a review from. Note that a `repo` scoped [PAT](https://docs.github.com/en/github/authenticating-to-github/creating-a-personal-access-token) may be required. See [this issue](https://github.com/peter-evans/create-pull-request/issues/155). If using a GitHub App, refer to [Authenticating with GitHub App generated tokens](docs/concepts-guidelines.md#authenticating-with-github-app-generated-tokens) for the proper permissions. | |
|
| `team-reviewers` | A comma or newline-separated list of GitHub teams to request a review from. Note that a `repo` scoped [PAT](https://docs.github.com/en/github/authenticating-to-github/creating-a-personal-access-token) may be required. See [this issue](https://github.com/peter-evans/create-pull-request/issues/155). If using a GitHub App, refer to [Authenticating with GitHub App generated tokens](docs/concepts-guidelines.md#authenticating-with-github-app-generated-tokens) for the proper permissions. | |
|
||||||
| `milestone` | The number of the milestone to associate this pull request with. | |
|
| `milestone` | The number of the milestone to associate this pull request with. | |
|
||||||
| `draft` | Create a [draft pull request](https://docs.github.com/en/github/collaborating-with-issues-and-pull-requests/about-pull-requests#draft-pull-requests). | `false` | |
|
| `draft` | Create a [draft pull request](https://docs.github.com/en/github/collaborating-with-issues-and-pull-requests/about-pull-requests#draft-pull-requests). | `false` | |
|
||||||
| `add-pattern-array` | A comma or newline-separated list of file path patterns, by example `**.txt, **some_dir**.png`. | `-A (what means --all)` |
|
|
||||||
|
|
||||||
For self-hosted runners behind a corporate proxy set the `https_proxy` environment variable.
|
For self-hosted runners behind a corporate proxy set the `https_proxy` environment variable.
|
||||||
```yml
|
```yml
|
||||||
|
@ -125,16 +125,18 @@ To use this strategy, set input `branch-suffix` with one of the following option
|
||||||
|
|
||||||
### Controlling committed files
|
### Controlling committed files
|
||||||
|
|
||||||
You may control files to added on pull request with argument `add-pattern-array`.
|
The action defaults to adding all new and modified files.
|
||||||
It specify `git add` pattern of files. By example:
|
You can override this behaviour and control which files are committed with the `add-paths` input.
|
||||||
|
Paths should follow git's [pathspec](https://git-scm.com/docs/gitglossary#Documentation/gitglossary.txt-aiddefpathspecapathspec) syntax.
|
||||||
|
All file changes that do not match one of the paths will be discarded.
|
||||||
|
|
||||||
```yml
|
```yml
|
||||||
...
|
- name: Create Pull Request
|
||||||
uses: peter-evans/create-pull-request@main #TODO put next version here
|
uses: peter-evans/create-pull-request@v3
|
||||||
with:
|
with:
|
||||||
add-pattern-array: |
|
add-paths: |
|
||||||
**.txt
|
*.java
|
||||||
**some/dirs**.png
|
docs/\*.txt
|
||||||
token: ${{ secrets.GITHUB_TOKEN }}
|
|
||||||
```
|
```
|
||||||
|
|
||||||
### Controlling commits
|
### Controlling commits
|
||||||
|
|
11
action.yml
11
action.yml
|
@ -8,6 +8,13 @@ inputs:
|
||||||
description: >
|
description: >
|
||||||
Relative path under $GITHUB_WORKSPACE to the repository.
|
Relative path under $GITHUB_WORKSPACE to the repository.
|
||||||
Defaults to $GITHUB_WORKSPACE.
|
Defaults to $GITHUB_WORKSPACE.
|
||||||
|
add-paths:
|
||||||
|
description: >
|
||||||
|
A comma or newline-separated list of file paths to commit.
|
||||||
|
Paths should follow git's pathspec syntax.
|
||||||
|
Defaults to adding all new and modified files.
|
||||||
|
default: |
|
||||||
|
-A
|
||||||
commit-message:
|
commit-message:
|
||||||
description: 'The message to use when committing changes.'
|
description: 'The message to use when committing changes.'
|
||||||
default: '[create-pull-request] automated change'
|
default: '[create-pull-request] automated change'
|
||||||
|
@ -64,10 +71,6 @@ inputs:
|
||||||
draft:
|
draft:
|
||||||
description: 'Create a draft pull request'
|
description: 'Create a draft pull request'
|
||||||
default: false
|
default: false
|
||||||
add-pattern-array:
|
|
||||||
description: 'git add [pattern]'
|
|
||||||
default: |
|
|
||||||
-A
|
|
||||||
outputs:
|
outputs:
|
||||||
pull-request-number:
|
pull-request-number:
|
||||||
description: 'The pull request number'
|
description: 'The pull request number'
|
||||||
|
|
13
dist/index.js
vendored
13
dist/index.js
vendored
|
@ -98,7 +98,7 @@ function splitLines(multilineString) {
|
||||||
.map(s => s.trim())
|
.map(s => s.trim())
|
||||||
.filter(x => x !== '');
|
.filter(x => x !== '');
|
||||||
}
|
}
|
||||||
function createOrUpdateBranch(git, commitMessage, base, branch, branchRemoteName, signoff, filePatterns) {
|
function createOrUpdateBranch(git, commitMessage, base, branch, branchRemoteName, signoff, addPaths) {
|
||||||
return __awaiter(this, void 0, void 0, function* () {
|
return __awaiter(this, void 0, void 0, function* () {
|
||||||
// Get the working base.
|
// Get the working base.
|
||||||
// When a ref, it may or may not be the actual base.
|
// When a ref, it may or may not be the actual base.
|
||||||
|
@ -124,14 +124,15 @@ function createOrUpdateBranch(git, commitMessage, base, branch, branchRemoteName
|
||||||
// Commit any uncommitted changes
|
// Commit any uncommitted changes
|
||||||
if (yield git.isDirty(true)) {
|
if (yield git.isDirty(true)) {
|
||||||
core.info('Uncommitted changes found. Adding a commit.');
|
core.info('Uncommitted changes found. Adding a commit.');
|
||||||
for (const filePattern of filePatterns) {
|
for (const path of addPaths) {
|
||||||
yield git.exec(['add', filePattern], true);
|
yield git.exec(['add', path], true);
|
||||||
}
|
}
|
||||||
const params = ['-m', commitMessage];
|
const params = ['-m', commitMessage];
|
||||||
if (signoff) {
|
if (signoff) {
|
||||||
params.push('--signoff');
|
params.push('--signoff');
|
||||||
}
|
}
|
||||||
yield git.commit(params);
|
yield git.commit(params);
|
||||||
|
// Remove uncommitted tracked and untracked changes
|
||||||
git.exec(['reset', '--hard']);
|
git.exec(['reset', '--hard']);
|
||||||
git.exec(['clean', '-f']);
|
git.exec(['clean', '-f']);
|
||||||
}
|
}
|
||||||
|
@ -381,7 +382,7 @@ function createPullRequest(inputs) {
|
||||||
core.endGroup();
|
core.endGroup();
|
||||||
// Create or update the pull request branch
|
// Create or update the pull request branch
|
||||||
core.startGroup('Create or update the pull request branch');
|
core.startGroup('Create or update the pull request branch');
|
||||||
const result = yield (0, create_or_update_branch_1.createOrUpdateBranch)(git, inputs.commitMessage, inputs.base, inputs.branch, branchRemoteName, inputs.signoff, inputs.addPatternArray);
|
const result = yield (0, create_or_update_branch_1.createOrUpdateBranch)(git, inputs.commitMessage, inputs.base, inputs.branch, branchRemoteName, inputs.signoff, inputs.addPaths);
|
||||||
core.endGroup();
|
core.endGroup();
|
||||||
if (['created', 'updated'].includes(result.action)) {
|
if (['created', 'updated'].includes(result.action)) {
|
||||||
// The branch was created or updated
|
// The branch was created or updated
|
||||||
|
@ -1078,6 +1079,7 @@ function run() {
|
||||||
const inputs = {
|
const inputs = {
|
||||||
token: core.getInput('token'),
|
token: core.getInput('token'),
|
||||||
path: core.getInput('path'),
|
path: core.getInput('path'),
|
||||||
|
addPaths: utils.getInputAsArray('add-paths'),
|
||||||
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'),
|
||||||
|
@ -1094,8 +1096,7 @@ function run() {
|
||||||
reviewers: utils.getInputAsArray('reviewers'),
|
reviewers: utils.getInputAsArray('reviewers'),
|
||||||
teamReviewers: utils.getInputAsArray('team-reviewers'),
|
teamReviewers: utils.getInputAsArray('team-reviewers'),
|
||||||
milestone: Number(core.getInput('milestone')),
|
milestone: Number(core.getInput('milestone')),
|
||||||
draft: core.getInput('draft') === 'true',
|
draft: core.getInput('draft') === 'true'
|
||||||
addPatternArray: utils.getInputAsArray('add-pattern-array')
|
|
||||||
};
|
};
|
||||||
core.debug(`Inputs: ${(0, util_1.inspect)(inputs)}`);
|
core.debug(`Inputs: ${(0, util_1.inspect)(inputs)}`);
|
||||||
yield (0, create_pull_request_1.createPullRequest)(inputs);
|
yield (0, create_pull_request_1.createPullRequest)(inputs);
|
||||||
|
|
|
@ -92,7 +92,7 @@ export async function createOrUpdateBranch(
|
||||||
branch: string,
|
branch: string,
|
||||||
branchRemoteName: string,
|
branchRemoteName: string,
|
||||||
signoff: boolean,
|
signoff: boolean,
|
||||||
filePatterns: string[]
|
addPaths: string[]
|
||||||
): Promise<CreateOrUpdateBranchResult> {
|
): Promise<CreateOrUpdateBranchResult> {
|
||||||
// Get the working base.
|
// Get the working base.
|
||||||
// When a ref, it may or may not be the actual base.
|
// When a ref, it may or may not be the actual base.
|
||||||
|
@ -121,14 +121,15 @@ export async function createOrUpdateBranch(
|
||||||
// Commit any uncommitted changes
|
// Commit any uncommitted changes
|
||||||
if (await git.isDirty(true)) {
|
if (await git.isDirty(true)) {
|
||||||
core.info('Uncommitted changes found. Adding a commit.')
|
core.info('Uncommitted changes found. Adding a commit.')
|
||||||
for (const filePattern of filePatterns) {
|
for (const path of addPaths) {
|
||||||
await git.exec(['add', filePattern], true)
|
await git.exec(['add', path], true)
|
||||||
}
|
}
|
||||||
const params = ['-m', commitMessage]
|
const params = ['-m', commitMessage]
|
||||||
if (signoff) {
|
if (signoff) {
|
||||||
params.push('--signoff')
|
params.push('--signoff')
|
||||||
}
|
}
|
||||||
await git.commit(params)
|
await git.commit(params)
|
||||||
|
// Remove uncommitted tracked and untracked changes
|
||||||
git.exec(['reset', '--hard'])
|
git.exec(['reset', '--hard'])
|
||||||
git.exec(['clean', '-f'])
|
git.exec(['clean', '-f'])
|
||||||
}
|
}
|
||||||
|
|
|
@ -12,6 +12,7 @@ import * as utils from './utils'
|
||||||
export interface Inputs {
|
export interface Inputs {
|
||||||
token: string
|
token: string
|
||||||
path: string
|
path: string
|
||||||
|
addPaths: string[]
|
||||||
commitMessage: string
|
commitMessage: string
|
||||||
committer: string
|
committer: string
|
||||||
author: string
|
author: string
|
||||||
|
@ -29,7 +30,6 @@ export interface Inputs {
|
||||||
teamReviewers: string[]
|
teamReviewers: string[]
|
||||||
milestone: number
|
milestone: number
|
||||||
draft: boolean
|
draft: boolean
|
||||||
addPatternArray: string[]
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function createPullRequest(inputs: Inputs): Promise<void> {
|
export async function createPullRequest(inputs: Inputs): Promise<void> {
|
||||||
|
@ -175,7 +175,7 @@ export async function createPullRequest(inputs: Inputs): Promise<void> {
|
||||||
inputs.branch,
|
inputs.branch,
|
||||||
branchRemoteName,
|
branchRemoteName,
|
||||||
inputs.signoff,
|
inputs.signoff,
|
||||||
inputs.addPatternArray
|
inputs.addPaths
|
||||||
)
|
)
|
||||||
core.endGroup()
|
core.endGroup()
|
||||||
|
|
||||||
|
|
|
@ -8,6 +8,7 @@ async function run(): Promise<void> {
|
||||||
const inputs: Inputs = {
|
const inputs: Inputs = {
|
||||||
token: core.getInput('token'),
|
token: core.getInput('token'),
|
||||||
path: core.getInput('path'),
|
path: core.getInput('path'),
|
||||||
|
addPaths: utils.getInputAsArray('add-paths'),
|
||||||
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'),
|
||||||
|
@ -24,8 +25,7 @@ async function run(): Promise<void> {
|
||||||
reviewers: utils.getInputAsArray('reviewers'),
|
reviewers: utils.getInputAsArray('reviewers'),
|
||||||
teamReviewers: utils.getInputAsArray('team-reviewers'),
|
teamReviewers: utils.getInputAsArray('team-reviewers'),
|
||||||
milestone: Number(core.getInput('milestone')),
|
milestone: Number(core.getInput('milestone')),
|
||||||
draft: core.getInput('draft') === 'true',
|
draft: core.getInput('draft') === 'true'
|
||||||
addPatternArray: utils.getInputAsArray('add-pattern-array')
|
|
||||||
}
|
}
|
||||||
core.debug(`Inputs: ${inspect(inputs)}`)
|
core.debug(`Inputs: ${inspect(inputs)}`)
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue