diff --git a/.github/workflows/benchmark.main.kts b/.github/workflows/benchmark.main.kts index 81a4a058e..eebaf44ed 100755 --- a/.github/workflows/benchmark.main.kts +++ b/.github/workflows/benchmark.main.kts @@ -36,6 +36,7 @@ val BENCHMARK_RESULTS = "snake-kmp-benchmarks/build/reports/benchmarks" val RESULTS_DIR = "bench-results" val AGGREGATED_REPORT = "aggregated.json" val PUBLISH_BENCHMARK_RESULTS by Contexts.secrets +val FULL_REPOSITORY_NAME = "krzema12/snakeyaml-engine-kmp" workflow( name = "Run Benchmarks", @@ -144,15 +145,17 @@ workflow( action = GithubActionBenchmark( name = "SnakeKMP benchmarks", tool = GithubActionBenchmark.Tool.Jmh, - commentOnAlert = true, + // Comment on PR only the PR is made from the same repo + commentOnAlert_Untyped = expr { "${github.eventPullRequest.pull_request.head.repo.full_name} == '$FULL_REPOSITORY_NAME'" }, summaryAlways = true, alertThreshold = "150%", failThreshold = "200%", ghRepository = "github.com/krzema12/snakeyaml-engine-kmp-benchmarks", outputFilePath = AGGREGATED_REPORT, - githubToken = expr { PUBLISH_BENCHMARK_RESULTS }, + // Use GitHub token in case the secret is not available + githubToken = expr { "$PUBLISH_BENCHMARK_RESULTS || ${github.token}" }, // Push and deploy GitHub pages branch automatically only if run in main repo and not in PR - autoPush_Untyped = expr { "${github.repository} == 'krzema12/snakeyaml-engine-kmp' && ${github.event_name} != 'pull_request'" }, + autoPush_Untyped = expr { "${github.repository} == '$FULL_REPOSITORY_NAME' && ${github.event_name} != 'pull_request'" }, ), ) } diff --git a/.github/workflows/benchmark.yaml b/.github/workflows/benchmark.yaml index 874e8c2cd..6ca3cd8ca 100644 --- a/.github/workflows/benchmark.yaml +++ b/.github/workflows/benchmark.yaml @@ -95,9 +95,9 @@ jobs: tool: 'jmh' output-file-path: 'aggregated.json' gh-repository: 'github.com/krzema12/snakeyaml-engine-kmp-benchmarks' - github-token: '${{ secrets.PUBLISH_BENCHMARK_RESULTS }}' + github-token: '${{ secrets.PUBLISH_BENCHMARK_RESULTS || github.token }}' auto-push: '${{ github.repository == ''krzema12/snakeyaml-engine-kmp'' && github.event_name != ''pull_request'' }}' summary-always: 'true' - comment-on-alert: 'true' + comment-on-alert: '${{ github.event.pull_request.head.repo.full_name == ''krzema12/snakeyaml-engine-kmp'' }}' alert-threshold: '150%' fail-threshold: '200%'