Compare commits
	
		
			No commits in common. "bc14ce351a6a25022a490f2be0570c700083a7fe" and "f34bce57c53bba8c9aad22748a2c7ea0027f26f0" have entirely different histories.
		
	
	
		
			
				bc14ce351a
			
			...
			
				f34bce57c5
			
		
	
		
					 10 changed files with 60 additions and 204 deletions
				
			
		
							
								
								
									
										7
									
								
								.github/workflows/ci.yaml
									
										
									
									
										vendored
									
									
								
							
							
						
						
									
										7
									
								
								.github/workflows/ci.yaml
									
										
									
									
										vendored
									
									
								
							|  | @ -15,7 +15,6 @@ jobs: | ||||||
| 
 | 
 | ||||||
|       - name: Comment PR with message |       - name: Comment PR with message | ||||||
|         uses: ./ |         uses: ./ | ||||||
|         id: nrt_message |  | ||||||
|         with: |         with: | ||||||
|           message: | |           message: | | ||||||
|             Current branch is `${{ github.head_ref }}`. |             Current branch is `${{ github.head_ref }}`. | ||||||
|  | @ -56,11 +55,5 @@ jobs: | ||||||
|           comment_tag: nrt_create_if_not_exists |           comment_tag: nrt_create_if_not_exists | ||||||
|           create_if_not_exists: false |           create_if_not_exists: false | ||||||
| 
 | 
 | ||||||
|       - name: Check outputs |  | ||||||
|         run: | |  | ||||||
|           echo "id : ${{ steps.nrt_message.outputs.id }}" |  | ||||||
|           echo "body : ${{ steps.nrt_message.outputs.body }}" |  | ||||||
|           echo "html_url : ${{ steps.nrt_message.outputs.html_url }}" |  | ||||||
| 
 |  | ||||||
|       - name: (AFTER) Setup test cases |       - name: (AFTER) Setup test cases | ||||||
|         run: rm /tmp/foobar.txt |         run: rm /tmp/foobar.txt | ||||||
							
								
								
									
										2
									
								
								.nvmrc
									
										
									
									
									
								
							
							
						
						
									
										2
									
								
								.nvmrc
									
										
									
									
									
								
							|  | @ -1 +1 @@ | ||||||
| 20.8.1 | 16.13.1 | ||||||
							
								
								
									
										29
									
								
								README.md
									
										
									
									
									
								
							
							
						
						
									
										29
									
								
								README.md
									
										
									
									
									
								
							|  | @ -125,35 +125,6 @@ This will delete the comment at the end of the job. | ||||||
| | `mode` | Mode that will be used to update comment (upsert/recreate/delete) | | upsert | | | `mode` | Mode that will be used to update comment (upsert/recreate/delete) | | upsert | | ||||||
| | `create_if_not_exists` | Whether a comment should be created even if `comment_tag` is not found | | true | | | `create_if_not_exists` | Whether a comment should be created even if `comment_tag` is not found | | true | | ||||||
| 
 | 
 | ||||||
| 
 |  | ||||||
| ## Outputs  |  | ||||||
| 
 |  | ||||||
| ### Action outputs |  | ||||||
| 
 |  | ||||||
| You can get some outputs from this actions :  |  | ||||||
| 
 |  | ||||||
| | Name | Description | |  | ||||||
| | --- | --- | |  | ||||||
| | `id` | Comment id that was created or updated |  |  | ||||||
| | `body` | Comment body | |  | ||||||
| | `html_url` | URL of the comment created or updated | |  | ||||||
| 
 |  | ||||||
| ### Example output |  | ||||||
| 
 |  | ||||||
| ```yaml |  | ||||||
| - name: Comment PR |  | ||||||
|   uses: thollander/actions-comment-pull-request@v2 |  | ||||||
|   id: hello |  | ||||||
|   with: |  | ||||||
|     message: | |  | ||||||
|       Hello world ! :wave: |  | ||||||
| - name: Check outputs |  | ||||||
|   run: | |  | ||||||
|     echo "id : ${{ steps.hello.outputs.id }}" |  | ||||||
|     echo "body : ${{ steps.hello.outputs.body }}" |  | ||||||
|     echo "html_url : ${{ steps.hello.outputs.html_url }}" |  | ||||||
| ``` |  | ||||||
| 
 |  | ||||||
| ## Permissions | ## Permissions | ||||||
| 
 | 
 | ||||||
| Depending on the permissions granted to your token, you may lack some rights.  | Depending on the permissions granted to your token, you may lack some rights.  | ||||||
|  |  | ||||||
|  | @ -25,6 +25,6 @@ inputs: | ||||||
|     description: 'Whether a comment should be created even if comment_tag is not found.' |     description: 'Whether a comment should be created even if comment_tag is not found.' | ||||||
|     default: 'true' |     default: 'true' | ||||||
| runs: | runs: | ||||||
|   using: 'node20' |   using: 'node16' | ||||||
|   main: 'lib/index.js' |   main: 'lib/index.js' | ||||||
|   post: 'lib/cleanup/index.js' |   post: 'lib/cleanup/index.js' | ||||||
|  |  | ||||||
|  | @ -558,7 +558,7 @@ class OidcClient { | ||||||
|                 .catch(error => { |                 .catch(error => { | ||||||
|                 throw new Error(`Failed to get ID Token. \n 
 |                 throw new Error(`Failed to get ID Token. \n 
 | ||||||
|         Error Code : ${error.statusCode}\n  |         Error Code : ${error.statusCode}\n  | ||||||
|         Error Message: ${error.message}`);
 |         Error Message: ${error.result.message}`);
 | ||||||
|             }); |             }); | ||||||
|             const id_token = (_a = res.result) === null || _a === void 0 ? void 0 : _a.value; |             const id_token = (_a = res.result) === null || _a === void 0 ? void 0 : _a.value; | ||||||
|             if (!id_token) { |             if (!id_token) { | ||||||
|  |  | ||||||
							
								
								
									
										47
									
								
								lib/index.js
									
										
									
									
									
								
							
							
						
						
									
										47
									
								
								lib/index.js
									
										
									
									
									
								
							|  | @ -558,7 +558,7 @@ class OidcClient { | ||||||
|                 .catch(error => { |                 .catch(error => { | ||||||
|                 throw new Error(`Failed to get ID Token. \n 
 |                 throw new Error(`Failed to get ID Token. \n 
 | ||||||
|         Error Code : ${error.statusCode}\n  |         Error Code : ${error.statusCode}\n  | ||||||
|         Error Message: ${error.message}`);
 |         Error Message: ${error.result.message}`);
 | ||||||
|             }); |             }); | ||||||
|             const id_token = (_a = res.result) === null || _a === void 0 ? void 0 : _a.value; |             const id_token = (_a = res.result) === null || _a === void 0 ? void 0 : _a.value; | ||||||
|             if (!id_token) { |             if (!id_token) { | ||||||
|  | @ -9582,40 +9582,6 @@ async function run() { | ||||||
|                 }); |                 }); | ||||||
|             })); |             })); | ||||||
|         } |         } | ||||||
|         async function createComment({ owner, repo, issue_number, body, }) { |  | ||||||
|             const { data: comment } = await octokit.rest.issues.createComment({ |  | ||||||
|                 owner, |  | ||||||
|                 repo, |  | ||||||
|                 issue_number, |  | ||||||
|                 body, |  | ||||||
|             }); |  | ||||||
|             core.setOutput('id', comment.id); |  | ||||||
|             core.setOutput('body', comment.body); |  | ||||||
|             core.setOutput('html_url', comment.html_url); |  | ||||||
|             await addReactions(comment.id, reactions); |  | ||||||
|             return comment; |  | ||||||
|         } |  | ||||||
|         async function updateComment({ owner, repo, comment_id, body, }) { |  | ||||||
|             const { data: comment } = await octokit.rest.issues.updateComment({ |  | ||||||
|                 owner, |  | ||||||
|                 repo, |  | ||||||
|                 comment_id, |  | ||||||
|                 body, |  | ||||||
|             }); |  | ||||||
|             core.setOutput('id', comment.id); |  | ||||||
|             core.setOutput('body', comment.body); |  | ||||||
|             core.setOutput('html_url', comment.html_url); |  | ||||||
|             await addReactions(comment.id, reactions); |  | ||||||
|             return comment; |  | ||||||
|         } |  | ||||||
|         async function deleteComment({ owner, repo, comment_id }) { |  | ||||||
|             const { data: comment } = await octokit.rest.issues.deleteComment({ |  | ||||||
|                 owner, |  | ||||||
|                 repo, |  | ||||||
|                 comment_id, |  | ||||||
|             }); |  | ||||||
|             return comment; |  | ||||||
|         } |  | ||||||
|         const comment_tag_pattern = comment_tag |         const comment_tag_pattern = comment_tag | ||||||
|             ? `<!-- thollander/actions-comment-pull-request "${comment_tag}" -->` |             ? `<!-- thollander/actions-comment-pull-request "${comment_tag}" -->` | ||||||
|             : null; |             : null; | ||||||
|  | @ -9632,23 +9598,25 @@ async function run() { | ||||||
|             } |             } | ||||||
|             if (comment) { |             if (comment) { | ||||||
|                 if (mode === 'upsert') { |                 if (mode === 'upsert') { | ||||||
|                     await updateComment({ |                     await octokit.rest.issues.updateComment({ | ||||||
|                         ...context.repo, |                         ...context.repo, | ||||||
|                         comment_id: comment.id, |                         comment_id: comment.id, | ||||||
|                         body, |                         body, | ||||||
|                     }); |                     }); | ||||||
|  |                     await addReactions(comment.id, reactions); | ||||||
|                     return; |                     return; | ||||||
|                 } |                 } | ||||||
|                 else if (mode === 'recreate') { |                 else if (mode === 'recreate') { | ||||||
|                     await deleteComment({ |                     await octokit.rest.issues.deleteComment({ | ||||||
|                         ...context.repo, |                         ...context.repo, | ||||||
|                         comment_id: comment.id, |                         comment_id: comment.id, | ||||||
|                     }); |                     }); | ||||||
|                     await createComment({ |                     const { data: newComment } = await octokit.rest.issues.createComment({ | ||||||
|                         ...context.repo, |                         ...context.repo, | ||||||
|                         issue_number, |                         issue_number, | ||||||
|                         body, |                         body, | ||||||
|                     }); |                     }); | ||||||
|  |                     await addReactions(newComment.id, reactions); | ||||||
|                     return; |                     return; | ||||||
|                 } |                 } | ||||||
|                 else if (mode === 'delete') { |                 else if (mode === 'delete') { | ||||||
|  | @ -9667,11 +9635,12 @@ async function run() { | ||||||
|                 return; |                 return; | ||||||
|             } |             } | ||||||
|         } |         } | ||||||
|         await createComment({ |         const { data: comment } = await octokit.rest.issues.createComment({ | ||||||
|             ...context.repo, |             ...context.repo, | ||||||
|             issue_number, |             issue_number, | ||||||
|             body, |             body, | ||||||
|         }); |         }); | ||||||
|  |         await addReactions(comment.id, reactions); | ||||||
|     } |     } | ||||||
|     catch (error) { |     catch (error) { | ||||||
|         if (error instanceof Error) { |         if (error instanceof Error) { | ||||||
|  |  | ||||||
							
								
								
									
										86
									
								
								package-lock.json
									
										
									
										generated
									
									
									
								
							
							
						
						
									
										86
									
								
								package-lock.json
									
										
									
										generated
									
									
									
								
							|  | @ -1,12 +1,12 @@ | ||||||
| { | { | ||||||
|   "name": "actions-comment-pull-request", |   "name": "actions-comment-pull-request", | ||||||
|   "version": "2.5.0", |   "version": "2.4.2", | ||||||
|   "lockfileVersion": 2, |   "lockfileVersion": 2, | ||||||
|   "requires": true, |   "requires": true, | ||||||
|   "packages": { |   "packages": { | ||||||
|     "": { |     "": { | ||||||
|       "name": "actions-comment-pull-request", |       "name": "actions-comment-pull-request", | ||||||
|       "version": "2.5.0", |       "version": "2.4.2", | ||||||
|       "license": "MIT", |       "license": "MIT", | ||||||
|       "dependencies": { |       "dependencies": { | ||||||
|         "@actions/core": "^1.10.1", |         "@actions/core": "^1.10.1", | ||||||
|  | @ -16,11 +16,11 @@ | ||||||
|         "@actions/tool-cache": "^2.0.1" |         "@actions/tool-cache": "^2.0.1" | ||||||
|       }, |       }, | ||||||
|       "devDependencies": { |       "devDependencies": { | ||||||
|         "@tsconfig/node20": "^20.1.2", |         "@tsconfig/node16": "^16.1.1", | ||||||
|         "@types/node": "^20.8.1", |         "@types/node": "^18.16.2", | ||||||
|         "@vercel/ncc": "^0.38.1", |         "@vercel/ncc": "^0.36.1", | ||||||
|         "prettier": "^3.0.3", |         "prettier": "^3.0.3", | ||||||
|         "typescript": "^5.3.3" |         "typescript": "^5.2.2" | ||||||
|       } |       } | ||||||
|     }, |     }, | ||||||
|     "node_modules/@actions/core": { |     "node_modules/@actions/core": { | ||||||
|  | @ -187,25 +187,22 @@ | ||||||
|         "@octokit/openapi-types": "^12.11.0" |         "@octokit/openapi-types": "^12.11.0" | ||||||
|       } |       } | ||||||
|     }, |     }, | ||||||
|     "node_modules/@tsconfig/node20": { |     "node_modules/@tsconfig/node16": { | ||||||
|       "version": "20.1.2", |       "version": "16.1.1", | ||||||
|       "resolved": "https://registry.npmjs.org/@tsconfig/node20/-/node20-20.1.2.tgz", |       "resolved": "https://registry.npmjs.org/@tsconfig/node16/-/node16-16.1.1.tgz", | ||||||
|       "integrity": "sha512-madaWq2k+LYMEhmcp0fs+OGaLFk0OenpHa4gmI4VEmCKX4PJntQ6fnnGADVFrVkBj0wIdAlQnK/MrlYTHsa1gQ==", |       "integrity": "sha512-+pio93ejHN4nINX4pXqfnR/fPLRtJBaT4ORaa5RH0Oc1zoYmo2B2koG+M328CQhHKn1Wj6FcOxCDFXAot9NhvA==", | ||||||
|       "dev": true |       "dev": true | ||||||
|     }, |     }, | ||||||
|     "node_modules/@types/node": { |     "node_modules/@types/node": { | ||||||
|       "version": "20.8.7", |       "version": "18.16.2", | ||||||
|       "resolved": "https://registry.npmjs.org/@types/node/-/node-20.8.7.tgz", |       "resolved": "https://registry.npmjs.org/@types/node/-/node-18.16.2.tgz", | ||||||
|       "integrity": "sha512-21TKHHh3eUHIi2MloeptJWALuCu5H7HQTdTrWIFReA8ad+aggoX+lRes3ex7/FtpC+sVUpFMQ+QTfYr74mruiQ==", |       "integrity": "sha512-GQW/JL/5Fz/0I8RpeBG9lKp0+aNcXEaVL71c0D2Q0QHDTFvlYKT7an0onCUXj85anv7b4/WesqdfchLc0jtsCg==", | ||||||
|       "dev": true, |       "dev": true | ||||||
|       "dependencies": { |  | ||||||
|         "undici-types": "~5.25.1" |  | ||||||
|       } |  | ||||||
|     }, |     }, | ||||||
|     "node_modules/@vercel/ncc": { |     "node_modules/@vercel/ncc": { | ||||||
|       "version": "0.38.1", |       "version": "0.36.1", | ||||||
|       "resolved": "https://registry.npmjs.org/@vercel/ncc/-/ncc-0.38.1.tgz", |       "resolved": "https://registry.npmjs.org/@vercel/ncc/-/ncc-0.36.1.tgz", | ||||||
|       "integrity": "sha512-IBBb+iI2NLu4VQn3Vwldyi2QwaXt5+hTyh58ggAMoCGE6DJmPvwL3KPBWcJl1m9LYPChBLE980Jw+CS4Wokqxw==", |       "integrity": "sha512-S4cL7Taa9yb5qbv+6wLgiKVZ03Qfkc4jGRuiUQMQ8HGBD5pcNRnHeYM33zBvJE4/zJGjJJ8GScB+WmTsn9mORw==", | ||||||
|       "dev": true, |       "dev": true, | ||||||
|       "bin": { |       "bin": { | ||||||
|         "ncc": "dist/ncc/cli.js" |         "ncc": "dist/ncc/cli.js" | ||||||
|  | @ -293,9 +290,9 @@ | ||||||
|       } |       } | ||||||
|     }, |     }, | ||||||
|     "node_modules/typescript": { |     "node_modules/typescript": { | ||||||
|       "version": "5.3.3", |       "version": "5.2.2", | ||||||
|       "resolved": "https://registry.npmjs.org/typescript/-/typescript-5.3.3.tgz", |       "resolved": "https://registry.npmjs.org/typescript/-/typescript-5.2.2.tgz", | ||||||
|       "integrity": "sha512-pXWcraxM0uxAS+tN0AG/BF2TyqmHO014Z070UsJ+pFvYuRSq8KH8DmWpnbXe0pEPDHXZV3FcAbJkijJ5oNEnWw==", |       "integrity": "sha512-mI4WrpHsbCIcwT9cF4FZvr80QUeKvsUsUvKDoR+X/7XHQH98xYD8YHZg7ANtz2GtZt/CBq2QJ0thkGJMHfqc1w==", | ||||||
|       "dev": true, |       "dev": true, | ||||||
|       "bin": { |       "bin": { | ||||||
|         "tsc": "bin/tsc", |         "tsc": "bin/tsc", | ||||||
|  | @ -305,12 +302,6 @@ | ||||||
|         "node": ">=14.17" |         "node": ">=14.17" | ||||||
|       } |       } | ||||||
|     }, |     }, | ||||||
|     "node_modules/undici-types": { |  | ||||||
|       "version": "5.25.3", |  | ||||||
|       "resolved": "https://registry.npmjs.org/undici-types/-/undici-types-5.25.3.tgz", |  | ||||||
|       "integrity": "sha512-Ga1jfYwRn7+cP9v8auvEXN1rX3sWqlayd4HP7OKk4mZWylEmu3KzXDUGrQUN6Ol7qo1gPvB2e5gX6udnyEPgdA==", |  | ||||||
|       "dev": true |  | ||||||
|     }, |  | ||||||
|     "node_modules/universal-user-agent": { |     "node_modules/universal-user-agent": { | ||||||
|       "version": "6.0.0", |       "version": "6.0.0", | ||||||
|       "resolved": "https://registry.npmjs.org/universal-user-agent/-/universal-user-agent-6.0.0.tgz", |       "resolved": "https://registry.npmjs.org/universal-user-agent/-/universal-user-agent-6.0.0.tgz", | ||||||
|  | @ -501,25 +492,22 @@ | ||||||
|         "@octokit/openapi-types": "^12.11.0" |         "@octokit/openapi-types": "^12.11.0" | ||||||
|       } |       } | ||||||
|     }, |     }, | ||||||
|     "@tsconfig/node20": { |     "@tsconfig/node16": { | ||||||
|       "version": "20.1.2", |       "version": "16.1.1", | ||||||
|       "resolved": "https://registry.npmjs.org/@tsconfig/node20/-/node20-20.1.2.tgz", |       "resolved": "https://registry.npmjs.org/@tsconfig/node16/-/node16-16.1.1.tgz", | ||||||
|       "integrity": "sha512-madaWq2k+LYMEhmcp0fs+OGaLFk0OenpHa4gmI4VEmCKX4PJntQ6fnnGADVFrVkBj0wIdAlQnK/MrlYTHsa1gQ==", |       "integrity": "sha512-+pio93ejHN4nINX4pXqfnR/fPLRtJBaT4ORaa5RH0Oc1zoYmo2B2koG+M328CQhHKn1Wj6FcOxCDFXAot9NhvA==", | ||||||
|       "dev": true |       "dev": true | ||||||
|     }, |     }, | ||||||
|     "@types/node": { |     "@types/node": { | ||||||
|       "version": "20.8.7", |       "version": "18.16.2", | ||||||
|       "resolved": "https://registry.npmjs.org/@types/node/-/node-20.8.7.tgz", |       "resolved": "https://registry.npmjs.org/@types/node/-/node-18.16.2.tgz", | ||||||
|       "integrity": "sha512-21TKHHh3eUHIi2MloeptJWALuCu5H7HQTdTrWIFReA8ad+aggoX+lRes3ex7/FtpC+sVUpFMQ+QTfYr74mruiQ==", |       "integrity": "sha512-GQW/JL/5Fz/0I8RpeBG9lKp0+aNcXEaVL71c0D2Q0QHDTFvlYKT7an0onCUXj85anv7b4/WesqdfchLc0jtsCg==", | ||||||
|       "dev": true, |       "dev": true | ||||||
|       "requires": { |  | ||||||
|         "undici-types": "~5.25.1" |  | ||||||
|       } |  | ||||||
|     }, |     }, | ||||||
|     "@vercel/ncc": { |     "@vercel/ncc": { | ||||||
|       "version": "0.38.1", |       "version": "0.36.1", | ||||||
|       "resolved": "https://registry.npmjs.org/@vercel/ncc/-/ncc-0.38.1.tgz", |       "resolved": "https://registry.npmjs.org/@vercel/ncc/-/ncc-0.36.1.tgz", | ||||||
|       "integrity": "sha512-IBBb+iI2NLu4VQn3Vwldyi2QwaXt5+hTyh58ggAMoCGE6DJmPvwL3KPBWcJl1m9LYPChBLE980Jw+CS4Wokqxw==", |       "integrity": "sha512-S4cL7Taa9yb5qbv+6wLgiKVZ03Qfkc4jGRuiUQMQ8HGBD5pcNRnHeYM33zBvJE4/zJGjJJ8GScB+WmTsn9mORw==", | ||||||
|       "dev": true |       "dev": true | ||||||
|     }, |     }, | ||||||
|     "before-after-hook": { |     "before-after-hook": { | ||||||
|  | @ -575,15 +563,9 @@ | ||||||
|       "integrity": "sha512-1h/Lnq9yajKY2PEbBadPXj3VxsDDu844OnaAo52UVmIzIvwwtBPIuNvkjuzBlTWpfJyUbG3ez0KSBibQkj4ojg==" |       "integrity": "sha512-1h/Lnq9yajKY2PEbBadPXj3VxsDDu844OnaAo52UVmIzIvwwtBPIuNvkjuzBlTWpfJyUbG3ez0KSBibQkj4ojg==" | ||||||
|     }, |     }, | ||||||
|     "typescript": { |     "typescript": { | ||||||
|       "version": "5.3.3", |       "version": "5.2.2", | ||||||
|       "resolved": "https://registry.npmjs.org/typescript/-/typescript-5.3.3.tgz", |       "resolved": "https://registry.npmjs.org/typescript/-/typescript-5.2.2.tgz", | ||||||
|       "integrity": "sha512-pXWcraxM0uxAS+tN0AG/BF2TyqmHO014Z070UsJ+pFvYuRSq8KH8DmWpnbXe0pEPDHXZV3FcAbJkijJ5oNEnWw==", |       "integrity": "sha512-mI4WrpHsbCIcwT9cF4FZvr80QUeKvsUsUvKDoR+X/7XHQH98xYD8YHZg7ANtz2GtZt/CBq2QJ0thkGJMHfqc1w==", | ||||||
|       "dev": true |  | ||||||
|     }, |  | ||||||
|     "undici-types": { |  | ||||||
|       "version": "5.25.3", |  | ||||||
|       "resolved": "https://registry.npmjs.org/undici-types/-/undici-types-5.25.3.tgz", |  | ||||||
|       "integrity": "sha512-Ga1jfYwRn7+cP9v8auvEXN1rX3sWqlayd4HP7OKk4mZWylEmu3KzXDUGrQUN6Ol7qo1gPvB2e5gX6udnyEPgdA==", |  | ||||||
|       "dev": true |       "dev": true | ||||||
|     }, |     }, | ||||||
|     "universal-user-agent": { |     "universal-user-agent": { | ||||||
|  |  | ||||||
							
								
								
									
										10
									
								
								package.json
									
										
									
									
									
								
							
							
						
						
									
										10
									
								
								package.json
									
										
									
									
									
								
							|  | @ -1,6 +1,6 @@ | ||||||
| { | { | ||||||
|   "name": "actions-comment-pull-request", |   "name": "actions-comment-pull-request", | ||||||
|   "version": "2.5.0", |   "version": "2.4.2", | ||||||
|   "description": "GitHub action for commenting pull-request", |   "description": "GitHub action for commenting pull-request", | ||||||
|   "main": "lib/main.js", |   "main": "lib/main.js", | ||||||
|   "scripts": { |   "scripts": { | ||||||
|  | @ -34,10 +34,10 @@ | ||||||
|     "@actions/tool-cache": "^2.0.1" |     "@actions/tool-cache": "^2.0.1" | ||||||
|   }, |   }, | ||||||
|   "devDependencies": { |   "devDependencies": { | ||||||
|     "@tsconfig/node20": "^20.1.2", |     "@tsconfig/node16": "^16.1.1", | ||||||
|     "@types/node": "^20.8.1", |     "@types/node": "^18.16.2", | ||||||
|     "@vercel/ncc": "^0.38.1", |     "@vercel/ncc": "^0.36.1", | ||||||
|     "prettier": "^3.0.3", |     "prettier": "^3.0.3", | ||||||
|     "typescript": "^5.3.3" |     "typescript": "^5.2.2" | ||||||
|   } |   } | ||||||
| } | } | ||||||
|  |  | ||||||
							
								
								
									
										77
									
								
								src/main.ts
									
										
									
									
									
								
							
							
						
						
									
										77
									
								
								src/main.ts
									
										
									
									
									
								
							|  | @ -55,70 +55,6 @@ async function run() { | ||||||
|       ); |       ); | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     async function createComment({ |  | ||||||
|       owner, |  | ||||||
|       repo, |  | ||||||
|       issue_number, |  | ||||||
|       body, |  | ||||||
|     }: { |  | ||||||
|       owner: string; |  | ||||||
|       repo: string; |  | ||||||
|       issue_number: number; |  | ||||||
|       body: string; |  | ||||||
|     }) { |  | ||||||
|       const { data: comment } = await octokit.rest.issues.createComment({ |  | ||||||
|         owner, |  | ||||||
|         repo, |  | ||||||
|         issue_number, |  | ||||||
|         body, |  | ||||||
|       }); |  | ||||||
| 
 |  | ||||||
|       core.setOutput('id', comment.id); |  | ||||||
|       core.setOutput('body', comment.body); |  | ||||||
|       core.setOutput('html_url', comment.html_url); |  | ||||||
| 
 |  | ||||||
|       await addReactions(comment.id, reactions); |  | ||||||
| 
 |  | ||||||
|       return comment; |  | ||||||
|     } |  | ||||||
| 
 |  | ||||||
|     async function updateComment({ |  | ||||||
|       owner, |  | ||||||
|       repo, |  | ||||||
|       comment_id, |  | ||||||
|       body, |  | ||||||
|     }: { |  | ||||||
|       owner: string; |  | ||||||
|       repo: string; |  | ||||||
|       comment_id: number; |  | ||||||
|       body: string; |  | ||||||
|     }) { |  | ||||||
|       const { data: comment } = await octokit.rest.issues.updateComment({ |  | ||||||
|         owner, |  | ||||||
|         repo, |  | ||||||
|         comment_id, |  | ||||||
|         body, |  | ||||||
|       }); |  | ||||||
| 
 |  | ||||||
|       core.setOutput('id', comment.id); |  | ||||||
|       core.setOutput('body', comment.body); |  | ||||||
|       core.setOutput('html_url', comment.html_url); |  | ||||||
| 
 |  | ||||||
|       await addReactions(comment.id, reactions); |  | ||||||
| 
 |  | ||||||
|       return comment; |  | ||||||
|     } |  | ||||||
| 
 |  | ||||||
|     async function deleteComment({ owner, repo, comment_id }: { owner: string; repo: string; comment_id: number }) { |  | ||||||
|       const { data: comment } = await octokit.rest.issues.deleteComment({ |  | ||||||
|         owner, |  | ||||||
|         repo, |  | ||||||
|         comment_id, |  | ||||||
|       }); |  | ||||||
| 
 |  | ||||||
|       return comment; |  | ||||||
|     } |  | ||||||
| 
 |  | ||||||
|     const comment_tag_pattern = comment_tag |     const comment_tag_pattern = comment_tag | ||||||
|       ? `<!-- thollander/actions-comment-pull-request "${comment_tag}" -->` |       ? `<!-- thollander/actions-comment-pull-request "${comment_tag}" -->` | ||||||
|       : null; |       : null; | ||||||
|  | @ -139,23 +75,26 @@ async function run() { | ||||||
| 
 | 
 | ||||||
|       if (comment) { |       if (comment) { | ||||||
|         if (mode === 'upsert') { |         if (mode === 'upsert') { | ||||||
|           await updateComment({ |           await octokit.rest.issues.updateComment({ | ||||||
|             ...context.repo, |             ...context.repo, | ||||||
|             comment_id: comment.id, |             comment_id: comment.id, | ||||||
|             body, |             body, | ||||||
|           }); |           }); | ||||||
|  |           await addReactions(comment.id, reactions); | ||||||
|           return; |           return; | ||||||
|         } else if (mode === 'recreate') { |         } else if (mode === 'recreate') { | ||||||
|           await deleteComment({ |           await octokit.rest.issues.deleteComment({ | ||||||
|             ...context.repo, |             ...context.repo, | ||||||
|             comment_id: comment.id, |             comment_id: comment.id, | ||||||
|           }); |           }); | ||||||
| 
 | 
 | ||||||
|           await createComment({ |           const { data: newComment } = await octokit.rest.issues.createComment({ | ||||||
|             ...context.repo, |             ...context.repo, | ||||||
|             issue_number, |             issue_number, | ||||||
|             body, |             body, | ||||||
|           }); |           }); | ||||||
|  | 
 | ||||||
|  |           await addReactions(newComment.id, reactions); | ||||||
|           return; |           return; | ||||||
|         } else if (mode === 'delete') { |         } else if (mode === 'delete') { | ||||||
|           core.debug('Registering this comment to be deleted.'); |           core.debug('Registering this comment to be deleted.'); | ||||||
|  | @ -173,11 +112,13 @@ async function run() { | ||||||
|       } |       } | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     await createComment({ |     const { data: comment } = await octokit.rest.issues.createComment({ | ||||||
|       ...context.repo, |       ...context.repo, | ||||||
|       issue_number, |       issue_number, | ||||||
|       body, |       body, | ||||||
|     }); |     }); | ||||||
|  | 
 | ||||||
|  |     await addReactions(comment.id, reactions); | ||||||
|   } catch (error) { |   } catch (error) { | ||||||
|     if (error instanceof Error) { |     if (error instanceof Error) { | ||||||
|       core.setFailed(error.message); |       core.setFailed(error.message); | ||||||
|  |  | ||||||
|  | @ -1,5 +1,5 @@ | ||||||
| { | { | ||||||
|   "extends": "@tsconfig/node20/tsconfig.json", |   "extends": "@tsconfig/node16/tsconfig.json", | ||||||
|   "compilerOptions": { |   "compilerOptions": { | ||||||
|     "outDir": "./lib", |     "outDir": "./lib", | ||||||
|     "rootDir": "./src" |     "rootDir": "./src" | ||||||
|  |  | ||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue