Skip to content

Commit

Permalink
fix: add GitHub CLI installation and improve branch handling
Browse files Browse the repository at this point in the history
  • Loading branch information
ashkan-deriv committed Dec 23, 2024
1 parent 257e1ee commit ba6f6e2
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion .github/workflows/pr-review.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,15 @@ jobs:
steps:
- uses: actions/checkout@v3

- name: Install GitHub CLI
run: |
type -p curl >/dev/null || (sudo apt update && sudo apt install curl -y)
curl -fsSL https://cli.github.com/packages/githubcli-archive-keyring.gpg | sudo dd of=/usr/share/keyrings/githubcli-archive-keyring.gpg \
&& sudo chmod go+r /usr/share/keyrings/githubcli-archive-keyring.gpg \
&& echo "deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/githubcli-archive-keyring.gpg] https://cli.github.com/packages stable main" | sudo tee /etc/apt/sources.list.d/github-cli.list > /dev/null \
&& sudo apt update \
&& sudo apt install gh -y
- name: Handle PR and Review
env:
GH_TOKEN: ${{ secrets.REVIEW_TOKEN }}
Expand All @@ -23,9 +32,12 @@ jobs:
echo "Requesting review for PR #${{ github.event.pull_request.number }}"
gh pr edit ${{ github.event.pull_request.number }} --add-reviewer $REVIEWER
else
current_branch=$(git rev-parse --abbrev-ref HEAD)
current_branch="${{ github.ref_name }}"
default_branch=$(gh repo view --json defaultBranchRef --jq .defaultBranchRef.name)
echo "Current branch: $current_branch"
echo "Default branch: $default_branch"
# Check for existing PR
existing_pr=$(gh pr list --head "$current_branch" --state open --json number --jq '.[0].number')
Expand Down

0 comments on commit ba6f6e2

Please sign in to comment.