72 lines
2.2 KiB
Markdown
72 lines
2.2 KiB
Markdown
<!--
|
|
git.auengun.net/homelab/action-pr-comment
|
|
Copyright (C) 2024 GregoryDosh
|
|
|
|
This program is free software: you can redistribute it and/or modify
|
|
it under the terms of the GNU Affero General Public License as
|
|
published by the Free Software Foundation, either version 3 of the
|
|
License, or (at your option) any later version.
|
|
|
|
This program is distributed in the hope that it will be useful,
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
GNU Affero General Public License for more details.
|
|
|
|
You should have received a copy of the GNU Affero General Public License
|
|
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|
|
|
SPDX-License-Identifier: AGPL-3.0-or-later
|
|
SPDX-FileCopyrightText: 2023 GregoryDosh
|
|
-->
|
|
|
|
# action-pr-comment
|
|
|
|
An action to add or update an existing comment anchored in a PR for test results, status messages, etc.
|
|
|
|
## Example
|
|
|
|
```yaml
|
|
name: Some Workflow
|
|
|
|
on:
|
|
push:
|
|
branches:
|
|
- main
|
|
pull_request:
|
|
|
|
jobs:
|
|
some-workflow:
|
|
name: Send PR Comment
|
|
runs-on: ubuntu-act-latest
|
|
steps:
|
|
- name: Clone Repo into Workspace
|
|
uses: https://git.auengun.net/homelab/action-common-setup
|
|
|
|
- name: "`make test`"
|
|
if: ${{ github.event_name == 'pull_request' && !cancelled() }}
|
|
shell: bash
|
|
run: |
|
|
set +e
|
|
make test 2>&1 | tee make_test.log
|
|
RESULT="$?"
|
|
set -e
|
|
{
|
|
echo "# Automated Forgejo Actions Report"
|
|
echo ""
|
|
echo "\`\`\`shell"
|
|
cat make_test.log
|
|
echo "\`\`\`"
|
|
} 2>&1 >> "${{github.workspace}}/.pr-comment.md"
|
|
echo "Saved to '${{github.workspace}}/.pr-comment.md'"
|
|
exit $RESULT
|
|
|
|
# Posts a comment back to the PR that spawned this CI
|
|
# and keeps it in sync whenever there is a change.
|
|
- name: Post/Update PR Comment
|
|
if: ${{ github.event_name == 'pull_request' && !cancelled() }}
|
|
continue-on-error: true
|
|
uses: https://git.auengun.net/homelab/action-pr-comment
|
|
with:
|
|
github-token: ${{ secrets.GITHUB_TOKEN }}
|
|
path: "${{github.workspace}}/.pr-comment.md"
|
|
```
|