-
-
Notifications
You must be signed in to change notification settings - Fork 424
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* feat: update author and committer input defaults * Update github-actions[bot] * Update author to new email format * feat: optional input for git ops token * feat: allow push-to-fork to push to sibling repos (#2414) Fixes #2412. * build: update dist * feat: update action runtime to node 20 (#2340) * feat: add truncate warning to pull request body * perf: unshallow only when necessary * fix: remove the remote for the fork on completion * feat: infer github server and api urls * test: integration test fixes * build: bump major version * docs: update to v6 --------- Co-authored-by: Teko <[email protected]> Co-authored-by: Benjamin Gilbert <[email protected]>
- Loading branch information
1 parent
bb80902
commit b1ddad2
Showing
24 changed files
with
619 additions
and
490 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -11,8 +11,8 @@ on: | |
type: choice | ||
description: The major version tag to update | ||
options: | ||
- v4 | ||
- v5 | ||
- v6 | ||
|
||
jobs: | ||
tag: | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -21,7 +21,7 @@ Create Pull Request action will: | |
|
||
- [Concepts, guidelines and advanced usage](docs/concepts-guidelines.md) | ||
- [Examples](docs/examples.md) | ||
- [Updating to v5](docs/updating.md) | ||
- [Updating to v6](docs/updating.md) | ||
- [Common issues](docs/common-issues.md) | ||
|
||
## Usage | ||
|
@@ -32,10 +32,10 @@ Create Pull Request action will: | |
# Make changes to pull request here | ||
|
||
- name: Create Pull Request | ||
uses: peter-evans/create-pull-request@v5 | ||
uses: peter-evans/create-pull-request@v6 | ||
``` | ||
You can also pin to a [specific release](https://github.com/peter-evans/create-pull-request/releases) version in the format `@v5.x.x` | ||
You can also pin to a [specific release](https://github.com/peter-evans/create-pull-request/releases) version in the format `@v6.x.x` | ||
|
||
### Workflow permissions | ||
|
||
|
@@ -53,11 +53,12 @@ All inputs are **optional**. If not set, sensible defaults will be used. | |
| Name | Description | Default | | ||
| --- | --- | --- | | ||
| `token` | `GITHUB_TOKEN` (permissions `contents: write` and `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` | | ||
| `git-token` | The [Personal Access Token (PAT)](https://docs.github.com/en/github/authenticating-to-github/creating-a-personal-access-token) that the action will use for git operations. | Defaults to the value of `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. If no paths are specified, all new and modified files are added. See [Add specific paths](#add-specific-paths). | | | ||
| `commit-message` | The message to use when committing changes. See [commit-message](#commit-message). | `[create-pull-request] automated change` | | ||
| `committer` | The committer name and email address in the format `Display Name <[email protected]>`. Defaults to the GitHub Actions bot user. | `GitHub <noreply@github.com>` | | ||
| `author` | The author name and email address in the format `Display Name <[email protected]>`. Defaults to the user who triggered the workflow run. | `${{ github.actor }} <${{ github.actor }}@users.noreply.github.com>` | | ||
| `committer` | The committer name and email address in the format `Display Name <[email protected]>`. Defaults to the GitHub Actions bot user. | `github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>` | | ||
| `author` | The author name and email address in the format `Display Name <[email protected]>`. Defaults to the user who triggered the workflow run. | `${{ github.actor }} <${{ github.actor_id }}+${{ github.actor }}@users.noreply.github.com>` | | ||
| `signoff` | Add [`Signed-off-by`](https://git-scm.com/docs/git-commit#Documentation/git-commit.txt---signoff) line by the committer at the end of the commit log message. | `false` | | ||
| `branch` | The pull request branch name. | `create-pull-request/patch` | | ||
| `delete-branch` | Delete the `branch` if it doesn't have an active pull request associated with it. See [delete-branch](#delete-branch). | `false` | | ||
|
@@ -99,7 +100,7 @@ If you want branches to be deleted immediately on merge then you should use GitH | |
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@v5 | ||
uses: peter-evans/create-pull-request@v6 | ||
env: | ||
https_proxy: http://<proxy_address>:<port> | ||
``` | ||
|
@@ -119,7 +120,7 @@ Note that in order to read the step outputs the action step must have an id. | |
```yml | ||
- name: Create Pull Request | ||
id: cpr | ||
uses: peter-evans/create-pull-request@v5 | ||
uses: peter-evans/create-pull-request@v6 | ||
- name: Check outputs | ||
if: ${{ steps.cpr.outputs.pull-request-number }} | ||
run: | | ||
|
@@ -182,7 +183,7 @@ File changes that do not match one of the paths will be stashed and restored aft | |
|
||
```yml | ||
- name: Create Pull Request | ||
uses: peter-evans/create-pull-request@v5 | ||
uses: peter-evans/create-pull-request@v6 | ||
with: | ||
add-paths: | | ||
*.java | ||
|
@@ -209,7 +210,7 @@ Note that the repository must be checked out on a branch with a remote, it won't | |
- name: Uncommitted change | ||
run: date +%s > report.txt | ||
- name: Create Pull Request | ||
uses: peter-evans/create-pull-request@v5 | ||
uses: peter-evans/create-pull-request@v6 | ||
``` | ||
|
||
### Create a project card | ||
|
@@ -219,7 +220,7 @@ To create a project card for the pull request, pass the `pull-request-number` st | |
```yml | ||
- name: Create Pull Request | ||
id: cpr | ||
uses: peter-evans/create-pull-request@v5 | ||
uses: peter-evans/create-pull-request@v6 | ||
- name: Create or Update Project Card | ||
if: ${{ steps.cpr.outputs.pull-request-number }} | ||
|
@@ -254,12 +255,12 @@ jobs: | |
- name: Create Pull Request | ||
id: cpr | ||
uses: peter-evans/create-pull-request@v5 | ||
uses: peter-evans/create-pull-request@v6 | ||
with: | ||
token: ${{ secrets.PAT }} | ||
commit-message: Update report | ||
committer: GitHub <noreply@github.com> | ||
author: ${{ github.actor }} <${{ github.actor }}@users.noreply.github.com> | ||
committer: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> | ||
author: ${{ github.actor }} <${{ github.actor_id }}+${{ github.actor }}@users.noreply.github.com> | ||
signoff: false | ||
branch: example-patches | ||
delete-branch: true | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,18 +5,18 @@ set -euo pipefail | |
WORKINGDIR=$PWD | ||
|
||
# Create and serve a remote repo | ||
mkdir -p /git/remote | ||
mkdir -p /git/remote/repos | ||
git config --global init.defaultBranch main | ||
git init --bare /git/remote/test-base.git | ||
git init --bare /git/remote/repos/test-base.git | ||
git daemon --verbose --enable=receive-pack --base-path=/git/remote --export-all /git/remote &>/dev/null & | ||
|
||
# Give the daemon time to start | ||
sleep 2 | ||
|
||
# Create a local clone and make an initial commit | ||
mkdir -p /git/local | ||
git clone git://127.0.0.1/test-base.git /git/local/test-base | ||
cd /git/local/test-base | ||
mkdir -p /git/local/repos | ||
git clone git://127.0.0.1/repos/test-base.git /git/local/repos/test-base | ||
cd /git/local/repos/test-base | ||
git config --global user.email "[email protected]" | ||
git config --global user.name "Your Name" | ||
echo "#test-base" > README.md | ||
|
@@ -30,8 +30,8 @@ git config -l | |
|
||
# Clone a server-side fork of the base repo | ||
cd $WORKINGDIR | ||
git clone --mirror git://127.0.0.1/test-base.git /git/remote/test-fork.git | ||
cd /git/remote/test-fork.git | ||
git clone --mirror git://127.0.0.1/repos/test-base.git /git/remote/repos/test-fork.git | ||
cd /git/remote/repos/test-fork.git | ||
git log -1 --pretty=oneline | ||
|
||
# Restore the working directory | ||
|
58 changes: 37 additions & 21 deletions
58
__test__/git-auth-helper.int.test.ts → __test__/git-config-helper.int.test.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,70 +1,86 @@ | ||
import {GitCommandManager} from '../lib/git-command-manager' | ||
import {GitAuthHelper} from '../lib/git-auth-helper' | ||
import {GitConfigHelper} from '../lib/git-config-helper' | ||
|
||
const REPO_PATH = '/git/local/test-base' | ||
const REPO_PATH = '/git/local/repos/test-base' | ||
|
||
const extraheaderConfigKey = 'http.https://github.com/.extraheader' | ||
const extraheaderConfigKey = 'http.https://127.0.0.1/.extraheader' | ||
|
||
describe('git-auth-helper tests', () => { | ||
describe('git-config-helper integration tests', () => { | ||
let git: GitCommandManager | ||
let gitAuthHelper: GitAuthHelper | ||
let gitConfigHelper: GitConfigHelper | ||
|
||
beforeAll(async () => { | ||
git = await GitCommandManager.create(REPO_PATH) | ||
gitAuthHelper = new GitAuthHelper(git) | ||
}) | ||
|
||
it('tests save and restore with no persisted auth', async () => { | ||
await gitAuthHelper.savePersistedAuth() | ||
await gitAuthHelper.restorePersistedAuth() | ||
const gitConfigHelper = await GitConfigHelper.create(git) | ||
await gitConfigHelper.close() | ||
}) | ||
|
||
it('tests configure and removal of auth', async () => { | ||
await gitAuthHelper.configureToken('github-token') | ||
const gitConfigHelper = await GitConfigHelper.create(git) | ||
await gitConfigHelper.configureToken('github-token') | ||
expect(await git.configExists(extraheaderConfigKey)).toBeTruthy() | ||
expect(await git.getConfigValue(extraheaderConfigKey)).toEqual( | ||
'AUTHORIZATION: basic eC1hY2Nlc3MtdG9rZW46Z2l0aHViLXRva2Vu' | ||
) | ||
|
||
await gitAuthHelper.removeAuth() | ||
await gitConfigHelper.close() | ||
expect(await git.configExists(extraheaderConfigKey)).toBeFalsy() | ||
}) | ||
|
||
it('tests save and restore of persisted auth', async () => { | ||
const extraheaderConfigValue = 'AUTHORIZATION: basic ***persisted-auth***' | ||
await git.config(extraheaderConfigKey, extraheaderConfigValue) | ||
|
||
await gitAuthHelper.savePersistedAuth() | ||
const gitConfigHelper = await GitConfigHelper.create(git) | ||
|
||
const exists = await git.configExists(extraheaderConfigKey) | ||
expect(exists).toBeFalsy() | ||
|
||
await gitAuthHelper.restorePersistedAuth() | ||
await gitConfigHelper.close() | ||
|
||
const configValue = await git.getConfigValue(extraheaderConfigKey) | ||
expect(configValue).toEqual(extraheaderConfigValue) | ||
|
||
await gitAuthHelper.removeAuth() | ||
const unset = await git.tryConfigUnset( | ||
extraheaderConfigKey, | ||
'^AUTHORIZATION:' | ||
) | ||
expect(unset).toBeTruthy() | ||
}) | ||
|
||
it('tests adding and removing the safe.directory config', async () => { | ||
it('tests not adding/removing the safe.directory config when it already exists', async () => { | ||
await git.config('safe.directory', '/another-value', true, true) | ||
|
||
await gitAuthHelper.removeSafeDirectory() | ||
await gitAuthHelper.addSafeDirectory() | ||
const gitConfigHelper = await GitConfigHelper.create(git) | ||
|
||
expect( | ||
await git.configExists('safe.directory', '/another-value', true) | ||
).toBeTruthy() | ||
|
||
await gitConfigHelper.close() | ||
|
||
const unset = await git.tryConfigUnset( | ||
'safe.directory', | ||
'/another-value', | ||
true | ||
) | ||
expect(unset).toBeTruthy() | ||
}) | ||
|
||
it('tests adding and removing the safe.directory config', async () => { | ||
const gitConfigHelper = await GitConfigHelper.create(git) | ||
|
||
expect( | ||
await git.configExists('safe.directory', REPO_PATH, true) | ||
).toBeTruthy() | ||
|
||
await gitAuthHelper.addSafeDirectory() | ||
await gitAuthHelper.removeSafeDirectory() | ||
await gitConfigHelper.close() | ||
|
||
expect( | ||
await git.configExists('safe.directory', REPO_PATH, true) | ||
).toBeFalsy() | ||
expect( | ||
await git.configExists('safe.directory', '/another-value', true) | ||
).toBeTruthy() | ||
}) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,93 @@ | ||
import {GitConfigHelper} from '../lib/git-config-helper' | ||
|
||
describe('git-config-helper unit tests', () => { | ||
test('parseGitRemote successfully parses HTTPS remote URLs', async () => { | ||
const remote1 = GitConfigHelper.parseGitRemote( | ||
'https://github.com/peter-evans/create-pull-request' | ||
) | ||
expect(remote1.hostname).toEqual('github.com') | ||
expect(remote1.protocol).toEqual('HTTPS') | ||
expect(remote1.repository).toEqual('peter-evans/create-pull-request') | ||
|
||
const remote2 = GitConfigHelper.parseGitRemote( | ||
'https://xxx:[email protected]/peter-evans/create-pull-request' | ||
) | ||
expect(remote2.hostname).toEqual('github.com') | ||
expect(remote2.protocol).toEqual('HTTPS') | ||
expect(remote2.repository).toEqual('peter-evans/create-pull-request') | ||
|
||
const remote3 = GitConfigHelper.parseGitRemote( | ||
'https://github.com/peter-evans/create-pull-request.git' | ||
) | ||
expect(remote3.hostname).toEqual('github.com') | ||
expect(remote3.protocol).toEqual('HTTPS') | ||
expect(remote3.repository).toEqual('peter-evans/create-pull-request') | ||
|
||
const remote4 = GitConfigHelper.parseGitRemote( | ||
'https://github.com/peter-evans/ungit' | ||
) | ||
expect(remote4.hostname).toEqual('github.com') | ||
expect(remote4.protocol).toEqual('HTTPS') | ||
expect(remote4.repository).toEqual('peter-evans/ungit') | ||
|
||
const remote5 = GitConfigHelper.parseGitRemote( | ||
'https://github.com/peter-evans/ungit.git' | ||
) | ||
expect(remote5.hostname).toEqual('github.com') | ||
expect(remote5.protocol).toEqual('HTTPS') | ||
expect(remote5.repository).toEqual('peter-evans/ungit') | ||
|
||
const remote6 = GitConfigHelper.parseGitRemote( | ||
'https://github.internal.company/peter-evans/create-pull-request' | ||
) | ||
expect(remote6.hostname).toEqual('github.internal.company') | ||
expect(remote6.protocol).toEqual('HTTPS') | ||
expect(remote6.repository).toEqual('peter-evans/create-pull-request') | ||
}) | ||
|
||
test('parseGitRemote successfully parses SSH remote URLs', async () => { | ||
const remote1 = GitConfigHelper.parseGitRemote( | ||
'[email protected]:peter-evans/create-pull-request.git' | ||
) | ||
expect(remote1.hostname).toEqual('github.com') | ||
expect(remote1.protocol).toEqual('SSH') | ||
expect(remote1.repository).toEqual('peter-evans/create-pull-request') | ||
|
||
const remote2 = GitConfigHelper.parseGitRemote( | ||
'[email protected]:peter-evans/ungit.git' | ||
) | ||
expect(remote2.hostname).toEqual('github.com') | ||
expect(remote2.protocol).toEqual('SSH') | ||
expect(remote2.repository).toEqual('peter-evans/ungit') | ||
|
||
const remote3 = GitConfigHelper.parseGitRemote( | ||
'[email protected]:peter-evans/create-pull-request.git' | ||
) | ||
expect(remote3.hostname).toEqual('github.internal.company') | ||
expect(remote3.protocol).toEqual('SSH') | ||
expect(remote3.repository).toEqual('peter-evans/create-pull-request') | ||
}) | ||
|
||
test('parseGitRemote successfully parses GIT remote URLs', async () => { | ||
// Unauthenticated git protocol for integration tests only | ||
const remote1 = GitConfigHelper.parseGitRemote( | ||
'git://127.0.0.1/repos/test-base.git' | ||
) | ||
expect(remote1.hostname).toEqual('127.0.0.1') | ||
expect(remote1.protocol).toEqual('GIT') | ||
expect(remote1.repository).toEqual('repos/test-base') | ||
}) | ||
|
||
test('parseGitRemote fails to parse a remote URL', async () => { | ||
const remoteUrl = 'https://github.com/peter-evans' | ||
try { | ||
GitConfigHelper.parseGitRemote(remoteUrl) | ||
// Fail the test if an error wasn't thrown | ||
expect(true).toEqual(false) | ||
} catch (e: any) { | ||
expect(e.message).toEqual( | ||
`The format of '${remoteUrl}' is not a valid GitHub repository URL` | ||
) | ||
} | ||
}) | ||
}) |
Oops, something went wrong.