Compare commits

..

28 Commits

Author SHA1 Message Date
Peter Evans aa523f9db6 refactor: replace uuid dep with Node.js built-in crypto.randomUUID (#4377)
Replace the third-party `uuid` package with the native `crypto.randomUUID()`
function available in Node.js, reducing the bundle size and external
dependencies.

- Remove `uuid` from `dependencies` in `package.json`
- Replace `import {v4 as uuidv4} from 'uuid'` with `import {randomUUID} from 'crypto'` in `src/create-or-update-branch.ts`
- Replace all `uuidv4()` calls with `randomUUID()` in `__test__/create-or-update-branch.int.test.ts`
- Rebuild `dist/index.js`, removing ~680 lines of bundled `uuid` library code
- Update `package-lock.json` to reflect removed dependency
2026-05-06 12:10:34 +01:00
dependabot[bot] d8c15c739f build(deps-dev): bump the npm group with 2 updates (#4372)
Bumps the npm group with 2 updates: [prettier](https://github.com/prettier/prettier) and [undici](https://github.com/nodejs/undici).


Updates `prettier` from 3.8.1 to 3.8.3
- [Release notes](https://github.com/prettier/prettier/releases)
- [Changelog](https://github.com/prettier/prettier/blob/main/CHANGELOG.md)
- [Commits](https://github.com/prettier/prettier/compare/3.8.1...3.8.3)

Updates `undici` from 6.24.1 to 6.25.0
- [Release notes](https://github.com/nodejs/undici/releases)
- [Commits](https://github.com/nodejs/undici/compare/v6.24.1...v6.25.0)

---
updated-dependencies:
- dependency-name: prettier
  dependency-version: 3.8.3
  dependency-type: direct:development
  update-type: version-update:semver-patch
  dependency-group: npm
- dependency-name: undici
  dependency-version: 6.25.0
  dependency-type: direct:development
  update-type: version-update:semver-minor
  dependency-group: npm
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2026-05-01 14:37:34 +00:00
actions-bot eec7ab75b2 build: update distribution (#4361)
Co-authored-by: peter-evans <18365890+peter-evans@users.noreply.github.com>
2026-04-10 17:35:29 +01:00
Peter Evans 5f6978faf0 fix: retry post-creation API calls on 422 eventual consistency errors (#4356)
Add retry logic to handle GitHub API eventual consistency errors that
can occur after creating a new pull request. Follow-up API calls for
milestones, labels, assignees, and reviewers may fail with a 422
"Could not resolve to a node" error before the PR is fully propagated.

- Add generic `retryWithBackoff` helper in `src/utils.ts` with
  exponential backoff (default 2 retries, starting at 1s delay)
- Wrap post-creation API calls in `src/github-helper.ts` with
  `withRetryForNewPr()`, which only retries for newly created PRs
- Use `@octokit/request-error` `RequestError` type for precise error
  matching (status 422 + "Could not resolve to a node" message)
- Add unit tests for `retryWithBackoff` covering success, retry,
  exhaustion, and non-retryable error scenarios
- Update `dist/index.js` bundle and `package.json` dependencies
2026-04-10 17:23:55 +01:00
dependabot[bot] d32e88dac7 build(deps-dev): bump the npm group with 3 updates (#4349)
Bumps the npm group with 3 updates: [jest-environment-jsdom](https://github.com/jestjs/jest/tree/HEAD/packages/jest-environment-jsdom), [ts-jest](https://github.com/kulshekhar/ts-jest) and [undici](https://github.com/nodejs/undici).


Updates `jest-environment-jsdom` from 30.2.0 to 30.3.0
- [Release notes](https://github.com/jestjs/jest/releases)
- [Changelog](https://github.com/jestjs/jest/blob/main/CHANGELOG.md)
- [Commits](https://github.com/jestjs/jest/commits/v30.3.0/packages/jest-environment-jsdom)

Updates `ts-jest` from 29.4.6 to 29.4.9
- [Release notes](https://github.com/kulshekhar/ts-jest/releases)
- [Changelog](https://github.com/kulshekhar/ts-jest/blob/main/CHANGELOG.md)
- [Commits](https://github.com/kulshekhar/ts-jest/compare/v29.4.6...v29.4.9)

Updates `undici` from 6.24.0 to 6.24.1
- [Release notes](https://github.com/nodejs/undici/releases)
- [Commits](https://github.com/nodejs/undici/compare/v6.24.0...v6.24.1)

---
updated-dependencies:
- dependency-name: jest-environment-jsdom
  dependency-version: 30.3.0
  dependency-type: direct:development
  update-type: version-update:semver-minor
  dependency-group: npm
- dependency-name: ts-jest
  dependency-version: 29.4.9
  dependency-type: direct:development
  update-type: version-update:semver-patch
  dependency-group: npm
- dependency-name: undici
  dependency-version: 6.24.1
  dependency-type: direct:development
  update-type: version-update:semver-patch
  dependency-group: npm
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2026-04-01 15:23:34 +00:00
dependabot[bot] 8170bccad1 build(deps-dev): bump handlebars from 4.7.8 to 4.7.9 (#4344)
Bumps [handlebars](https://github.com/handlebars-lang/handlebars.js) from 4.7.8 to 4.7.9.
- [Release notes](https://github.com/handlebars-lang/handlebars.js/releases)
- [Changelog](https://github.com/handlebars-lang/handlebars.js/blob/v4.7.9/release-notes.md)
- [Commits](https://github.com/handlebars-lang/handlebars.js/compare/v4.7.8...v4.7.9)

---
updated-dependencies:
- dependency-name: handlebars
  dependency-version: 4.7.9
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2026-03-27 20:17:57 +00:00
dependabot[bot] 00418193b4 build(deps): bump picomatch (#4339)
Bumps  and [picomatch](https://github.com/micromatch/picomatch). These dependencies needed to be updated together.

Updates `picomatch` from 2.3.1 to 2.3.2
- [Release notes](https://github.com/micromatch/picomatch/releases)
- [Changelog](https://github.com/micromatch/picomatch/blob/master/CHANGELOG.md)
- [Commits](https://github.com/micromatch/picomatch/compare/2.3.1...2.3.2)

Updates `picomatch` from 4.0.2 to 4.0.4
- [Release notes](https://github.com/micromatch/picomatch/releases)
- [Changelog](https://github.com/micromatch/picomatch/blob/master/CHANGELOG.md)
- [Commits](https://github.com/micromatch/picomatch/compare/2.3.1...2.3.2)

Updates `picomatch` from 4.0.3 to 4.0.4
- [Release notes](https://github.com/micromatch/picomatch/releases)
- [Changelog](https://github.com/micromatch/picomatch/blob/master/CHANGELOG.md)
- [Commits](https://github.com/micromatch/picomatch/compare/2.3.1...2.3.2)

---
updated-dependencies:
- dependency-name: picomatch
  dependency-version: 2.3.2
  dependency-type: indirect
- dependency-name: picomatch
  dependency-version: 4.0.4
  dependency-type: indirect
- dependency-name: picomatch
  dependency-version: 4.0.4
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2026-03-25 21:50:05 +00:00
dependabot[bot] b993918c85 build(deps-dev): bump flatted from 3.3.1 to 3.4.2 (#4334)
Bumps [flatted](https://github.com/WebReflection/flatted) from 3.3.1 to 3.4.2.
- [Commits](https://github.com/WebReflection/flatted/compare/v3.3.1...v3.4.2)

---
updated-dependencies:
- dependency-name: flatted
  dependency-version: 3.4.2
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2026-03-20 00:22:17 +00:00
dependabot[bot] 36d7c8468b build(deps-dev): bump undici from 6.23.0 to 6.24.0 (#4328)
Bumps [undici](https://github.com/nodejs/undici) from 6.23.0 to 6.24.0.
- [Release notes](https://github.com/nodejs/undici/releases)
- [Commits](https://github.com/nodejs/undici/compare/v6.23.0...v6.24.0)

---
updated-dependencies:
- dependency-name: undici
  dependency-version: 6.24.0
  dependency-type: direct:development
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2026-03-14 06:18:43 +00:00
dependabot[bot] a45d1fb447 build(deps): bump @tootallnate/once and jest-environment-jsdom (#4323)
Removes [@tootallnate/once](https://github.com/TooTallNate/once). It's no longer used after updating ancestor dependency [jest-environment-jsdom](https://github.com/jestjs/jest/tree/HEAD/packages/jest-environment-jsdom). These dependencies need to be updated together.


Removes `@tootallnate/once`

Updates `jest-environment-jsdom` from 29.7.0 to 30.2.0
- [Release notes](https://github.com/jestjs/jest/releases)
- [Changelog](https://github.com/jestjs/jest/blob/main/CHANGELOG.md)
- [Commits](https://github.com/jestjs/jest/commits/v30.2.0/packages/jest-environment-jsdom)

---
updated-dependencies:
- dependency-name: "@tootallnate/once"
  dependency-version: 
  dependency-type: indirect
- dependency-name: jest-environment-jsdom
  dependency-version: 30.2.0
  dependency-type: direct:development
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2026-03-05 06:14:22 +00:00
dependabot[bot] 3499eb6183 build(deps): bump the github-actions group with 2 updates (#4316)
Bumps the github-actions group with 2 updates: [actions/upload-artifact](https://github.com/actions/upload-artifact) and [actions/download-artifact](https://github.com/actions/download-artifact).


Updates `actions/upload-artifact` from 6 to 7
- [Release notes](https://github.com/actions/upload-artifact/releases)
- [Commits](https://github.com/actions/upload-artifact/compare/v6...v7)

Updates `actions/download-artifact` from 7 to 8
- [Release notes](https://github.com/actions/download-artifact/releases)
- [Commits](https://github.com/actions/download-artifact/compare/v7...v8)

---
updated-dependencies:
- dependency-name: actions/upload-artifact
  dependency-version: '7'
  dependency-type: direct:production
  update-type: version-update:semver-major
  dependency-group: github-actions
- dependency-name: actions/download-artifact
  dependency-version: '8'
  dependency-type: direct:production
  update-type: version-update:semver-major
  dependency-group: github-actions
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2026-03-01 12:34:50 +00:00
dependabot[bot] 3f3b473b8c build(deps): bump minimatch (#4311)
Bumps  and [minimatch](https://github.com/isaacs/minimatch). These dependencies needed to be updated together.

Updates `minimatch` from 3.1.2 to 3.1.5
- [Changelog](https://github.com/isaacs/minimatch/blob/main/changelog.md)
- [Commits](https://github.com/isaacs/minimatch/compare/v3.1.2...v3.1.5)

Updates `minimatch` from 9.0.5 to 9.0.9
- [Changelog](https://github.com/isaacs/minimatch/blob/main/changelog.md)
- [Commits](https://github.com/isaacs/minimatch/compare/v3.1.2...v3.1.5)

---
updated-dependencies:
- dependency-name: minimatch
  dependency-version: 3.1.5
  dependency-type: indirect
- dependency-name: minimatch
  dependency-version: 9.0.9
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2026-02-28 06:50:02 +00:00
dependabot[bot] 6699836a21 build(deps-dev): bump the npm group with 2 updates (#4305)
Bumps the npm group with 2 updates: [eslint-plugin-prettier](https://github.com/prettier/eslint-plugin-prettier) and [prettier](https://github.com/prettier/prettier).


Updates `eslint-plugin-prettier` from 5.5.4 to 5.5.5
- [Release notes](https://github.com/prettier/eslint-plugin-prettier/releases)
- [Changelog](https://github.com/prettier/eslint-plugin-prettier/blob/main/CHANGELOG.md)
- [Commits](https://github.com/prettier/eslint-plugin-prettier/compare/v5.5.4...v5.5.5)

Updates `prettier` from 3.7.4 to 3.8.1
- [Release notes](https://github.com/prettier/prettier/releases)
- [Changelog](https://github.com/prettier/prettier/blob/main/CHANGELOG.md)
- [Commits](https://github.com/prettier/prettier/compare/3.7.4...3.8.1)

---
updated-dependencies:
- dependency-name: eslint-plugin-prettier
  dependency-version: 5.5.5
  dependency-type: direct:development
  update-type: version-update:semver-patch
  dependency-group: npm
- dependency-name: prettier
  dependency-version: 3.8.1
  dependency-type: direct:development
  update-type: version-update:semver-minor
  dependency-group: npm
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2026-02-01 12:35:41 +00:00
Peter Evans c0f553fe54 feat: add @octokit/plugin-retry to handle retriable server errors (#4298)
Add the retry plugin to automatically retry requests that fail with
server errors (5xx status codes). Configure the plugin to exclude 429
(rate limit) from retries since that is already handled by the
throttling plugin.

- Add @octokit/plugin-retry dependency
- Register retry plugin in Octokit client
- Export retryOptions with doNotRetry list excluding 429
- Apply retryOptions in GitHubHelper constructor
2026-01-21 15:20:27 +00:00
Peter Evans 70001242bf fix: Handle remote prune failures gracefully (#4295)
Wrap the git remote prune command in a try-catch block to prevent
the action from failing if the prune operation fails. Instead, log
a warning message and allow the action to continue.

Fixes edge cases where the prune command may fail on self-hosted
runners but shouldn't block the pull request creation workflow.
2026-01-21 15:04:51 +00:00
actions-bot 34aa40e9cf build: update distribution (#4289) 2026-01-15 07:55:19 +00:00
dependabot[bot] 641099ddca build(deps-dev): bump undici from 6.22.0 to 6.23.0 (#4284)
Bumps [undici](https://github.com/nodejs/undici) from 6.22.0 to 6.23.0.
- [Release notes](https://github.com/nodejs/undici/releases)
- [Commits](https://github.com/nodejs/undici/compare/v6.22.0...v6.23.0)

---
updated-dependencies:
- dependency-name: undici
  dependency-version: 6.23.0
  dependency-type: direct:development
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2026-01-15 00:49:39 +00:00
dependabot[bot] 2271f1ddcf build(deps-dev): bump the npm group with 2 updates (#4274)
Bumps the npm group with 2 updates: [prettier](https://github.com/prettier/prettier) and [ts-jest](https://github.com/kulshekhar/ts-jest).


Updates `prettier` from 3.7.3 to 3.7.4
- [Release notes](https://github.com/prettier/prettier/releases)
- [Changelog](https://github.com/prettier/prettier/blob/main/CHANGELOG.md)
- [Commits](https://github.com/prettier/prettier/compare/3.7.3...3.7.4)

Updates `ts-jest` from 29.4.5 to 29.4.6
- [Release notes](https://github.com/kulshekhar/ts-jest/releases)
- [Changelog](https://github.com/kulshekhar/ts-jest/blob/main/CHANGELOG.md)
- [Commits](https://github.com/kulshekhar/ts-jest/compare/v29.4.5...v29.4.6)

---
updated-dependencies:
- dependency-name: prettier
  dependency-version: 3.7.4
  dependency-type: direct:development
  update-type: version-update:semver-patch
  dependency-group: npm
- dependency-name: ts-jest
  dependency-version: 29.4.6
  dependency-type: direct:development
  update-type: version-update:semver-patch
  dependency-group: npm
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2026-01-01 12:04:07 +00:00
dependabot[bot] 437c31a11d build(deps): bump the github-actions group with 2 updates (#4273)
Bumps the github-actions group with 2 updates: [actions/upload-artifact](https://github.com/actions/upload-artifact) and [actions/download-artifact](https://github.com/actions/download-artifact).


Updates `actions/upload-artifact` from 5 to 6
- [Release notes](https://github.com/actions/upload-artifact/releases)
- [Commits](https://github.com/actions/upload-artifact/compare/v5...v6)

Updates `actions/download-artifact` from 6 to 7
- [Release notes](https://github.com/actions/download-artifact/releases)
- [Commits](https://github.com/actions/download-artifact/compare/v6...v7)

---
updated-dependencies:
- dependency-name: actions/upload-artifact
  dependency-version: '6'
  dependency-type: direct:production
  update-type: version-update:semver-major
  dependency-group: github-actions
- dependency-name: actions/download-artifact
  dependency-version: '7'
  dependency-type: direct:production
  update-type: version-update:semver-major
  dependency-group: github-actions
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2026-01-01 12:03:28 +00:00
Peter Evans 0979079bc2 docs: update readme 2025-12-10 07:32:05 +00:00
Andreas Deininger 5b751cdf40 README.md: bump given GitHub actions to their latest versions (#4265)
Co-authored-by: Andreas Deininger <adeininger@urbanonline.de>
2025-12-10 07:30:53 +00:00
Peter Evans 98357b18bf feat: v8 (#4260) 2025-12-09 20:23:02 +00:00
Copilot 41c0e4b789 Update actions/checkout references to @v6 in docs (#4259)
* Initial plan

* Update actions/checkout references to @v6 in docs

Co-authored-by: peter-evans <18365890+peter-evans@users.noreply.github.com>

* Revert changes to docs/updating.md

Co-authored-by: peter-evans <18365890+peter-evans@users.noreply.github.com>

---------

Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: peter-evans <18365890+peter-evans@users.noreply.github.com>
2025-12-09 11:03:24 +00:00
Yonas Yanfa 994332de4c chore: Update checkout action version to v6 (#4258) 2025-12-09 10:45:05 +00:00
Peter Evans 22a9089034 fix: restrict remote prune to self-hosted runners (#4250) 2025-12-05 17:14:47 +00:00
Peter Evans d4f3be6ce6 fix: provider list pulls fallback for multi fork same owner (#4245)
* fix: GitHub API not providing details for existing PRs in private repos (#4064)

* fix: extract fallback into func getPullNumber

---------

Co-authored-by: Noah Miller <mike@stealthwing.com>
2025-12-05 16:26:27 +00:00
dependabot[bot] bc8a47f565 build(deps-dev): bump prettier from 3.6.2 to 3.7.3 in the npm group (#4240)
Bumps the npm group with 1 update: [prettier](https://github.com/prettier/prettier).


Updates `prettier` from 3.6.2 to 3.7.3
- [Release notes](https://github.com/prettier/prettier/releases)
- [Changelog](https://github.com/prettier/prettier/blob/main/CHANGELOG.md)
- [Commits](https://github.com/prettier/prettier/compare/3.6.2...3.7.3)

---
updated-dependencies:
- dependency-name: prettier
  dependency-version: 3.7.3
  dependency-type: direct:development
  update-type: version-update:semver-minor
  dependency-group: npm
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2025-12-01 14:21:14 +00:00
dependabot[bot] a67ef28ca5 build(deps): bump the github-actions group with 2 updates (#4235)
Bumps the github-actions group with 2 updates: [actions/checkout](https://github.com/actions/checkout) and [peter-evans/slash-command-dispatch](https://github.com/peter-evans/slash-command-dispatch).


Updates `actions/checkout` from 5 to 6
- [Release notes](https://github.com/actions/checkout/releases)
- [Changelog](https://github.com/actions/checkout/blob/main/CHANGELOG.md)
- [Commits](https://github.com/actions/checkout/compare/v5...v6)

Updates `peter-evans/slash-command-dispatch` from 4 to 5
- [Release notes](https://github.com/peter-evans/slash-command-dispatch/releases)
- [Commits](https://github.com/peter-evans/slash-command-dispatch/compare/v4...v5)

---
updated-dependencies:
- dependency-name: actions/checkout
  dependency-version: '6'
  dependency-type: direct:production
  update-type: version-update:semver-major
  dependency-group: github-actions
- dependency-name: peter-evans/slash-command-dispatch
  dependency-version: '5'
  dependency-type: direct:production
  update-type: version-update:semver-major
  dependency-group: github-actions
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2025-12-01 14:04:04 +00:00
20 changed files with 1688 additions and 1541 deletions
+10 -10
View File
@@ -19,21 +19,21 @@ jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v5
- uses: actions/checkout@v6
- uses: actions/setup-node@v6
with:
node-version: 20.x
node-version-file: package.json
cache: npm
- run: npm ci
- run: npm run build
- run: npm run format-check
- run: npm run lint
- run: npm run test
- uses: actions/upload-artifact@v5
- uses: actions/upload-artifact@v7
with:
name: dist
path: dist
- uses: actions/upload-artifact@v5
- uses: actions/upload-artifact@v7
with:
name: action.yml
path: action.yml
@@ -46,16 +46,16 @@ jobs:
matrix:
target: [built, committed]
steps:
- uses: actions/checkout@v5
- uses: actions/checkout@v6
with:
ref: main
- if: matrix.target == 'built' || github.event_name == 'pull_request'
uses: actions/download-artifact@v6
uses: actions/download-artifact@v8
with:
name: dist
path: dist
- if: matrix.target == 'built' || github.event_name == 'pull_request'
uses: actions/download-artifact@v6
uses: actions/download-artifact@v8
with:
name: action.yml
path: .
@@ -118,13 +118,13 @@ jobs:
needs: [test]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v5
- uses: actions/download-artifact@v6
- uses: actions/checkout@v6
- uses: actions/download-artifact@v8
with:
name: dist
path: dist
- name: Create Pull Request
uses: peter-evans/create-pull-request@v7
uses: peter-evans/create-pull-request@v8
with:
token: ${{ secrets.ACTIONS_BOT_TOKEN }}
commit-message: 'build: update distribution'
+1 -1
View File
@@ -6,7 +6,7 @@ jobs:
createPullRequest:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v5
- uses: actions/checkout@v6
- name: Make changes to pull request
run: date +%s > report.txt
+1 -1
View File
@@ -7,7 +7,7 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Slash Command Dispatch
uses: peter-evans/slash-command-dispatch@v4
uses: peter-evans/slash-command-dispatch@v5
with:
token: ${{ secrets.ACTIONS_BOT_TOKEN }}
config: >
+2 -2
View File
@@ -11,14 +11,14 @@ on:
type: choice
description: The major version tag to update
options:
- v6
- v7
- v8
jobs:
tag:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v5
- uses: actions/checkout@v6
with:
token: ${{ secrets.ACTIONS_BOT_TOKEN }}
fetch-depth: 0
+11 -11
View File
@@ -21,21 +21,21 @@ Create Pull Request action will:
- [Concepts, guidelines and advanced usage](docs/concepts-guidelines.md)
- [Examples](docs/examples.md)
- [Updating to v7](docs/updating.md)
- [Updating between versions](docs/updating.md)
- [Common issues](docs/common-issues.md)
## Usage
```yml
- uses: actions/checkout@v4
- uses: actions/checkout@v6
# Make changes to pull request here
- name: Create Pull Request
uses: peter-evans/create-pull-request@v7
uses: peter-evans/create-pull-request@v8
```
You can also pin to a [specific release](https://github.com/peter-evans/create-pull-request/releases) version in the format `@v7.x.x`
You can also pin to a [specific release](https://github.com/peter-evans/create-pull-request/releases) version in the format `@v8.x.x`
### Workflow permissions
@@ -131,7 +131,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@v7
uses: peter-evans/create-pull-request@v8
env:
https_proxy: http://<proxy_address>:<port>
```
@@ -153,7 +153,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@v7
uses: peter-evans/create-pull-request@v8
- name: Check outputs
if: ${{ steps.cpr.outputs.pull-request-number }}
run: |
@@ -216,7 +216,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@v7
uses: peter-evans/create-pull-request@v8
with:
add-paths: |
*.java
@@ -230,7 +230,7 @@ Note that the repository must be checked out on a branch with a remote, it won't
```yml
steps:
- uses: actions/checkout@v4
- uses: actions/checkout@v6
- name: Create commits
run: |
git config user.name 'Peter Evans'
@@ -243,7 +243,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@v7
uses: peter-evans/create-pull-request@v8
```
### Auto-merge
@@ -263,14 +263,14 @@ jobs:
createPullRequest:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/checkout@v6
- name: Make changes to pull request
run: date +%s > report.txt
- name: Create Pull Request
id: cpr
uses: peter-evans/create-pull-request@v7
uses: peter-evans/create-pull-request@v8
with:
token: ${{ secrets.PAT }}
commit-message: Update report
+75 -75
View File
@@ -4,10 +4,10 @@ import {
getWorkingBaseAndType,
buildBranchCommits
} from '../lib/create-or-update-branch'
import {randomUUID} from 'crypto'
import * as fs from 'fs'
import {GitCommandManager} from '../lib/git-command-manager'
import * as path from 'path'
import {v4 as uuidv4} from 'uuid'
const REPO_PATH = '/git/local/repos/test-base'
const REMOTE_NAME = 'origin'
@@ -31,7 +31,7 @@ const ADD_PATHS_MULTI = ['a', 'b']
const ADD_PATHS_WILDCARD = ['a/*.txt', 'b/*.txt']
async function createFile(filename: string, content?: string): Promise<string> {
const _content = content ? content : uuidv4()
const _content = content ? content : randomUUID()
const filepath = path.join(REPO_PATH, filename)
await fs.promises.mkdir(path.dirname(filepath), {recursive: true})
await fs.promises.writeFile(filepath, _content, {encoding: 'utf8'})
@@ -82,7 +82,7 @@ async function createCommits(
} else {
result.changes = await createChanges()
}
const commitMessage = uuidv4()
const commitMessage = randomUUID()
await git.exec(['add', '-A'])
await git.commit(['-m', commitMessage])
result.commitMsgs.unshift(commitMessage)
@@ -313,7 +313,7 @@ describe('create-or-update-branch tests', () => {
})
it('tests no changes resulting in no new branch being created', async () => {
const commitMessage = uuidv4()
const commitMessage = randomUUID()
const result = await createOrUpdateBranch(
git,
commitMessage,
@@ -330,7 +330,7 @@ describe('create-or-update-branch tests', () => {
it('tests create and update with a tracked file change', async () => {
// Create a tracked file change
const trackedContent = await createFile(TRACKED_FILE)
const commitMessage = uuidv4()
const commitMessage = randomUUID()
const result = await createOrUpdateBranch(
git,
commitMessage,
@@ -359,7 +359,7 @@ describe('create-or-update-branch tests', () => {
// Create a tracked file change
const _trackedContent = await createFile(TRACKED_FILE)
const _commitMessage = uuidv4()
const _commitMessage = randomUUID()
const _result = await createOrUpdateBranch(
git,
_commitMessage,
@@ -381,7 +381,7 @@ describe('create-or-update-branch tests', () => {
it('tests create and update with an untracked file change', async () => {
// Create an untracked file change
const untrackedContent = await createFile(UNTRACKED_FILE)
const commitMessage = uuidv4()
const commitMessage = randomUUID()
const result = await createOrUpdateBranch(
git,
commitMessage,
@@ -410,7 +410,7 @@ describe('create-or-update-branch tests', () => {
// Create an untracked file change
const _untrackedContent = await createFile(UNTRACKED_FILE)
const _commitMessage = uuidv4()
const _commitMessage = randomUUID()
const _result = await createOrUpdateBranch(
git,
_commitMessage,
@@ -434,7 +434,7 @@ describe('create-or-update-branch tests', () => {
// Create tracked and untracked file changes
const changes = await createChanges()
const commitMessage = uuidv4()
const commitMessage = randomUUID()
const result = await createOrUpdateBranch(
git,
commitMessage,
@@ -464,7 +464,7 @@ describe('create-or-update-branch tests', () => {
// Create identical tracked and untracked file changes
await createChanges(changes.tracked, changes.untracked)
const _commitMessage = uuidv4()
const _commitMessage = randomUUID()
const _result = await createOrUpdateBranch(
git,
_commitMessage,
@@ -486,7 +486,7 @@ describe('create-or-update-branch tests', () => {
it('tests create and update with commits on the base inbetween', async () => {
// Create tracked and untracked file changes
const changes = await createChanges()
const commitMessage = uuidv4()
const commitMessage = randomUUID()
const result = await createOrUpdateBranch(
git,
commitMessage,
@@ -524,7 +524,7 @@ describe('create-or-update-branch tests', () => {
// Create tracked and untracked file changes
const _changes = await createChanges()
const _commitMessage = uuidv4()
const _commitMessage = randomUUID()
const _result = await createOrUpdateBranch(
git,
_commitMessage,
@@ -556,7 +556,7 @@ describe('create-or-update-branch tests', () => {
// Create tracked and untracked file changes
const changes = await createChanges()
const commitMessage = uuidv4()
const commitMessage = randomUUID()
const result = await createOrUpdateBranch(
git,
commitMessage,
@@ -585,7 +585,7 @@ describe('create-or-update-branch tests', () => {
await beforeTest()
// Running with no update effectively reverts the branch back to match the base
const _commitMessage = uuidv4()
const _commitMessage = randomUUID()
const _result = await createOrUpdateBranch(
git,
_commitMessage,
@@ -607,7 +607,7 @@ describe('create-or-update-branch tests', () => {
// Create tracked and untracked file changes
const changes = await createChanges()
const commitMessage = uuidv4()
const commitMessage = randomUUID()
const result = await createOrUpdateBranch(
git,
commitMessage,
@@ -648,7 +648,7 @@ describe('create-or-update-branch tests', () => {
commits.changes.tracked,
commits.changes.untracked
)
const _commitMessage = uuidv4()
const _commitMessage = randomUUID()
const _result = await createOrUpdateBranch(
git,
_commitMessage,
@@ -673,7 +673,7 @@ describe('create-or-update-branch tests', () => {
// Create tracked and untracked file changes
const changes = await createChanges()
const commitMessage = uuidv4()
const commitMessage = randomUUID()
const result = await createOrUpdateBranch(
git,
commitMessage,
@@ -703,7 +703,7 @@ describe('create-or-update-branch tests', () => {
// Create a commit on the base with a partial merge of the changes
await createFile(TRACKED_FILE, changes.tracked)
const baseCommitMessage = uuidv4()
const baseCommitMessage = randomUUID()
await git.exec(['add', '-A'])
await git.commit(['-m', baseCommitMessage])
await git.push([
@@ -714,7 +714,7 @@ describe('create-or-update-branch tests', () => {
// Create the same tracked and untracked file changes
const _changes = await createChanges(changes.tracked, changes.untracked)
const _commitMessage = uuidv4()
const _commitMessage = randomUUID()
const _result = await createOrUpdateBranch(
git,
_commitMessage,
@@ -746,7 +746,7 @@ describe('create-or-update-branch tests', () => {
// Create tracked and untracked file changes
const changes = await createChanges()
const commitMessage = uuidv4()
const commitMessage = randomUUID()
const result = await createOrUpdateBranch(
git,
commitMessage,
@@ -790,7 +790,7 @@ describe('create-or-update-branch tests', () => {
// Create the same tracked and untracked file changes (no change on update)
const _changes = await createChanges(changes.tracked, changes.untracked)
const _commitMessage = uuidv4()
const _commitMessage = randomUUID()
const _result = await createOrUpdateBranch(
git,
_commitMessage,
@@ -816,7 +816,7 @@ describe('create-or-update-branch tests', () => {
// Create tracked and untracked file changes
const changes = await createChanges()
const commitMessage = uuidv4()
const commitMessage = randomUUID()
const result = await createOrUpdateBranch(
git,
commitMessage,
@@ -845,7 +845,7 @@ describe('create-or-update-branch tests', () => {
await beforeTest()
// Force push the base branch to a different commit
const amendedCommitMessage = uuidv4()
const amendedCommitMessage = randomUUID()
await git.commit(['--amend', '-m', amendedCommitMessage])
await git.push([
'--force',
@@ -855,7 +855,7 @@ describe('create-or-update-branch tests', () => {
// Create the same tracked and untracked file changes (no change on update)
const _changes = await createChanges(changes.tracked, changes.untracked)
const _commitMessage = uuidv4()
const _commitMessage = randomUUID()
const _result = await createOrUpdateBranch(
git,
_commitMessage,
@@ -878,7 +878,7 @@ describe('create-or-update-branch tests', () => {
it('tests create and update with commits on the working base (during the workflow)', async () => {
// Create commits on the working base
const commits = await createCommits(git)
const commitMessage = uuidv4()
const commitMessage = randomUUID()
const result = await createOrUpdateBranch(
git,
commitMessage,
@@ -910,7 +910,7 @@ describe('create-or-update-branch tests', () => {
// Create commits on the working base
const _commits = await createCommits(git)
const _commitMessage = uuidv4()
const _commitMessage = randomUUID()
const _result = await createOrUpdateBranch(
git,
_commitMessage,
@@ -937,7 +937,7 @@ describe('create-or-update-branch tests', () => {
const commits = await createCommits(git)
// Create tracked and untracked file changes
const changes = await createChanges()
const commitMessage = uuidv4()
const commitMessage = randomUUID()
const result = await createOrUpdateBranch(
git,
commitMessage,
@@ -973,7 +973,7 @@ describe('create-or-update-branch tests', () => {
const _commits = await createCommits(git)
// Create tracked and untracked file changes
const _changes = await createChanges()
const _commitMessage = uuidv4()
const _commitMessage = randomUUID()
const _result = await createOrUpdateBranch(
git,
_commitMessage,
@@ -1002,7 +1002,7 @@ describe('create-or-update-branch tests', () => {
const commits = await createCommits(git)
// Create tracked and untracked file changes
const changes = await createChanges()
const commitMessage = uuidv4()
const commitMessage = randomUUID()
const result = await createOrUpdateBranch(
git,
commitMessage,
@@ -1046,7 +1046,7 @@ describe('create-or-update-branch tests', () => {
const _commits = await createCommits(git)
// Create tracked and untracked file changes
const _changes = await createChanges()
const _commitMessage = uuidv4()
const _commitMessage = randomUUID()
const _result = await createOrUpdateBranch(
git,
_commitMessage,
@@ -1074,7 +1074,7 @@ describe('create-or-update-branch tests', () => {
it('tests create and update using a different remote from the base', async () => {
// Create tracked and untracked file changes
const changes = await createChanges()
const commitMessage = uuidv4()
const commitMessage = randomUUID()
const result = await createOrUpdateBranch(
git,
commitMessage,
@@ -1104,7 +1104,7 @@ describe('create-or-update-branch tests', () => {
// Create tracked and untracked file changes
const _changes = await createChanges()
const _commitMessage = uuidv4()
const _commitMessage = randomUUID()
const _result = await createOrUpdateBranch(
git,
_commitMessage,
@@ -1127,7 +1127,7 @@ describe('create-or-update-branch tests', () => {
it('tests create and update with signoff on commit', async () => {
// Create tracked and untracked file changes
const changes = await createChanges()
const commitMessage = uuidv4()
const commitMessage = randomUUID()
const result = await createOrUpdateBranch(
git,
commitMessage,
@@ -1164,7 +1164,7 @@ describe('create-or-update-branch tests', () => {
// Create tracked and untracked file changes
const _changes = await createChanges()
const _commitMessage = uuidv4()
const _commitMessage = randomUUID()
const _result = await createOrUpdateBranch(
git,
_commitMessage,
@@ -1194,7 +1194,7 @@ describe('create-or-update-branch tests', () => {
it('tests create and update with multiple add-paths', async () => {
// Create tracked and untracked file changes
const changes = await createChanges()
const commitMessage = uuidv4()
const commitMessage = randomUUID()
const result = await createOrUpdateBranch(
git,
commitMessage,
@@ -1224,7 +1224,7 @@ describe('create-or-update-branch tests', () => {
// Create tracked and untracked file changes
const _changes = await createChanges()
const _commitMessage = uuidv4()
const _commitMessage = randomUUID()
const _result = await createOrUpdateBranch(
git,
_commitMessage,
@@ -1247,7 +1247,7 @@ describe('create-or-update-branch tests', () => {
it('tests create and update with wildcard add-paths', async () => {
// Create tracked and untracked file changes
const changes = await createChanges()
const commitMessage = uuidv4()
const commitMessage = randomUUID()
const result = await createOrUpdateBranch(
git,
commitMessage,
@@ -1277,7 +1277,7 @@ describe('create-or-update-branch tests', () => {
// Create tracked and untracked file changes
const _changes = await createChanges()
const _commitMessage = uuidv4()
const _commitMessage = randomUUID()
const _result = await createOrUpdateBranch(
git,
_commitMessage,
@@ -1300,7 +1300,7 @@ describe('create-or-update-branch tests', () => {
it('tests create with add-paths resolving to no changes when other changes exist', async () => {
// Create tracked and untracked file changes
await createChanges()
const commitMessage = uuidv4()
const commitMessage = randomUUID()
const result = await createOrUpdateBranch(
git,
commitMessage,
@@ -1321,7 +1321,7 @@ describe('create-or-update-branch tests', () => {
// Create tracked and untracked file changes
const changes = await createChanges()
const commitMessage = uuidv4()
const commitMessage = randomUUID()
const resultA = await createOrUpdateBranch(
git,
commitMessage,
@@ -1365,7 +1365,7 @@ describe('create-or-update-branch tests', () => {
// Set the working base to a branch that is not the pull request base
await git.checkout(NOT_BASE_BRANCH)
const commitMessage = uuidv4()
const commitMessage = randomUUID()
const result = await createOrUpdateBranch(
git,
commitMessage,
@@ -1386,7 +1386,7 @@ describe('create-or-update-branch tests', () => {
// Create a tracked file change
const trackedContent = await createFile(TRACKED_FILE)
const commitMessage = uuidv4()
const commitMessage = randomUUID()
const result = await createOrUpdateBranch(
git,
commitMessage,
@@ -1418,7 +1418,7 @@ describe('create-or-update-branch tests', () => {
// Create a tracked file change
const _trackedContent = await createFile(TRACKED_FILE)
const _commitMessage = uuidv4()
const _commitMessage = randomUUID()
const _result = await createOrUpdateBranch(
git,
_commitMessage,
@@ -1443,7 +1443,7 @@ describe('create-or-update-branch tests', () => {
// Create an untracked file change
const untrackedContent = await createFile(UNTRACKED_FILE)
const commitMessage = uuidv4()
const commitMessage = randomUUID()
const result = await createOrUpdateBranch(
git,
commitMessage,
@@ -1475,7 +1475,7 @@ describe('create-or-update-branch tests', () => {
// Create an untracked file change
const _untrackedContent = await createFile(UNTRACKED_FILE)
const _commitMessage = uuidv4()
const _commitMessage = randomUUID()
const _result = await createOrUpdateBranch(
git,
_commitMessage,
@@ -1502,7 +1502,7 @@ describe('create-or-update-branch tests', () => {
// Create tracked and untracked file changes
const changes = await createChanges()
const commitMessage = uuidv4()
const commitMessage = randomUUID()
const result = await createOrUpdateBranch(
git,
commitMessage,
@@ -1535,7 +1535,7 @@ describe('create-or-update-branch tests', () => {
// Create identical tracked and untracked file changes
await createChanges(changes.tracked, changes.untracked)
const _commitMessage = uuidv4()
const _commitMessage = randomUUID()
const _result = await createOrUpdateBranch(
git,
_commitMessage,
@@ -1560,7 +1560,7 @@ describe('create-or-update-branch tests', () => {
// Create tracked and untracked file changes
const changes = await createChanges()
const commitMessage = uuidv4()
const commitMessage = randomUUID()
const result = await createOrUpdateBranch(
git,
commitMessage,
@@ -1601,7 +1601,7 @@ describe('create-or-update-branch tests', () => {
// Create tracked and untracked file changes
const _changes = await createChanges()
const _commitMessage = uuidv4()
const _commitMessage = randomUUID()
const _result = await createOrUpdateBranch(
git,
_commitMessage,
@@ -1635,7 +1635,7 @@ describe('create-or-update-branch tests', () => {
// Create tracked and untracked file changes
const changes = await createChanges()
const commitMessage = uuidv4()
const commitMessage = randomUUID()
const result = await createOrUpdateBranch(
git,
commitMessage,
@@ -1667,7 +1667,7 @@ describe('create-or-update-branch tests', () => {
await git.checkout(NOT_BASE_BRANCH)
// Running with no update effectively reverts the branch back to match the base
const _commitMessage = uuidv4()
const _commitMessage = randomUUID()
const _result = await createOrUpdateBranch(
git,
_commitMessage,
@@ -1694,7 +1694,7 @@ describe('create-or-update-branch tests', () => {
// Create tracked and untracked file changes
const changes = await createChanges()
const commitMessage = uuidv4()
const commitMessage = randomUUID()
const result = await createOrUpdateBranch(
git,
commitMessage,
@@ -1738,7 +1738,7 @@ describe('create-or-update-branch tests', () => {
commits.changes.tracked,
commits.changes.untracked
)
const _commitMessage = uuidv4()
const _commitMessage = randomUUID()
const _result = await createOrUpdateBranch(
git,
_commitMessage,
@@ -1768,7 +1768,7 @@ describe('create-or-update-branch tests', () => {
// Create tracked and untracked file changes
const changes = await createChanges()
const commitMessage = uuidv4()
const commitMessage = randomUUID()
const result = await createOrUpdateBranch(
git,
commitMessage,
@@ -1798,7 +1798,7 @@ describe('create-or-update-branch tests', () => {
// Create a commit on the base with a partial merge of the changes
await createFile(TRACKED_FILE, changes.tracked)
const baseCommitMessage = uuidv4()
const baseCommitMessage = randomUUID()
await git.exec(['add', '-A'])
await git.commit(['-m', baseCommitMessage])
await git.push([
@@ -1812,7 +1812,7 @@ describe('create-or-update-branch tests', () => {
// Create the same tracked and untracked file changes
const _changes = await createChanges(changes.tracked, changes.untracked)
const _commitMessage = uuidv4()
const _commitMessage = randomUUID()
const _result = await createOrUpdateBranch(
git,
_commitMessage,
@@ -1846,7 +1846,7 @@ describe('create-or-update-branch tests', () => {
// Create tracked and untracked file changes
const changes = await createChanges()
const commitMessage = uuidv4()
const commitMessage = randomUUID()
const result = await createOrUpdateBranch(
git,
commitMessage,
@@ -1893,7 +1893,7 @@ describe('create-or-update-branch tests', () => {
// Create the same tracked and untracked file changes (no change on update)
const _changes = await createChanges(changes.tracked, changes.untracked)
const _commitMessage = uuidv4()
const _commitMessage = randomUUID()
const _result = await createOrUpdateBranch(
git,
_commitMessage,
@@ -1924,7 +1924,7 @@ describe('create-or-update-branch tests', () => {
// Create tracked and untracked file changes
const changes = await createChanges()
const commitMessage = uuidv4()
const commitMessage = randomUUID()
const result = await createOrUpdateBranch(
git,
commitMessage,
@@ -1953,7 +1953,7 @@ describe('create-or-update-branch tests', () => {
await beforeTest()
// Force push the base branch to a different commit
const amendedCommitMessage = uuidv4()
const amendedCommitMessage = randomUUID()
await git.commit(['--amend', '-m', amendedCommitMessage])
await git.push([
'--force',
@@ -1966,7 +1966,7 @@ describe('create-or-update-branch tests', () => {
// Create the same tracked and untracked file changes (no change on update)
const _changes = await createChanges(changes.tracked, changes.untracked)
const _commitMessage = uuidv4()
const _commitMessage = randomUUID()
const _result = await createOrUpdateBranch(
git,
_commitMessage,
@@ -1992,7 +1992,7 @@ describe('create-or-update-branch tests', () => {
// Create commits on the working base
const commits = await createCommits(git)
const commitMessage = uuidv4()
const commitMessage = randomUUID()
const result = await createOrUpdateBranch(
git,
commitMessage,
@@ -2027,7 +2027,7 @@ describe('create-or-update-branch tests', () => {
// Create commits on the working base
const _commits = await createCommits(git)
const _commitMessage = uuidv4()
const _commitMessage = randomUUID()
const _result = await createOrUpdateBranch(
git,
_commitMessage,
@@ -2057,7 +2057,7 @@ describe('create-or-update-branch tests', () => {
const commits = await createCommits(git)
// Create tracked and untracked file changes
const changes = await createChanges()
const commitMessage = uuidv4()
const commitMessage = randomUUID()
const result = await createOrUpdateBranch(
git,
commitMessage,
@@ -2096,7 +2096,7 @@ describe('create-or-update-branch tests', () => {
const _commits = await createCommits(git)
// Create tracked and untracked file changes
const _changes = await createChanges()
const _commitMessage = uuidv4()
const _commitMessage = randomUUID()
const _result = await createOrUpdateBranch(
git,
_commitMessage,
@@ -2128,7 +2128,7 @@ describe('create-or-update-branch tests', () => {
const commits = await createCommits(git)
// Create tracked and untracked file changes
const changes = await createChanges()
const commitMessage = uuidv4()
const commitMessage = randomUUID()
const result = await createOrUpdateBranch(
git,
commitMessage,
@@ -2175,7 +2175,7 @@ describe('create-or-update-branch tests', () => {
const _commits = await createCommits(git)
// Create tracked and untracked file changes
const _changes = await createChanges()
const _commitMessage = uuidv4()
const _commitMessage = randomUUID()
const _result = await createOrUpdateBranch(
git,
_commitMessage,
@@ -2205,7 +2205,7 @@ describe('create-or-update-branch tests', () => {
// Create tracked and untracked file changes
const changes = await createChanges()
const commitMessage = uuidv4()
const commitMessage = randomUUID()
const result = await createOrUpdateBranch(
git,
commitMessage,
@@ -2238,7 +2238,7 @@ describe('create-or-update-branch tests', () => {
// Create tracked and untracked file changes
const _changes = await createChanges()
const _commitMessage = uuidv4()
const _commitMessage = randomUUID()
const _result = await createOrUpdateBranch(
git,
_commitMessage,
@@ -2268,7 +2268,7 @@ describe('create-or-update-branch tests', () => {
// Create tracked and untracked file changes
const changes = await createChanges()
const commitMessage = uuidv4()
const commitMessage = randomUUID()
const result = await createOrUpdateBranch(
git,
commitMessage,
@@ -2302,7 +2302,7 @@ describe('create-or-update-branch tests', () => {
// Create tracked and untracked file changes
const _changes = await createChanges()
const _commitMessage = uuidv4()
const _commitMessage = randomUUID()
const _result = await createOrUpdateBranch(
git,
_commitMessage,
@@ -2329,7 +2329,7 @@ describe('create-or-update-branch tests', () => {
// Create tracked and untracked file changes
const changes = await createChanges()
const commitMessage = uuidv4()
const commitMessage = randomUUID()
const result = await createOrUpdateBranch(
git,
commitMessage,
@@ -2371,7 +2371,7 @@ describe('create-or-update-branch tests', () => {
// Create tracked and untracked file changes
const _changes = await createChanges()
const _commitMessage = uuidv4()
const _commitMessage = randomUUID()
const _result = await createOrUpdateBranch(
git,
_commitMessage,
@@ -2403,7 +2403,7 @@ describe('create-or-update-branch tests', () => {
// Create commits on the working base
const commits = await createCommits(git)
const commitMessage = uuidv4()
const commitMessage = randomUUID()
const result = await createOrUpdateBranch(
git,
commitMessage,
@@ -2428,7 +2428,7 @@ describe('create-or-update-branch tests', () => {
// Create tracked and untracked file changes
const changes = await createChanges()
const commitMessage = uuidv4()
const commitMessage = randomUUID()
const resultA = await createOrUpdateBranch(
git,
commitMessage,
+68
View File
@@ -118,3 +118,71 @@ describe('utils tests', () => {
}
})
})
describe('retryWithBackoff', () => {
const makeConsistencyError = () => {
const error = new Error(
'Validation Failed: "Could not resolve to a node with the global id of \'PR_abc123\'."'
)
;(error as any).status = 422
return error
}
const shouldRetry = (e: unknown): boolean =>
e instanceof Error &&
(e as any).status === 422 &&
e.message.includes('Could not resolve to a node')
test('succeeds on first attempt without retrying', async () => {
const fn = jest.fn().mockResolvedValue('success')
const result = await utils.retryWithBackoff(fn, shouldRetry, 2, 1)
expect(result).toBe('success')
expect(fn).toHaveBeenCalledTimes(1)
})
test('retries on eventual consistency 422 and succeeds', async () => {
const fn = jest
.fn()
.mockRejectedValueOnce(makeConsistencyError())
.mockResolvedValue('success')
const result = await utils.retryWithBackoff(fn, shouldRetry, 2, 1)
expect(result).toBe('success')
expect(fn).toHaveBeenCalledTimes(2)
})
test('exhausts retries on persistent 422 and throws', async () => {
const fn = jest.fn().mockRejectedValue(makeConsistencyError())
await expect(utils.retryWithBackoff(fn, shouldRetry, 2, 1)).rejects.toThrow(
'Could not resolve to a node'
)
expect(fn).toHaveBeenCalledTimes(3) // 1 initial + 2 retries
})
test('does not retry on non-422 errors', async () => {
const error = new Error('Forbidden')
;(error as any).status = 403
const fn = jest.fn().mockRejectedValue(error)
await expect(utils.retryWithBackoff(fn, shouldRetry, 2, 1)).rejects.toThrow(
'Forbidden'
)
expect(fn).toHaveBeenCalledTimes(1)
})
test('does not retry on 422 without the consistency error message', async () => {
const error = new Error('Validation Failed: invalid label')
;(error as any).status = 422
const fn = jest.fn().mockRejectedValue(error)
await expect(utils.retryWithBackoff(fn, shouldRetry, 2, 1)).rejects.toThrow(
'Validation Failed: invalid label'
)
expect(fn).toHaveBeenCalledTimes(1)
})
test('does not retry on plain Error objects', async () => {
const fn = jest.fn().mockRejectedValue(new Error('Something broke'))
await expect(utils.retryWithBackoff(fn, shouldRetry, 2, 1)).rejects.toThrow(
'Something broke'
)
expect(fn).toHaveBeenCalledTimes(1)
})
})
+1 -1
View File
@@ -94,7 +94,7 @@ outputs:
pull-request-branch:
description: 'The pull request branch name'
runs:
using: 'node20'
using: 'node24'
main: 'dist/index.js'
branding:
icon: 'git-pull-request'
+325 -778
View File
File diff suppressed because it is too large Load Diff
+1 -1
View File
@@ -37,7 +37,7 @@ So the straightforward solution is to just not install them during the workflow
- If hooks are automatically enabled by a framework, use an option provided by the framework to disable them. For example, for Husky users, they can be disabled with the `--ignore-scripts` flag, or by setting the `HUSKY` environment variable when the action runs.
```yml
uses: peter-evans/create-pull-request@v7
uses: peter-evans/create-pull-request@v8
env:
HUSKY: '0'
```
+26 -26
View File
@@ -40,7 +40,7 @@ For each [event type](https://docs.github.com/en/actions/reference/events-that-t
The default can be overridden by specifying a `ref` on checkout.
```yml
- uses: actions/checkout@v4
- uses: actions/checkout@v6
with:
ref: develop
```
@@ -77,7 +77,7 @@ jobs:
example:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/checkout@v6
```
There may be use cases where it makes sense to execute the workflow on a branch that is not the base of the pull request. In these cases, the base branch can be specified with the `base` action input. The action will attempt to rebase changes made during the workflow on to the actual base.
@@ -92,7 +92,7 @@ In these cases, you *must supply* the `base` input so the action can rebase chan
Workflows triggered by [`pull_request`](https://docs.github.com/en/actions/reference/events-that-trigger-workflows#pull_request) events will by default check out a merge commit. Set the `base` input as follows to base the new pull request on the current pull request's branch.
```yml
- uses: peter-evans/create-pull-request@v7
- uses: peter-evans/create-pull-request@v8
with:
base: ${{ github.head_ref }}
```
@@ -100,7 +100,7 @@ Workflows triggered by [`pull_request`](https://docs.github.com/en/actions/refer
Workflows triggered by [`release`](https://docs.github.com/en/actions/reference/events-that-trigger-workflows#release) events will by default check out a tag. For most use cases, you will need to set the `base` input to the branch name of the tagged commit.
```yml
- uses: peter-evans/create-pull-request@v7
- uses: peter-evans/create-pull-request@v8
with:
base: main
```
@@ -179,14 +179,14 @@ This action uses [ncc](https://github.com/vercel/ncc) to compile the Node.js cod
Checking out a branch from a different repository from where the workflow is executing will make *that repository* the target for the created pull request. In this case, the `GITHUB_TOKEN` will not work and one of the other [token options](../README.md#token) must be used.
```yml
- uses: actions/checkout@v4
- uses: actions/checkout@v6
with:
token: ${{ secrets.PAT }}
repository: owner/repo
# Make changes to pull request here
- uses: peter-evans/create-pull-request@v7
- uses: peter-evans/create-pull-request@v8
with:
token: ${{ secrets.PAT }}
```
@@ -210,14 +210,14 @@ How to use SSH (deploy keys) with create-pull-request action:
```yml
steps:
- uses: actions/checkout@v4
- uses: actions/checkout@v6
with:
ssh-key: ${{ secrets.SSH_PRIVATE_KEY }}
# Make changes to pull request here
- name: Create Pull Request
uses: peter-evans/create-pull-request@v7
uses: peter-evans/create-pull-request@v8
```
### Push pull request branches to a fork
@@ -238,11 +238,11 @@ It will use their own fork to push code and create the pull request.
6. As shown in the following example workflow, set the `push-to-fork` input to the full repository name of the fork.
```yaml
- uses: actions/checkout@v4
- uses: actions/checkout@v6
# Make changes to pull request here
- uses: peter-evans/create-pull-request@v7
- uses: peter-evans/create-pull-request@v8
with:
token: ${{ secrets.MACHINE_USER_PAT }}
push-to-fork: machine-user/fork-of-repository
@@ -280,12 +280,12 @@ The following is an example of pushing to a fork using GitHub App tokens.
owner: owner
repositories: fork-of-repo
- uses: actions/checkout@v4
- uses: actions/checkout@v6
# Make changes to pull request here
- name: Create Pull Request
uses: peter-evans/create-pull-request@v7
uses: peter-evans/create-pull-request@v8
with:
branch-token: ${{ steps.generate-token.outputs.token }}
push-to-fork: owner/fork-of-repo
@@ -325,12 +325,12 @@ GitHub App generated tokens can be configured with fine-grained permissions and
app-id: ${{ secrets.APP_ID }}
private-key: ${{ secrets.APP_PRIVATE_KEY }}
- uses: actions/checkout@v4
- uses: actions/checkout@v6
# Make changes to pull request here
- name: Create Pull Request
uses: peter-evans/create-pull-request@v7
uses: peter-evans/create-pull-request@v8
with:
token: ${{ steps.generate-token.outputs.token }}
```
@@ -350,7 +350,7 @@ In the following example, a pull request is being created in remote repo `owner/
owner: owner
repositories: repo
- uses: actions/checkout@v4
- uses: actions/checkout@v6
with:
token: ${{ steps.generate-token.outputs.token }} # necessary if the repo is private
repository: owner/repo
@@ -358,7 +358,7 @@ In the following example, a pull request is being created in remote repo `owner/
# Make changes to pull request here
- name: Create Pull Request
uses: peter-evans/create-pull-request@v7
uses: peter-evans/create-pull-request@v8
with:
token: ${{ steps.generate-token.outputs.token }}
```
@@ -382,12 +382,12 @@ The action can sign commits as `github-actions[bot]` when using the repository's
In this example the `token` input is not supplied, so the action will use the repository's default `GITHUB_TOKEN`. This will sign commits as `github-actions[bot]`.
```yaml
steps:
- uses: actions/checkout@v4
- uses: actions/checkout@v6
# Make changes to pull request here
- name: Create Pull Request
uses: peter-evans/create-pull-request@v7
uses: peter-evans/create-pull-request@v8
with:
sign-commits: true
```
@@ -395,7 +395,7 @@ In this example the `token` input is not supplied, so the action will use the re
In this example, the `token` input is generated using a GitHub App. This will sign commits as `<application-name>[bot]`.
```yaml
steps:
- uses: actions/checkout@v4
- uses: actions/checkout@v6
- uses: actions/create-github-app-token@v2
id: generate-token
@@ -406,7 +406,7 @@ In this example, the `token` input is generated using a GitHub App. This will si
# Make changes to pull request here
- name: Create Pull Request
uses: peter-evans/create-pull-request@v7
uses: peter-evans/create-pull-request@v8
with:
token: ${{ steps.generate-token.outputs.token }}
sign-commits: true
@@ -437,7 +437,7 @@ The action can use GPG to sign commits with a GPG key that you generate yourself
```yaml
steps:
- uses: actions/checkout@v4
- uses: actions/checkout@v6
- uses: crazy-max/ghaction-import-gpg@v5
with:
@@ -449,7 +449,7 @@ The action can use GPG to sign commits with a GPG key that you generate yourself
# Make changes to pull request here
- name: Create Pull Request
uses: peter-evans/create-pull-request@v7
uses: peter-evans/create-pull-request@v8
with:
token: ${{ secrets.PAT }}
committer: example <email@example.com>
@@ -474,12 +474,12 @@ jobs:
- name: Install dependencies
run: apk --no-cache add git
- uses: actions/checkout@v4
- uses: actions/checkout@v6
# Make changes to pull request here
- name: Create Pull Request
uses: peter-evans/create-pull-request@v7
uses: peter-evans/create-pull-request@v8
```
**Ubuntu container example:**
@@ -497,10 +497,10 @@ jobs:
add-apt-repository -y ppa:git-core/ppa
apt-get install -y git
- uses: actions/checkout@v4
- uses: actions/checkout@v6
# Make changes to pull request here
- name: Create Pull Request
uses: peter-evans/create-pull-request@v7
uses: peter-evans/create-pull-request@v8
```
+26 -26
View File
@@ -42,14 +42,14 @@ jobs:
updateAuthors:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/checkout@v6
with:
fetch-depth: 0
- name: Update AUTHORS
run: |
git log --format='%aN <%aE>%n%cN <%cE>' | sort -u > AUTHORS
- name: Create Pull Request
uses: peter-evans/create-pull-request@v7
uses: peter-evans/create-pull-request@v8
with:
commit-message: update authors
title: Update AUTHORS
@@ -73,7 +73,7 @@ jobs:
productionPromotion:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/checkout@v6
with:
ref: production
- name: Reset promotion branch
@@ -81,7 +81,7 @@ jobs:
git fetch origin main:main
git reset --hard main
- name: Create Pull Request
uses: peter-evans/create-pull-request@v7
uses: peter-evans/create-pull-request@v8
with:
branch: production-promotion
```
@@ -106,7 +106,7 @@ jobs:
updateChangelog:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/checkout@v6
with:
fetch-depth: 0
- name: Update Changelog
@@ -116,7 +116,7 @@ jobs:
./git-chglog -o CHANGELOG.md
rm git-chglog
- name: Create Pull Request
uses: peter-evans/create-pull-request@v7
uses: peter-evans/create-pull-request@v8
with:
commit-message: update changelog
title: Update Changelog
@@ -144,7 +144,7 @@ jobs:
update-dep:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/checkout@v6
- uses: actions/setup-node@v3
with:
node-version: '16.x'
@@ -153,7 +153,7 @@ jobs:
npx -p npm-check-updates ncu -u
npm install
- name: Create Pull Request
uses: peter-evans/create-pull-request@v7
uses: peter-evans/create-pull-request@v8
with:
token: ${{ secrets.PAT }}
commit-message: Update dependencies
@@ -180,7 +180,7 @@ jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/checkout@v6
- uses: actions/setup-node@v3
with:
node-version: 16.x
@@ -204,7 +204,7 @@ jobs:
update-dep:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/checkout@v6
- uses: actions/setup-java@v2
with:
distribution: 'temurin'
@@ -214,7 +214,7 @@ jobs:
- name: Perform dependency resolution and write new lockfiles
run: ./gradlew dependencies --write-locks
- name: Create Pull Request
uses: peter-evans/create-pull-request@v7
uses: peter-evans/create-pull-request@v8
with:
token: ${{ secrets.PAT }}
commit-message: Update dependencies
@@ -242,14 +242,14 @@ jobs:
update-dep:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/checkout@v6
- name: Update dependencies
run: |
cargo install cargo-edit
cargo update
cargo upgrade --to-lockfile
- name: Create Pull Request
uses: peter-evans/create-pull-request@v7
uses: peter-evans/create-pull-request@v8
with:
token: ${{ secrets.PAT }}
commit-message: Update dependencies
@@ -277,7 +277,7 @@ jobs:
updateSwagger:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/checkout@v6
- name: Get Latest Swagger UI Release
id: swagger-ui
run: |
@@ -307,7 +307,7 @@ jobs:
# Update current release
echo ${{ steps.swagger-ui.outputs.release_tag }} > swagger-ui.version
- name: Create Pull Request
uses: peter-evans/create-pull-request@v7
uses: peter-evans/create-pull-request@v8
with:
commit-message: Update swagger-ui to ${{ steps.swagger-ui.outputs.release_tag }}
title: Update SwaggerUI to ${{ steps.swagger-ui.outputs.release_tag }}
@@ -342,7 +342,7 @@ jobs:
updateFork:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/checkout@v6
with:
repository: fork-owner/repo
- name: Reset the default branch with upstream changes
@@ -351,7 +351,7 @@ jobs:
git fetch upstream main:upstream-main
git reset --hard upstream-main
- name: Create Pull Request
uses: peter-evans/create-pull-request@v7
uses: peter-evans/create-pull-request@v8
with:
token: ${{ secrets.PAT }}
branch: upstream-changes
@@ -370,7 +370,7 @@ jobs:
format:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/checkout@v6
- name: Download website
run: |
wget \
@@ -384,7 +384,7 @@ jobs:
--domains quotes.toscrape.com \
http://quotes.toscrape.com/
- name: Create Pull Request
uses: peter-evans/create-pull-request@v7
uses: peter-evans/create-pull-request@v8
with:
commit-message: update local website copy
title: Automated Updates to Local Website Copy
@@ -466,7 +466,7 @@ jobs:
if: startsWith(github.head_ref, 'autopep8-patches') == false && github.event.pull_request.head.repo.full_name == github.repository
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/checkout@v6
with:
ref: ${{ github.head_ref }}
- name: autopep8
@@ -481,7 +481,7 @@ jobs:
echo "branch-name=$branch-name" >> $GITHUB_OUTPUT
- name: Create Pull Request
if: steps.autopep8.outputs.exit-code == 2
uses: peter-evans/create-pull-request@v7
uses: peter-evans/create-pull-request@v8
with:
commit-message: autopep8 action fixes
title: Fixes by autopep8 action
@@ -515,13 +515,13 @@ jobs:
if: startsWith(github.ref, 'refs/heads/')
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/checkout@v6
...
someOtherJob:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/checkout@v6
...
```
@@ -540,7 +540,7 @@ Note that the step where output variables are defined must have an id.
echo "pr_title=$pr_title" >> $GITHUB_OUTPUT
echo "pr_body=$pr_body" >> $GITHUB_OUTPUT
- name: Create Pull Request
uses: peter-evans/create-pull-request@v7
uses: peter-evans/create-pull-request@v8
with:
title: ${{ steps.vars.outputs.pr_title }}
body: ${{ steps.vars.outputs.pr_body }}
@@ -566,7 +566,7 @@ The template is rendered using the [render-template](https://github.com/chuhlomi
bar: that
- name: Create Pull Request
uses: peter-evans/create-pull-request@v7
uses: peter-evans/create-pull-request@v8
with:
body: ${{ steps.template.outputs.result }}
```
@@ -622,7 +622,7 @@ For example:
```yml
- name: Create Pull Request
id: cpr
uses: peter-evans/create-pull-request@v7
uses: peter-evans/create-pull-request@v8
- name: Show message for created Pull Request
if: ${{ steps.cpr.outputs.pull-request-url && steps.cpr.outputs.pull-request-operation != 'none' }}
+11
View File
@@ -1,3 +1,14 @@
## Updating from `v7` to `v8`
### Behaviour changes
- If using self-hosted runners or GitHub Enterprise Server, there are minimum requirements for `v8` to run. See "What's new" below for details.
### What's new
- Updated runtime to Node.js 24
- The action now requires a minimum version of [v2.327.1](https://github.com/actions/runner/releases/tag/v2.327.1) for the Actions runner. Update self-hosted runners to v2.327.1 or later to ensure compatibility.
## Updating from `v6` to `v7`
### Behaviour changes
+967 -565
View File
File diff suppressed because it is too large Load Diff
+12 -8
View File
@@ -1,9 +1,12 @@
{
"name": "create-pull-request",
"version": "7.0.0",
"version": "8.0.0",
"private": true,
"description": "Creates a pull request for changes to your repository in the actions workspace",
"main": "lib/main.js",
"engines": {
"node": ">=24.4.0"
},
"scripts": {
"build": "tsc && ncc build",
"format": "prettier --write '**/*.ts'",
@@ -34,10 +37,11 @@
"@octokit/core": "^6.1.6",
"@octokit/plugin-paginate-rest": "^11.6.0",
"@octokit/plugin-rest-endpoint-methods": "^13.5.0",
"@octokit/plugin-retry": "^7.2.1",
"@octokit/plugin-throttling": "^9.6.1",
"@octokit/request-error": "^6.1.8",
"node-fetch-native": "^1.6.7",
"p-limit": "^6.2.0",
"uuid": "^9.0.1"
"p-limit": "^6.2.0"
},
"devDependencies": {
"@types/jest": "^29.5.14",
@@ -50,14 +54,14 @@
"eslint-plugin-github": "^4.10.2",
"eslint-plugin-import": "^2.32.0",
"eslint-plugin-jest": "^27.9.0",
"eslint-plugin-prettier": "^5.5.4",
"eslint-plugin-prettier": "^5.5.5",
"jest": "^29.7.0",
"jest-circus": "^29.7.0",
"jest-environment-jsdom": "^29.7.0",
"jest-environment-jsdom": "^30.3.0",
"js-yaml": "^4.1.1",
"prettier": "^3.6.2",
"ts-jest": "^29.4.5",
"prettier": "^3.8.3",
"ts-jest": "^29.4.9",
"typescript": "^5.9.3",
"undici": "^6.22.0"
"undici": "^6.25.0"
}
}
+2 -2
View File
@@ -1,6 +1,6 @@
import * as core from '@actions/core'
import {randomUUID} from 'crypto'
import {GitCommandManager, Commit} from './git-command-manager'
import {v4 as uuidv4} from 'uuid'
import * as utils from './utils'
const CHERRYPICK_EMPTY =
@@ -189,7 +189,7 @@ export async function createOrUpdateBranch(
const baseRemote = 'origin'
// Save the working base changes to a temporary branch
const tempBranch = uuidv4()
const tempBranch = randomUUID()
await git.checkout(tempBranch, 'HEAD')
// Commit any uncommitted changes
if (await git.isDirty(true, addPaths)) {
+14 -6
View File
@@ -121,12 +121,20 @@ export async function createPullRequest(inputs: Inputs): Promise<void> {
`The 'base' and 'branch' for a pull request must be different branches. Unable to continue.`
)
}
// For self-hosted runners the repository state persists between runs.
// This command prunes the stale remote ref when the pull request branch was
// deleted after being merged or closed. Without this the push using
// '--force-with-lease' fails due to "stale info."
// https://github.com/peter-evans/create-pull-request/issues/633
await git.exec(['remote', 'prune', branchRemoteName])
if (utils.isSelfHosted()) {
// For self-hosted runners the repository state persists between runs.
// This command prunes the stale remote ref when the pull request branch was
// deleted after being merged or closed. Without this the push using
// '--force-with-lease' fails due to "stale info."
// https://github.com/peter-evans/create-pull-request/issues/633
try {
await git.exec(['remote', 'prune', branchRemoteName])
} catch (error) {
core.warning(
`Failed to prune remote '${branchRemoteName}': ${(error as Error).message}`
)
}
}
core.endGroup()
// Apply the branch suffix if set
+99 -28
View File
@@ -1,7 +1,13 @@
import * as core from '@actions/core'
import {RequestError} from '@octokit/request-error'
import {Inputs} from './create-pull-request'
import {Commit, GitCommandManager} from './git-command-manager'
import {Octokit, OctokitOptions, throttleOptions} from './octokit-client'
import {
Octokit,
OctokitOptions,
retryOptions,
throttleOptions
} from './octokit-client'
import pLimit from 'p-limit'
import * as utils from './utils'
@@ -52,6 +58,7 @@ export class GitHubHelper {
options.baseUrl = 'https://api.github.com'
}
options.throttle = throttleOptions
options.retry = retryOptions
this.octokit = new Octokit(options)
}
@@ -63,6 +70,50 @@ export class GitHubHelper {
}
}
private async getPullNumber(
baseRepository: string,
headBranch: string,
baseBranch: string
): Promise<number> {
const {data: pulls} = await this.octokit.rest.pulls.list({
...this.parseRepository(baseRepository),
state: 'open',
head: headBranch,
base: baseBranch
})
let pullNumber: number | undefined = undefined
if (pulls?.length === 0 || pulls === null || pulls === undefined) {
// This is a fallback due to a bug that affects the list endpoint when called on forks with the same owner as the repository parent.
core.info(
`Pull request not found via list endpoint; attempting fallback mechanism`
)
for await (const response of this.octokit.paginate.iterator(
this.octokit.rest.pulls.list,
{
...this.parseRepository(baseRepository),
state: 'open',
base: baseBranch
}
)) {
const existingPull = response.data.find(
pull => pull.head.label === headBranch
)
if (existingPull !== undefined) {
pullNumber = existingPull.number
break
}
}
} else {
pullNumber = pulls[0].number
}
if (pullNumber === undefined) {
throw new Error(
`Failed to find pull request number for branch ${headBranch}`
)
}
return pullNumber
}
private async createOrUpdate(
inputs: Inputs,
baseRepository: string,
@@ -113,16 +164,15 @@ export class GitHubHelper {
// Update the pull request that exists for this branch and base
core.info(`Fetching existing pull request`)
const {data: pulls} = await this.octokit.rest.pulls.list({
...this.parseRepository(baseRepository),
state: 'open',
head: headBranch,
base: inputs.base
})
const pullNumber = await this.getPullNumber(
baseRepository,
headBranch,
inputs.base
)
core.info(`Attempting update of pull request`)
const {data: pull} = await this.octokit.rest.pulls.update({
...this.parseRepository(baseRepository),
pull_number: pulls[0].number,
pull_number: pullNumber,
title: inputs.title,
body: inputs.body
})
@@ -160,32 +210,51 @@ export class GitHubHelper {
headRepository
)
// After creating a new PR, follow-up API calls can fail with a 422
// "Could not resolve to a node" error due to GitHub API eventual
// consistency. Wrap post-creation calls with targeted retry logic.
// See: https://github.com/peter-evans/create-pull-request/issues/4321
const isEventualConsistencyError = (e: unknown): boolean =>
e instanceof RequestError &&
e.status === 422 &&
e.message.includes('Could not resolve to a node')
const withRetryForNewPr = <T>(fn: () => Promise<T>): Promise<T> =>
pull.created
? utils.retryWithBackoff(fn, isEventualConsistencyError)
: fn()
// Apply milestone
if (inputs.milestone) {
core.info(`Applying milestone '${inputs.milestone}'`)
await this.octokit.rest.issues.update({
...this.parseRepository(baseRepository),
issue_number: pull.number,
milestone: inputs.milestone
})
await withRetryForNewPr(() =>
this.octokit.rest.issues.update({
...this.parseRepository(baseRepository),
issue_number: pull.number,
milestone: inputs.milestone
})
)
}
// Apply labels
if (inputs.labels.length > 0) {
core.info(`Applying labels '${inputs.labels}'`)
await this.octokit.rest.issues.addLabels({
...this.parseRepository(baseRepository),
issue_number: pull.number,
labels: inputs.labels
})
await withRetryForNewPr(() =>
this.octokit.rest.issues.addLabels({
...this.parseRepository(baseRepository),
issue_number: pull.number,
labels: inputs.labels
})
)
}
// Apply assignees
if (inputs.assignees.length > 0) {
core.info(`Applying assignees '${inputs.assignees}'`)
await this.octokit.rest.issues.addAssignees({
...this.parseRepository(baseRepository),
issue_number: pull.number,
assignees: inputs.assignees
})
await withRetryForNewPr(() =>
this.octokit.rest.issues.addAssignees({
...this.parseRepository(baseRepository),
issue_number: pull.number,
assignees: inputs.assignees
})
)
}
// Request reviewers and team reviewers
@@ -201,11 +270,13 @@ export class GitHubHelper {
}
if (Object.keys(requestReviewersParams).length > 0) {
try {
await this.octokit.rest.pulls.requestReviewers({
...this.parseRepository(baseRepository),
pull_number: pull.number,
...requestReviewersParams
})
await withRetryForNewPr(() =>
this.octokit.rest.pulls.requestReviewers({
...this.parseRepository(baseRepository),
pull_number: pull.number,
...requestReviewersParams
})
)
} catch (e) {
if (utils.getErrorMessage(e).includes(ERROR_PR_REVIEW_TOKEN_SCOPE)) {
core.error(
+7
View File
@@ -2,6 +2,7 @@ import * as core from '@actions/core'
import {Octokit as OctokitCore} from '@octokit/core'
import {paginateRest} from '@octokit/plugin-paginate-rest'
import {restEndpointMethods} from '@octokit/plugin-rest-endpoint-methods'
import {retry} from '@octokit/plugin-retry'
import {throttling} from '@octokit/plugin-throttling'
import {fetch} from 'node-fetch-native/proxy'
export {RestEndpointMethodTypes} from '@octokit/plugin-rest-endpoint-methods'
@@ -11,6 +12,7 @@ export {OctokitOptions} from '@octokit/core/dist-types/types'
export const Octokit = OctokitCore.plugin(
paginateRest,
restEndpointMethods,
retry,
throttling,
autoProxyAgent
)
@@ -32,6 +34,11 @@ export const throttleOptions = {
}
}
export const retryOptions = {
// 429 is handled by the throttling plugin, so we exclude it from retry
doNotRetry: [400, 401, 403, 404, 410, 422, 429, 451]
}
// Octokit plugin to support the standard environment variables http_proxy, https_proxy and no_proxy
function autoProxyAgent(octokit: OctokitCore) {
octokit.hook.before('request', options => {
+29
View File
@@ -135,3 +135,32 @@ export function getErrorMessage(error: unknown) {
if (error instanceof Error) return error.message
return String(error)
}
export const isSelfHosted = (): boolean =>
process.env['RUNNER_ENVIRONMENT'] !== 'github-hosted' &&
(process.env['AGENT_ISSELFHOSTED'] === '1' ||
process.env['AGENT_ISSELFHOSTED'] === undefined)
export async function retryWithBackoff<T>(
fn: () => Promise<T>,
shouldRetry: (error: unknown) => boolean,
maxRetries = 2,
delayMs = 1000
): Promise<T> {
for (let attempt = 0; attempt <= maxRetries; attempt++) {
try {
return await fn()
} catch (e) {
if (attempt < maxRetries && shouldRetry(e)) {
const delay = delayMs * Math.pow(2, attempt)
core.info(
`Request failed (attempt ${attempt + 1}/${maxRetries + 1}), retrying in ${delay}ms...`
)
await new Promise(resolve => setTimeout(resolve, delay))
} else {
throw e
}
}
}
throw new Error('Unexpected: retry loop exited without return or throw')
}