File tree Expand file tree Collapse file tree 2 files changed +13
-4
lines changed
Expand file tree Collapse file tree 2 files changed +13
-4
lines changed Original file line number Diff line number Diff line change 44
55$ diff = file_get_contents ('/workdir/ ' . $ argv [1 ] . '.md ' );
66$ prNumber = json_decode (file_get_contents (getenv ('GITHUB_EVENT_PATH ' )), true )['pull_request ' ]['number ' ];
7- $ locator = '<!-- @)}---^----- wyrihaximus/github-action-composer.lock-diff ' . getenv ('GITHUB_WORKFLOW ' ) . ' __/<+>\__ ' . $ argv [1 ] . ' -----^---{(@ --> ' ;
7+ $ workingDirectory = getenv ('INPUT_WORKINGDIRECTORY ' ) ?: '/ ' ;
8+ $ locator = '<!-- @)}---^----- wyrihaximus/github-action-composer.lock-diff ' . getenv ('GITHUB_WORKFLOW ' ) . ' __/<+>\__ ' . $ argv [1 ] . ' __/<*>\__ ' . $ workingDirectory . ' -----^---{(@ --> ' ;
9+ $ legacyLocator = '<!-- @)}---^----- wyrihaximus/github-action-composer.lock-diff ' . getenv ('GITHUB_WORKFLOW ' ) . ' __/<+>\__ ' . $ argv [1 ] . ' -----^---{(@ --> ' ;
810$ commentContents = $ locator . PHP_EOL . $ argv [2 ] . PHP_EOL . $ diff . PHP_EOL ;
911
1012$ client = new GuzzleHttp \Client ();
1719$ comments = json_decode ($ res ->getBody ()->getContents (), true );
1820
1921foreach ($ comments as $ comment ) {
20- if (strpos ($ comment ['body ' ], $ locator ) === 0 ) {
22+ $ isCurrentLocator = strpos ($ comment ['body ' ], $ locator ) === 0 ;
23+ $ isLegacyLocator = !$ isCurrentLocator && !getenv ('INPUT_WORKINGDIRECTORY ' ) && strpos ($ comment ['body ' ], $ legacyLocator ) === 0 ;
24+ if ($ isCurrentLocator || $ isLegacyLocator ) {
2125 if (strlen ($ diff ) === 0 ) {
2226 echo 'Deleting ' , $ argv [1 ], ' comment ' , PHP_EOL ;
2327 $ client ->request ('DELETE ' , 'https://api.github.com/repos/ ' . getenv ('GITHUB_REPOSITORY ' ) . '/issues/comments/ ' . $ comment ['id ' ], [
Original file line number Diff line number Diff line change @@ -45,8 +45,13 @@ echo "${delimiter}" >> "${GITHUB_OUTPUT}"
4545if [ " $INPUT_DRYRUN " != " yes" ]
4646then
4747 echo " Not in a dry run so upserting comments when desirable"
48- php /workdir/comment.php production " 🏰 Composer Production Dependency changes 🏰"
49- php /workdir/comment.php development " 🚧 Composer Development Dependency changes 🚧"
48+ if [ -n " ${workingDirectory} " ]; then
49+ directoryLabel=" (${workingDirectory%/ } )"
50+ else
51+ directoryLabel=" "
52+ fi
53+ php /workdir/comment.php production " 🏰 Composer Production Dependency changes${directoryLabel} 🏰"
54+ php /workdir/comment.php development " 🚧 Composer Development Dependency changes${directoryLabel} 🚧"
5055else
5156 echo " In a dry run so not upserting comments when desirable"
5257fi
You can’t perform that action at this time.
0 commit comments