diff --git a/README.md b/README.md index 4a0d580..da03ff0 100644 --- a/README.md +++ b/README.md @@ -6,4 +6,28 @@ Program to simplify PCI double approval process across repositories 0. Install nix 1. Run `nix-shell` -2. Run `cargo run` +2. Run `cargo build` +3. Run `cargo test` +4. Run `cargo deny check` + +## GitHub Action usage + +pear-reviewer can be used as a GitHub Actions workflow to comment the review template on PRs. + +```yaml +name: pear-reviewer +on: + pull_request: + branches: + - '*' + +permissions: + pull-requests: write + +jobs: + review: + name: Review + runs-on: ubuntu-latest + steps: + - uses: sapcc/pear-reviewer@main +``` diff --git a/action.yaml b/action.yaml new file mode 100644 index 0000000..583dc2d --- /dev/null +++ b/action.yaml @@ -0,0 +1,42 @@ +name: 'pear-reviewer' +description: 'Run pear-reviewer' +runs: + using: "composite" + steps: + - name: Check out code + uses: actions/checkout@v4 + + - name: Run pear-reviewer + id: run-pear-reviewer + uses: docker://ghcr.io/sapcc/pear-reviewer:latest + run: + pear-reviewer > $GITHUB_OUTPUT + + - name: Find Comment + uses: peter-evans/find-comment@v3 + id: find-comment + with: + issue-number: ${{ github.event.pull_request.number }} + comment-author: 'github-actions[bot]' + body-includes: + + - name: Create comment + if: steps.find-comment.outputs.comment-id == '' + uses: peter-evans/create-or-update-comment@v4 + with: + issue-number: ${{ github.event.pull_request.number }} + body: | + + + ${{ steps.run-pear-rewiwer.outputs.comment }} + + - name: Update comment + if: steps.find-comment.outputs.comment-id != '' + uses: peter-evans/create-or-update-comment@v4 + with: + comment-id: ${{ steps.find-comment.outputs.comment-id }} + body: | + + + ${{ steps.run-pear-rewiwer.outputs.result }} + edit-mode: replace