mirror of
https://github.com/peter-evans/create-pull-request.git
synced 2026-12-03 04:49:02 +00:00
Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
67df31e08a | ||
|
|
f530141cd3 | ||
|
|
a5a72ba246 | ||
|
|
a6c8b3814a | ||
|
|
c0a9598b0e | ||
|
|
3c3d696d5b | ||
|
|
bd0f84d69c | ||
|
|
ad71e1f128 | ||
|
|
368c9da6f6 | ||
|
|
d8a389d1fa | ||
|
|
225cf628aa | ||
|
|
d7a8d0affc | ||
|
|
2dc79e58de | ||
|
|
95767e7d51 | ||
|
|
3263596ac4 | ||
|
|
3e21ec0c82 | ||
|
|
5050a372c9 | ||
|
|
7380612b49 | ||
|
|
771ad1b5f4 | ||
|
|
093c191148 | ||
|
|
00cb0abb4d | ||
|
|
fa0950476f | ||
|
|
b90b9c1e20 | ||
|
|
028a63020c | ||
|
|
9d59234a82 | ||
|
|
210f7aab2c | ||
|
|
6bb7394339 | ||
|
|
a518698c07 | ||
|
|
8be395fdd3 | ||
|
|
36d063872e | ||
|
|
9825ae65b1 | ||
|
|
243251cf92 | ||
|
|
28beef91aa |
No files matched your search
@@ -64,6 +64,14 @@ All inputs are **optional**. If not set, sensible defaults will be used.
|
||||
| `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` |
|
||||
|
||||
For self-hosted runners behind a corporate proxy set the `https_proxy` environment variable.
|
||||
```yml
|
||||
- name: Create Pull Request
|
||||
uses: peter-evans/create-pull-request@v3
|
||||
env:
|
||||
https_proxy: http://<proxy_address>:<port>
|
||||
```
|
||||
|
||||
### Action outputs
|
||||
|
||||
The following outputs can be used by subsequent workflow steps.
|
||||
@@ -71,6 +79,7 @@ The following outputs can be used by subsequent workflow steps.
|
||||
- `pull-request-number` - The pull request number.
|
||||
- `pull-request-url` - The URL of the pull request.
|
||||
- `pull-request-operation` - The pull request operation performed by the action, `created`, `updated` or `closed`.
|
||||
- `pull-request-head-sha` - The commit SHA of the pull request branch.
|
||||
|
||||
Step outputs can be accessed as in the following example.
|
||||
Note that in order to read the step outputs the action step must have an id.
|
||||
@@ -207,11 +216,6 @@ jobs:
|
||||
maintainers
|
||||
milestone: 1
|
||||
draft: false
|
||||
|
||||
- name: Check outputs
|
||||
run: |
|
||||
echo "Pull Request Number - ${{ steps.cpr.outputs.pull-request-number }}"
|
||||
echo "Pull Request URL - ${{ steps.cpr.outputs.pull-request-url }}"
|
||||
```
|
||||
|
||||
An example based on the above reference configuration creates pull requests that look like this:
|
||||
|
||||
@@ -1740,4 +1740,26 @@ describe('create-or-update-branch tests', () => {
|
||||
])
|
||||
).toBeTruthy()
|
||||
})
|
||||
|
||||
// This failure mode is a limitation of the action. Controlling your own commits cannot be used in detached HEAD state.
|
||||
// https://github.com/peter-evans/create-pull-request/issues/902
|
||||
it('tests failure to create with commits on the working base (during the workflow) in detached HEAD state (WBNR)', async () => {
|
||||
// Checkout the HEAD commit SHA
|
||||
const headSha = await git.revParse('HEAD')
|
||||
await git.checkout(headSha)
|
||||
|
||||
// Create commits on the working base
|
||||
const commits = await createCommits(git)
|
||||
const commitMessage = uuidv4()
|
||||
const result = await createOrUpdateBranch(
|
||||
git,
|
||||
commitMessage,
|
||||
BASE,
|
||||
BRANCH,
|
||||
REMOTE_NAME,
|
||||
false
|
||||
)
|
||||
// The action cannot successfully create the branch
|
||||
expect(result.action).toEqual('none')
|
||||
})
|
||||
})
|
||||
@@ -16,7 +16,7 @@ COPY __test__/entrypoint.sh /entrypoint.sh
|
||||
ENTRYPOINT ["/entrypoint.sh"]
|
||||
EOF
|
||||
|
||||
docker build -t $IMAGE .
|
||||
docker build --no-cache -t $IMAGE .
|
||||
rm Dockerfile
|
||||
fi
|
||||
|
||||
|
||||
@@ -58,7 +58,7 @@ describe('utils tests', () => {
|
||||
utils.getRemoteDetail(remoteUrl)
|
||||
// Fail the test if an error wasn't thrown
|
||||
expect(true).toEqual(false)
|
||||
} catch (e) {
|
||||
} catch (e: any) {
|
||||
expect(e.message).toEqual(
|
||||
`The format of '${remoteUrl}' is not a valid GitHub repository URL`
|
||||
)
|
||||
@@ -104,7 +104,7 @@ describe('utils tests', () => {
|
||||
utils.parseDisplayNameEmail(displayNameEmail1)
|
||||
// Fail the test if an error wasn't thrown
|
||||
expect(true).toEqual(false)
|
||||
} catch (e) {
|
||||
} catch (e: any) {
|
||||
expect(e.message).toEqual(
|
||||
`The format of '${displayNameEmail1}' is not a valid email address with display name`
|
||||
)
|
||||
@@ -115,7 +115,7 @@ describe('utils tests', () => {
|
||||
utils.parseDisplayNameEmail(displayNameEmail2)
|
||||
// Fail the test if an error wasn't thrown
|
||||
expect(true).toEqual(false)
|
||||
} catch (e) {
|
||||
} catch (e: any) {
|
||||
expect(e.message).toEqual(
|
||||
`The format of '${displayNameEmail2}' is not a valid email address with display name`
|
||||
)
|
||||
|
||||
@@ -67,6 +67,12 @@ inputs:
|
||||
outputs:
|
||||
pull-request-number:
|
||||
description: 'The pull request number'
|
||||
pull-request-url:
|
||||
description: 'The URL of the pull request.'
|
||||
pull-request-operation:
|
||||
description: 'The pull request operation performed by the action, `created`, `updated` or `closed`.'
|
||||
pull-request-head-sha:
|
||||
description: 'The commit SHA of the pull request branch.'
|
||||
runs:
|
||||
using: 'node12'
|
||||
main: 'dist/index.js'
|
||||
|
||||
Vendored
+3510
-689
File diff suppressed because it is too large.
Load diff
Generated
+2170
-10744
File diff suppressed because it is too large.
Load diff
+18
-17
@@ -29,26 +29,27 @@
|
||||
},
|
||||
"homepage": "https://github.com/peter-evans/create-pull-request",
|
||||
"dependencies": {
|
||||
"@actions/core": "1.2.7",
|
||||
"@actions/exec": "1.0.4",
|
||||
"@octokit/core": "3.4.0",
|
||||
"@octokit/plugin-paginate-rest": "2.13.3",
|
||||
"@octokit/plugin-rest-endpoint-methods": "5.1.1",
|
||||
"@actions/core": "1.6.0",
|
||||
"@actions/exec": "1.1.0",
|
||||
"@octokit/core": "3.5.1",
|
||||
"@octokit/plugin-paginate-rest": "2.16.7",
|
||||
"@octokit/plugin-rest-endpoint-methods": "5.11.4",
|
||||
"https-proxy-agent": "5.0.0",
|
||||
"uuid": "8.3.2"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@types/jest": "26.0.23",
|
||||
"@types/node": "15.0.3",
|
||||
"@typescript-eslint/parser": "4.23.0",
|
||||
"@vercel/ncc": "0.28.5",
|
||||
"eslint": "7.26.0",
|
||||
"eslint-plugin-github": "4.1.3",
|
||||
"eslint-plugin-jest": "24.3.6",
|
||||
"jest": "26.6.3",
|
||||
"jest-circus": "26.6.3",
|
||||
"@types/jest": "27.0.2",
|
||||
"@types/node": "16.10.3",
|
||||
"@typescript-eslint/parser": "4.33.0",
|
||||
"@vercel/ncc": "0.31.1",
|
||||
"eslint": "7.32.0",
|
||||
"eslint-plugin-github": "4.3.2",
|
||||
"eslint-plugin-jest": "24.5.2",
|
||||
"jest": "27.2.4",
|
||||
"jest-circus": "27.2.4",
|
||||
"js-yaml": "4.1.0",
|
||||
"prettier": "2.3.0",
|
||||
"ts-jest": "26.5.6",
|
||||
"typescript": "4.2.4"
|
||||
"prettier": "2.4.1",
|
||||
"ts-jest": "27.0.5",
|
||||
"typescript": "4.4.3"
|
||||
}
|
||||
}
|
||||
@@ -110,7 +110,8 @@ export async function createOrUpdateBranch(
|
||||
const result: CreateOrUpdateBranchResult = {
|
||||
action: 'none',
|
||||
base: base,
|
||||
hasDiffWithBase: false
|
||||
hasDiffWithBase: false,
|
||||
headSha: ''
|
||||
}
|
||||
|
||||
// Save the working base changes to a temporary branch
|
||||
@@ -231,6 +232,9 @@ export async function createOrUpdateBranch(
|
||||
result.hasDiffWithBase = await isAhead(git, base, branch)
|
||||
}
|
||||
|
||||
// Get the pull request branch SHA
|
||||
result.headSha = await git.revParse('HEAD')
|
||||
|
||||
// Delete the temporary branch
|
||||
await git.exec(['branch', '--delete', '--force', tempBranch])
|
||||
|
||||
@@ -241,4 +245,5 @@ interface CreateOrUpdateBranchResult {
|
||||
action: string
|
||||
base: string
|
||||
hasDiffWithBase: boolean
|
||||
headSha: string
|
||||
}
|
||||
@@ -212,6 +212,7 @@ export async function createPullRequest(inputs: Inputs): Promise<void> {
|
||||
} else if (result.action == 'updated') {
|
||||
core.setOutput('pull-request-operation', 'updated')
|
||||
}
|
||||
core.setOutput('pull-request-head-sha', result.headSha)
|
||||
// Deprecated
|
||||
core.exportVariable('PULL_REQUEST_NUMBER', pull.number)
|
||||
core.endGroup()
|
||||
@@ -237,7 +238,7 @@ export async function createPullRequest(inputs: Inputs): Promise<void> {
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch (error) {
|
||||
} catch (error: any) {
|
||||
core.setFailed(error.message)
|
||||
} finally {
|
||||
// Remove auth and restore persisted auth config if it existed
|
||||
|
||||
@@ -33,7 +33,7 @@ export class GitAuthHelper {
|
||||
try {
|
||||
await this.setExtraheaderConfig(this.persistedExtraheaderConfigValue)
|
||||
core.info('Persisted git credentials restored')
|
||||
} catch (e) {
|
||||
} catch (e: any) {
|
||||
core.warning(e)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -60,7 +60,7 @@ export class GitHubHelper {
|
||||
html_url: pull.html_url,
|
||||
created: true
|
||||
}
|
||||
} catch (e) {
|
||||
} catch (e: any) {
|
||||
if (
|
||||
e.message &&
|
||||
e.message.includes(`A pull request already exists for ${headBranch}`)
|
||||
@@ -165,7 +165,7 @@ export class GitHubHelper {
|
||||
pull_number: pull.number,
|
||||
...requestReviewersParams
|
||||
})
|
||||
} catch (e) {
|
||||
} catch (e: any) {
|
||||
if (e.message && e.message.includes(ERROR_PR_REVIEW_FROM_AUTHOR)) {
|
||||
core.warning(ERROR_PR_REVIEW_FROM_AUTHOR)
|
||||
} else {
|
||||
|
||||
+1
-1
@@ -29,7 +29,7 @@ async function run(): Promise<void> {
|
||||
core.debug(`Inputs: ${inspect(inputs)}`)
|
||||
|
||||
await createPullRequest(inputs)
|
||||
} catch (error) {
|
||||
} catch (error: any) {
|
||||
core.setFailed(error.message)
|
||||
}
|
||||
}
|
||||
|
||||
+17
-1
@@ -1,7 +1,23 @@
|
||||
import {Octokit as Core} from '@octokit/core'
|
||||
import {paginateRest} from '@octokit/plugin-paginate-rest'
|
||||
import {restEndpointMethods} from '@octokit/plugin-rest-endpoint-methods'
|
||||
import {HttpsProxyAgent} from 'https-proxy-agent'
|
||||
export {RestEndpointMethodTypes} from '@octokit/plugin-rest-endpoint-methods'
|
||||
export {OctokitOptions} from '@octokit/core/dist-types/types'
|
||||
|
||||
export const Octokit = Core.plugin(paginateRest, restEndpointMethods)
|
||||
export const Octokit = Core.plugin(
|
||||
paginateRest,
|
||||
restEndpointMethods,
|
||||
autoProxyAgent
|
||||
)
|
||||
|
||||
// Octokit plugin to support the https_proxy environment variable
|
||||
function autoProxyAgent(octokit: Core) {
|
||||
const proxy = process.env.https_proxy || process.env.HTTPS_PROXY
|
||||
if (!proxy) return
|
||||
|
||||
const agent = new HttpsProxyAgent(proxy)
|
||||
octokit.hook.before('request', options => {
|
||||
options.request.agent = agent
|
||||
})
|
||||
}
|
||||
+1
-1
@@ -134,7 +134,7 @@ export function fileExistsSync(path: string): boolean {
|
||||
let stats: fs.Stats
|
||||
try {
|
||||
stats = fs.statSync(path)
|
||||
} catch (error) {
|
||||
} catch (error: any) {
|
||||
if (error.code === 'ENOENT') {
|
||||
return false
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user