Skip to content

Commit 4297204

Browse files
committed
CI: Post output from semver-checks as a comment
1 parent 1e4c551 commit 4297204

File tree

1 file changed

+26
-2
lines changed

1 file changed

+26
-2
lines changed

.github/workflows/semver_checks.yml

Lines changed: 26 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ jobs:
3434
timeout-minutes: 30
3535
outputs:
3636
exitcode: ${{ steps.semver-pr-check.outputs.exitcode }}
37+
output: ${{ steps.semver-pr-check.outputs.output }}
3738
steps:
3839
- name: Checkout
3940
uses: actions/checkout@v3
@@ -56,8 +57,11 @@ jobs:
5657
id: semver-pr-check
5758
run: |
5859
set +e
59-
make semver-rev rev="$PR_BASE"
60-
exitcode=$?
60+
echo "output<<SEMVER_STDOUT_EOF" >> $GITHUB_OUTPUT
61+
# Weird sed strip ANSI colors from output
62+
make semver-rev rev="$PR_BASE" |& tee /dev/tty | sed -r "s/\x1B\[([0-9]{1,2}(;[0-9]{1,2})?)?[mGK]//g" >> $GITHUB_OUTPUT
63+
exitcode=${PIPESTATUS[0]}
64+
echo "SEMVER_STDOUT_EOF" >> $GITHUB_OUTPUT
6165
echo "exitcode=$exitcode" >> $GITHUB_OUTPUT
6266
exit "$exitcode"
6367
continue-on-error: true
@@ -82,6 +86,26 @@ jobs:
8286
env:
8387
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
8488
GH_REPO: ${{ github.repository }}
89+
- name: Post report on semver break
90+
run: |
91+
gh pr comment "$PR_ID" --body "\
92+
\`cargo semver-checks\` detected some API incompatibilities in this PR.
93+
See the following report for details:
94+
<details>
95+
<summary>cargo semver-checks output</summary>
96+
97+
\`\`\`
98+
$SEMVER_OUTPUT
99+
\`\`\`
100+
101+
</details>
102+
"
103+
if: needs.semver-pull-request-check.outputs.exitcode != '0'
104+
env:
105+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
106+
GH_REPO: ${{ github.repository }}
107+
SEMVER_OUTPUT: ${{ needs.semver-pull-request-check.outputs.output }}
108+
85109

86110
semver-push-tag:
87111
runs-on: ubuntu-latest

0 commit comments

Comments
 (0)