Skip to content

Commit

Permalink
Update review-pr.yml
Browse files Browse the repository at this point in the history
  • Loading branch information
SmartManoj committed Jul 19, 2024
1 parent 810b77b commit f6f2128
Showing 1 changed file with 16 additions and 47 deletions.
63 changes: 16 additions & 47 deletions .github/workflows/review-pr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,7 @@ on:
permissions:
contents: write
pull-requests: write
env:
PRR_FILE_NAME: ${{ github.repository }}/${{ github.event.pull_request.number }}

jobs:
dogfood:
if: contains(github.event.pull_request.labels.*.name, 'review-this')
Expand All @@ -23,18 +22,6 @@ jobs:
run: |
sudo apt-get install -y git gh
git config --global --add safe.directory $PWD
- name: Install prr
uses: baptiste0928/cargo-install@v3
with:
crate: prr
- name: Configure prr
run: |
mkdir -p ~/.config/prr
cat << EOF > ~/.config/prr/config.toml
[prr]
token = "${{ github.token }}"
workdir = "$GITHUB_WORKSPACE"
EOF
- name: Checkout Repository
uses: actions/checkout@v4
Expand All @@ -43,39 +30,12 @@ jobs:

- name: Download Diff
run: |
prr get $PRR_FILE_NAME
curl -O "${{ github.event.pull_request.diff_url }}" -L
- name: Write Task File
run: |
echo "Your coworker wants to apply a pull request to this project." > task.txt
echo "Read and review $PRR_FILE_NAME.prr file. Edit this file to add comments and suggestions." >> task.txt
cat << EOF
Sample content of a .prr file:
> diff --git a/ch4.txt b/ch4.txt
> index 41e1932..8741175 100644
> --- a/ch4.txt
> +++ b/ch4.txt
> @@ -16,6 +16,10 @@ CHAPTER 4. TACTICAL DISPOSITIONS
> +HERE IS SOME CONTENT I'M TRYING TO ADD
> +LALALALLALALALALAL
> +
> +Some important line
---
> diff --git a/ch4.txt b/ch4.txt
> index 41e1932..8741175 100644
> --- a/ch4.txt
> +++ b/ch4.txt
> @@ -16,6 +16,10 @@ CHAPTER 4. TACTICAL DISPOSITIONS
> +HERE IS SOME CONTENT I'M TRYING TO ADD
> +LALALALLALALALALAL
> +
Remove this spam
> +Some important line
EOF >> task.txt
echo "Read and review ${{ github.event.pull_request.number }}.diff file. Create a review-${{ github.event.pull_request.number }}.txt and write your concise comments and suggestions there." >> task.txt
echo "Do not ask me for confirmation at any point." >> task.txt
echo "" >> task.txt
echo "Title" >> task.txt
Expand All @@ -84,8 +44,7 @@ jobs:
echo "Description" >> task.txt
echo "${{ github.event.pull_request.body }}" >> task.txt
echo "" >> task.txt
echo "Diff file is: $PRR_FILE_NAME.prr" >> task.txt
echo "" >> task.txt
echo "Diff file is: ${{ github.event.pull_request.number }}.diff" >> task.txt
- name: Set up environment
run: |
Expand All @@ -109,8 +68,18 @@ jobs:
echo -e "/exit\n" | poetry run python opendevin/core/main.py -i 50 -f task.txt
rm task.txt
- name: Create PR review
- name: Check if review file is non-empty
id: check_file
run: |
ls -la
if [[ -s review-${{ github.event.pull_request.number }}.txt ]]; then
echo "non_empty=true" >> $GITHUB_OUTPUT
fi
shell: bash

- name: Create PR review if file is non-empty
env:
GH_TOKEN: ${{ github.token }}
if: steps.check_file.outputs.non_empty == 'true'
run: |
prr submit $PRR_FILE_NAME
gh pr review ${{ github.event.pull_request.number }} --comment --body-file "review-${{ github.event.pull_request.number }}.txt"

0 comments on commit f6f2128

Please sign in to comment.