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` |
|
||||
| `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` |
|
||||
| `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>` |
|
||||
|
@ -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. | |
|
||||
| `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` | |
|
||||
| `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.
|
||||
```yml
|
||||
|
@ -125,16 +125,18 @@ To use this strategy, set input `branch-suffix` with one of the following option
|
|||
|
||||
### Controlling committed files
|
||||
|
||||
You may control files to added on pull request with argument `add-pattern-array`.
|
||||
It specify `git add` pattern of files. By example:
|
||||
The action defaults to adding all new and modified files.
|
||||
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
|
||||
...
|
||||
uses: peter-evans/create-pull-request@main #TODO put next version here
|
||||
- name: Create Pull Request
|
||||
uses: peter-evans/create-pull-request@v3
|
||||
with:
|
||||
add-pattern-array: |
|
||||
**.txt
|
||||
**some/dirs**.png
|
||||
token: ${{ secrets.GITHUB_TOKEN }}
|
||||
add-paths: |
|
||||
*.java
|
||||
docs/\*.txt
|
||||
```
|
||||
|
||||
### Controlling commits
|
||||
|
|
11
action.yml
11
action.yml
|
@ -8,6 +8,13 @@ inputs:
|
|||
description: >
|
||||
Relative path under $GITHUB_WORKSPACE to the repository.
|
||||
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:
|
||||
description: 'The message to use when committing changes.'
|
||||
default: '[create-pull-request] automated change'
|
||||
|
@ -64,10 +71,6 @@ inputs:
|
|||
draft:
|
||||
description: 'Create a draft pull request'
|
||||
default: false
|
||||
add-pattern-array:
|
||||
description: 'git add [pattern]'
|
||||
default: |
|
||||
-A
|
||||
outputs:
|
||||
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())
|
||||
.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* () {
|
||||
// Get the working 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
|
||||
if (yield git.isDirty(true)) {
|
||||
core.info('Uncommitted changes found. Adding a commit.');
|
||||
for (const filePattern of filePatterns) {
|
||||
yield git.exec(['add', filePattern], true);
|
||||
for (const path of addPaths) {
|
||||
yield git.exec(['add', path], true);
|
||||
}
|
||||
const params = ['-m', commitMessage];
|
||||
if (signoff) {
|
||||
params.push('--signoff');
|
||||
}
|
||||
yield git.commit(params);
|
||||
// Remove uncommitted tracked and untracked changes
|
||||
git.exec(['reset', '--hard']);
|
||||
git.exec(['clean', '-f']);
|
||||
}
|
||||
|
@ -381,7 +382,7 @@ function createPullRequest(inputs) {
|
|||
core.endGroup();
|
||||
// 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();
|
||||
if (['created', 'updated'].includes(result.action)) {
|
||||
// The branch was created or updated
|
||||
|
@ -1078,6 +1079,7 @@ function run() {
|
|||
const inputs = {
|
||||
token: core.getInput('token'),
|
||||
path: core.getInput('path'),
|
||||
addPaths: utils.getInputAsArray('add-paths'),
|
||||
commitMessage: core.getInput('commit-message'),
|
||||
committer: core.getInput('committer'),
|
||||
author: core.getInput('author'),
|
||||
|
@ -1094,8 +1096,7 @@ function run() {
|
|||
reviewers: utils.getInputAsArray('reviewers'),
|
||||
teamReviewers: utils.getInputAsArray('team-reviewers'),
|
||||
milestone: Number(core.getInput('milestone')),
|
||||
draft: core.getInput('draft') === 'true',
|
||||
addPatternArray: utils.getInputAsArray('add-pattern-array')
|
||||
draft: core.getInput('draft') === 'true'
|
||||
};
|
||||
core.debug(`Inputs: ${(0, util_1.inspect)(inputs)}`);
|
||||
yield (0, create_pull_request_1.createPullRequest)(inputs);
|
||||
|
|
|
@ -92,7 +92,7 @@ export async function createOrUpdateBranch(
|
|||
branch: string,
|
||||
branchRemoteName: string,
|
||||
signoff: boolean,
|
||||
filePatterns: string[]
|
||||
addPaths: string[]
|
||||
): Promise<CreateOrUpdateBranchResult> {
|
||||
// Get the working 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
|
||||
if (await git.isDirty(true)) {
|
||||
core.info('Uncommitted changes found. Adding a commit.')
|
||||
for (const filePattern of filePatterns) {
|
||||
await git.exec(['add', filePattern], true)
|
||||
for (const path of addPaths) {
|
||||
await git.exec(['add', path], true)
|
||||
}
|
||||
const params = ['-m', commitMessage]
|
||||
if (signoff) {
|
||||
params.push('--signoff')
|
||||
}
|
||||
await git.commit(params)
|
||||
// Remove uncommitted tracked and untracked changes
|
||||
git.exec(['reset', '--hard'])
|
||||
git.exec(['clean', '-f'])
|
||||
}
|
||||
|
|
|
@ -12,6 +12,7 @@ import * as utils from './utils'
|
|||
export interface Inputs {
|
||||
token: string
|
||||
path: string
|
||||
addPaths: string[]
|
||||
commitMessage: string
|
||||
committer: string
|
||||
author: string
|
||||
|
@ -29,7 +30,6 @@ export interface Inputs {
|
|||
teamReviewers: string[]
|
||||
milestone: number
|
||||
draft: boolean
|
||||
addPatternArray: string[]
|
||||
}
|
||||
|
||||
export async function createPullRequest(inputs: Inputs): Promise<void> {
|
||||
|
@ -175,7 +175,7 @@ export async function createPullRequest(inputs: Inputs): Promise<void> {
|
|||
inputs.branch,
|
||||
branchRemoteName,
|
||||
inputs.signoff,
|
||||
inputs.addPatternArray
|
||||
inputs.addPaths
|
||||
)
|
||||
core.endGroup()
|
||||
|
||||
|
|
|
@ -8,6 +8,7 @@ async function run(): Promise<void> {
|
|||
const inputs: Inputs = {
|
||||
token: core.getInput('token'),
|
||||
path: core.getInput('path'),
|
||||
addPaths: utils.getInputAsArray('add-paths'),
|
||||
commitMessage: core.getInput('commit-message'),
|
||||
committer: core.getInput('committer'),
|
||||
author: core.getInput('author'),
|
||||
|
@ -24,8 +25,7 @@ async function run(): Promise<void> {
|
|||
reviewers: utils.getInputAsArray('reviewers'),
|
||||
teamReviewers: utils.getInputAsArray('team-reviewers'),
|
||||
milestone: Number(core.getInput('milestone')),
|
||||
draft: core.getInput('draft') === 'true',
|
||||
addPatternArray: utils.getInputAsArray('add-pattern-array')
|
||||
draft: core.getInput('draft') === 'true'
|
||||
}
|
||||
core.debug(`Inputs: ${inspect(inputs)}`)
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue