[CI] Skip the workflow run for a pull request, if the same SHA was already built

This commit is contained in:
Mat Sutcliffe
2020-07-07 19:42:42 +01:00
parent 93998720b2
commit c4f6e516ef
2 changed files with 11 additions and 9 deletions

View File

@@ -18,6 +18,7 @@ jobs:
preBuild:
runs-on: ubuntu-20.04
if: ${{ github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name != github.repository }}
outputs:
version: ${{ steps.version.outputs.value }}
@@ -446,14 +447,16 @@ jobs:
steps:
- name: Prepare Discord message
run: |
result=SUCCESS
expr ${{ join(needs.*.outputs.warnings, ' + ') }} && result=WARNING
echo ${{ join(needs.*.result, ' ') }} | grep -q fail && result=FAILED
echo ${{ join(needs.*.result, ' ') }} | grep -q cancel && result=CANCELLED
result=SKIPPED
${{ contains(needs.*.result, 'success') }} && result=SUCCESS
${{ contains(needs.*.outputs.warnings, 'true') }} && result=WARNING
${{ contains(needs.*.result, 'cancelled') }} && result=CANCELLED
${{ contains(needs.*.result, 'failure') }} && result=FAILED
[[ $result = SKIPPED ]] && emoji=repeat
[[ $result = SUCCESS ]] && emoji=white_check_mark
[[ $result = WARNING ]] && emoji=warning
[[ $result = FAILED ]] && emoji=x
[[ $result = CANCELLED ]] && emoji=grey_question
[[ $result = FAILED ]] && emoji=x
echo "::set-env name=result::$result"
echo "::set-env name=emoji::$emoji"
- name: Send Discord message

View File

@@ -31,10 +31,9 @@ while (<<>>)
++$cmds{"::warning file=$result{file}::$result{msg}"};
}
}
my @cmds = sort keys %cmds;
my $count = scalar @cmds;
print "$_\n" for @cmds;
print "::set-output name=warnings::$count\n";
my $bool = %cmds ? 'true' : 'false';
print "$_\n" for sort keys %cmds;
print "::set-output name=warnings::$bool\n";
sub extractWarning
{