* GitCommandManager: add a function to get a file's contents at a specific revision
* use showFileAtRef instead of readFileBase64
* Teach GitCommandManager.exec about an object of exec parameters so we can add more
* Encode the showFiletRef output as base64 out of the gate
* Fix missing async for function
* Use Buffer.concat to avoid issues with partial data streams
* formatting
---------
Co-authored-by: gustavderdrache <alex.ford@determinate.systems>
The option suggested here (Read only) is not an option, and wouldn't mean/do anything - you can read these files if you have access to the repo files. The description says this is needed if the PR could change the workflow files, so you need "Read and Write". Pretty sure this is just a typo, copied from the line below instead of the line above.
* Add support for signed commits (#3055)
* formatting
* fix eslint and lint errors
* shift setting the base to before the push
* sign commits by default for testing
* add debug lines
* read to buffer not string and use non-legacy method to base64
* debug payload without contents
* disable linter for debug code
* fix filepath when using path input
* try to fix head repo
* remove commented code
* Try refactor of file changes
* add tests for building file changes
* add build file changes test for binary files
* refactor graphql code into github helper class
* build file changes even when there is no diff
* add function to get commit detail
* fix format
* build branch commits
* use source mode for deleted files
* try rest api route
* fix check for branch existence
* force push
* try fix base tree
* debug commit verification
* debug commit verification
* fix format and cleanup
* add executable mode file to test
* limit blob creation concurrency
* only build commits when feature enabled
* remove unused code
* update readme link
* update docs for commit signing
* fix capital letter
* update docs
* add throttling
* set default back to false
* output head sha and verified status
* log outputs
* fix head sha output
* default the operation output to none
* output retryafter for secondary rate limit
* use separate client for branch and pull operations
* add maintainer-can-modify input
* rename git-token to branch-token
* fix branch token input
* remove deprecated env output
* update docs
* fix doc
* update docs
* build branch commits when there is a diff with the base
* check verification status of head commit when not known
* fix verified output when no commit signing is being used
* draft always-true
* convert to draft on branch updates when there is a diff with base
* update docs with blob size limit
* catch errors during blob creation for debugging
* parse empty commits
* pass base commit to push signed commits
* use parent commit details in create commit
* use parent tree for base_tree
* multipart tree creation
* update docs
* update readme about the permissions of the default token
* fix edge case where changes are partially merged
* add updating documentation
* fix typo
* update major version
---------
Co-authored-by: Ravi <1299606+rustycl0ck@users.noreply.github.com>
2024-09-03 08:54:12 +01:00
22 changed files with 2455 additions and 28278 deletions
You can also pin to a [specific release](https://github.com/peter-evans/create-pull-request/releases) version in the format `@v6.x.x`
You can also pin to a [specific release](https://github.com/peter-evans/create-pull-request/releases) version in the format `@v7.x.x`
### Workflow permissions
@ -99,7 +99,7 @@ Other token options:
#### branch-token
The action first creates a branch, and then creates a pull request for the branch.
For some rare use cases it can be useful, or even neccessary, to use different tokens for these operations.
For some rare use cases it can be useful, or even necessary, to use different tokens for these operations.
It is not advisable to use this input unless you know you need to.
#### commit-message
@ -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@v6
uses:peter-evans/create-pull-request@v7
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@v6
uses:peter-evans/create-pull-request@v7
- 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@v6
uses:peter-evans/create-pull-request@v7
with:
add-paths:|
*.java
@ -243,25 +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@v6
```
### Create a project card
To create a project card for the pull request, pass the `pull-request-number` step output to [create-or-update-project-card](https://github.com/peter-evans/create-or-update-project-card) action.
--`+a;constt=newUint8Array(a.length);for(letn=0;n<a.length;n++)t[n]=a.charCodeAt(n),this.boundaryChars[t[n]]=!0;this.boundary=t,this.lookbehind=newUint8Array(this.boundary.length+8),this.state=S.START_BOUNDARY}write(a){lett=0;constn=a.length;letE=this.index,{lookbehind:d,boundary:h,boundaryChars:H,index:e,state:o,flags:l}=this;constb=this.boundary.length,m=b-1,O=a.length;letr,P;constu=c(D=>{this[D+"Mark"]=t},"mark"),i=c(D=>{deletethis[D+"Mark"]},"clear"),T=c((D,p,R,g)=>{(p===void0||p!==R)&&this[D](g&&g.subarray(p,R))},"callback"),L=c((D,p)=>{constR=D+"Mark";Rinthis&&(p?(T(D,this[R],t,a),deletethis[R]):(T(D,this[R],a.length,a),this[R]=0))},"dataCallback");for(t=0;t<n;t++)switch(r=a[t],o){caseS.START_BOUNDARY:if(e===h.length-2){if(r===HYPHEN)l|=F.LAST_BOUNDARY;elseif(r!==CR)return;e++;break}elseif(e-1===h.length-2){if(l&F.LAST_BOUNDARY&&r===HYPHEN)o=S.END,l=0;elseif(!(l&F.LAST_BOUNDARY)&&r===LF)e=0,T("onPartBegin"),o=S.HEADER_FIELD_START;elsereturn;break}r!==h[e+2]&&(e=-2),r===h[e+2]&&e++;break;caseS.HEADER_FIELD_START:o=S.HEADER_FIELD,u("onHeaderField"),e=0;caseS.HEADER_FIELD:if(r===CR){i("onHeaderField"),o=S.HEADERS_ALMOST_DONE;break}if(e++,r===HYPHEN)break;if(r===COLON){if(e===1)return;L("onHeaderField",!0),o=S.HEADER_VALUE_START;break}if(P=lower(r),P<A||P>Z)return;break;caseS.HEADER_VALUE_START:if(r===SPACE)break;u("onHeaderValue"),o=S.HEADER_VALUE;caseS.HEADER_VALUE:r===CR&&(L("onHeaderValue",!0),T("onHeaderEnd"),o=S.HEADER_VALUE_ALMOST_DONE);break;caseS.HEADER_VALUE_ALMOST_DONE:if(r!==LF)return;o=S.HEADER_FIELD_START;break;caseS.HEADERS_ALMOST_DONE:if(r!==LF)return;T("onHeadersEnd"),o=S.PART_DATA_START;break;caseS.PART_DATA_START:o=S.PART_DATA,u("onPartData");caseS.PART_DATA:if(E=e,e===0){for(t+=m;t<O&&!(a[t]inH);)t+=b;t-=m,r=a[t]}if(e<h.length)h[e]===r?(e===0&&L("onPartData",!0),e++):e=0;elseif(e===h.length)e++,r===CR?l|=F.PART_BOUNDARY:r===HYPHEN?l|=F.LAST_BOUNDARY:e=0;elseif(e-1===h.length)if(l&F.PART_BOUNDARY){if(e=0,r===LF){l&=~F.PART_BOUNDARY,T("onPartEnd"),T("onPartBegin"),o=S.HEADER_FIELD_START;break}}elsel&F.LAST_BOUNDARY&&r===HYPHEN?(T("onPartEnd"),o=S.END,l=0):e=0;if(e>0)d[e-1]=r;elseif(E>0){constD=newUint8Array(d.buffer,d.byteOffset,d.byteLength);T("onPartData",0,E,D),E=0,u("onPartData"),t--}break;caseS.END:break;default:thrownewError(`Unexpected state entered: ${o}`)}L("onHeaderField"),L("onHeaderValue"),L("onPartData"),this.index=e,this.state=o,this.flags=l}end(){if(this.state===S.HEADER_FIELD_START&&this.index===0||this.state===S.PART_DATA&&this.index===this.boundary.length)this.onPartEnd();elseif(this.state!==S.END)thrownewError("MultipartParser.end(): stream ended unexpectedly")}}function_fileName(_){consta=_.match(/\bfilename=("(.*?)"|([^()<>@,;:\\"/[\]?={}\s\t]+))($|;\s)/i);if(!a)return;constt=a[2]||a[3]||"";letn=t.slice(t.lastIndexOf("\\")+1);returnn=n.replace(/%22/g,'"'),n=n.replace(/&#(\d{4});/g,(E,d)=>String.fromCharCode(d)),n}c(_fileName,"_fileName");asyncfunctiontoFormData(_,a){if(!/multipart/i.test(a))thrownewTypeError("Failed to fetch");constt=a.match(/boundary=(?:"([^"]+)"|([^;]+))/i);if(!t)thrownewTypeError("no or bad content-type header, no multipart boundary");constn=newMultipartParser(t[1]||t[2]);letE,d,h,H,e,o;constl=[],b=newnode.FormData,m=c(i=>{h+=u.decode(i,{stream:!0})},"onPartData"),O=c(i=>{l.push(i)},"appendToFile"),r=c(()=>{consti=newnode.File(l,o,{type:e});b.append(H,i)},"appendFileToFormData"),P=c(()=>{b.append(H,h)},"appendEntryToFormData"),u=newTextDecoder("utf-8");u.decode(),n.onPartBegin=function(){n.onPartData=m,n.onPartEnd=P,E="",d="",h="",H="",e="",o=null,l.length=0},n.onHeaderField=function(i){E+=u.decode(i,{stream:!0})},n.onHeaderValue=function(i){d+=u.decode(i,{stream:!0})},n.onHeaderEnd=function(){if(d+=u.decode(),E=E.toLowerCase(),E==="content-disposition"){consti=d.match(/\bname=("([^"]*)"|([^()<>@,;:\\"/[\]?={}\s\t]+))/i);i&&(H=i[2]||i[3]||""),o=_fileName(d),o&&(n.onPartData=O,n.onPartEnd=r)}elseE==="content-type"&&(e=d);d="",E=""};forawait(constiof_)n.write(i);returnn.end(),b}c(toFormData,"toFormData"),exports.toFormData=toFormData;
@ -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.
@ -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@v6
- uses:peter-evans/create-pull-request@v7
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@v6
- uses:peter-evans/create-pull-request@v7
with:
base:main
```
@ -186,7 +186,7 @@ Checking out a branch from a different repository from where the workflow is exe
# Make changes to pull request here
- uses:peter-evans/create-pull-request@v6
- uses:peter-evans/create-pull-request@v7
with:
token:${{ secrets.PAT }}
```
@ -216,7 +216,7 @@ How to use SSH (deploy keys) with create-pull-request action:
# Make changes to pull request here
- name:Create Pull Request
uses:peter-evans/create-pull-request@v6
uses:peter-evans/create-pull-request@v7
```
### Push pull request branches to a fork
@ -231,7 +231,7 @@ It will use their own fork to push code and create the pull request.
1. Create a new GitHub user and login.
2. Fork the repository that you will be creating pull requests in.
3. Create a Classic [Personal Access Token (PAT)](https://docs.github.com/en/github/authenticating-to-github/creating-a-personal-access-token) with `repo` scope.
3. Create a Classic [Personal Access Token (PAT)](https://docs.github.com/en/github/authenticating-to-github/creating-a-personal-access-token) with `repo` and `workflow` scopes.
4. Logout and log back into your main user account.
5. Add a secret to your repository containing the above PAT.
6. As shown in the following example workflow, set the `push-to-fork` input to the full repository name of the fork.
@ -241,7 +241,7 @@ It will use their own fork to push code and create the pull request.
# Make changes to pull request here
- uses:peter-evans/create-pull-request@v6
- uses:peter-evans/create-pull-request@v7
with:
token:${{ secrets.MACHINE_USER_PAT }}
push-to-fork:machine-user/fork-of-repository
@ -284,7 +284,7 @@ The following is an example of pushing to a fork using GitHub App tokens.
commit-message:Update swagger-ui to ${{ steps.swagger-ui.outputs.release_tag }}
title:Update SwaggerUI to ${{ steps.swagger-ui.outputs.release_tag }}
@ -324,7 +324,7 @@ jobs:
### Keep a fork up-to-date with its upstream
This example is designed to be run in a seperate repository from the fork repository itself.
This example is designed to be run in a separate repository from the fork repository itself.
The aim of this is to prevent committing anything to the fork's default branch would cause it to differ from the upstream.
In the following example workflow, `owner/repo` is the upstream repository and `fork-owner/repo` is the fork. It assumes the default branch of the upstream repository is called `main`.
@ -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@v6
uses:peter-evans/create-pull-request@v7
with:
token:${{ secrets.PAT }}
branch:upstream-changes
@ -384,7 +384,7 @@ jobs:
--domains quotes.toscrape.com \
http://quotes.toscrape.com/
- name:Create Pull Request
uses:peter-evans/create-pull-request@v6
uses:peter-evans/create-pull-request@v7
with:
commit-message:update local website copy
title:Automated Updates to Local Website Copy
@ -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@v6
uses:peter-evans/create-pull-request@v7
with:
commit-message:autopep8 action fixes
title:Fixes by autopep8 action
@ -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@v6
uses:peter-evans/create-pull-request@v7
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@v6
uses:peter-evans/create-pull-request@v7
with:
body:${{ steps.template.outputs.result }}
```
@ -612,3 +612,30 @@ To enable step debug logging set the secret `ACTIONS_STEP_DEBUG` to `true` in th
MATRIX_CONTEXT:${{ toJson(matrix) }}
run:echo "$MATRIX_CONTEXT"
```
### Show an annotation message for a created pull request
Showing an annotation message for a created or updated pull request allows you to confirm the pull request easily, such as by visiting the link. This can be achieved by adding a step that uses the [`notice` workflow command](https://docs.github.com/en/actions/writing-workflows/choosing-what-your-workflow-does/workflow-commands-for-github-actions?tool=bash#setting-a-notice-message).
In this example, when a pull request is created, you will be able to see the following message on an action run page (e.g., `/actions/runs/12812393039`):
```
https://github.com/peter-evans/create-pull-request/pull/1 was created.
- Action input `git-token` has been renamed `branch-token`, to be more clear about its purpose. The `branch-token` is the token that the action will use to create and update the branch.
- The action now handles requests that have been rate-limited by GitHub. Requests hitting a primary rate limit will retry twice, for a total of three attempts. Requests hitting a secondary rate limit will not be retried.
- The `pull-request-operation` output now returns `none` when no operation was executed.
- Removed deprecated output environment variable `PULL_REQUEST_NUMBER`. Please use the `pull-request-number` action output instead.
### What's new
- The action can now sign commits as `github-actions[bot]` when using `GITHUB_TOKEN`, or your own bot when using [GitHub App tokens](concepts-guidelines.md#authenticating-with-github-app-generated-tokens). See [commit signing](concepts-guidelines.md#commit-signature-verification-for-bots) for details.
- Action input `draft` now accepts a new value `always-true`. This will set the pull request to draft status when the pull request is updated, as well as on creation.
- A new action input `maintainer-can-modify` indicates whether [maintainers can modify](https://docs.github.com/en/pull-requests/collaborating-with-pull-requests/working-with-forks/allowing-changes-to-a-pull-request-branch-created-from-a-fork) the pull request. The default is `true`, which retains the existing behaviour of the action.
- A new output `pull-request-commits-verified` returns `true` or `false`, indicating whether GitHub considers the signature of the branch's commits to be verified.
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.