-
-
Notifications
You must be signed in to change notification settings - Fork 212
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
16 additions
and
16 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -80,6 +80,7 @@ jobs: | |
run: sudo apt install universal-ctags | ||
|
||
- name: Checkout PR branch if comment is on a PR | ||
id: checkout_branch | ||
env: | ||
GITHUB_TOKEN: ${{ github.token }} | ||
run: | | ||
|
@@ -95,11 +96,15 @@ jobs: | |
DATA=$(gh api /repos/${{ github.repository }}/pulls/${{ github.event.issue.number }}) | ||
# Get the PR's branch name | ||
PR_BRANCH=$(echo "$DATA" | jq -r .head.ref) | ||
git fetch origin $PR_BRANCH | ||
git checkout $PR_BRANCH | ||
BRANCH_NAME=$(echo "$DATA" | jq -r .head.ref) | ||
git fetch origin $BRANCH_NAME | ||
git checkout $BRANCH_NAME | ||
else | ||
# Create a new branch and push changes | ||
BRANCH_NAME="gptme-bot-changes-$(date +'%Y%m%d%H%M%S')" | ||
git checkout -b $BRANCH_NAME | ||
fi | ||
echo "branch_name=$BRANCH_NAME" >> $GITHUB_OUTPUT | ||
- name: Install poetry | ||
run: pipx install poetry | ||
|
@@ -156,10 +161,9 @@ jobs: | |
ISSUE_TYPE: ${{ github.event.issue.pull_request && 'pull_request' || 'issue' }} | ||
REPO_NAME: ${{ github.event.repository.name }} | ||
USER_NAME: ${{ github.event.repository.owner.login }} | ||
BRANCH_NAME: ${{ steps.checkout_branch.outputs.branch_name }} | ||
BRANCH_BASE: "master" | ||
run: | | ||
BRANCH_NAME="gptme-bot-changes-$(date +'%Y%m%d%H%M%S')" | ||
BRANCH_BASE="master" | ||
RUN_URL="https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}" | ||
COMMENT_URL="https://github.com/${{ github.repository }}/issues/${{ github.event.issue.number }}#issuecomment-${{ github.event.comment.id }}" | ||
|
@@ -176,19 +180,15 @@ jobs: | |
git config user.name "gptme-bot" | ||
git config user.email "[email protected]" | ||
if [[ $ISSUE_TYPE == "pull_request" ]]; then | ||
# Push changes to the PR branch | ||
git commit -m "$COMMIT_MSG" | ||
git push | ||
git commit -m "$COMMIT_MSG" | ||
# Push changes to the PR branch | ||
git push -u origin $BRANCH_NAME | ||
if [[ $ISSUE_TYPE == "pull_request" ]]; then | ||
# Comment on the PR | ||
echo "Changes have been pushed to this pull request." | gh pr comment $ISSUE_NUMBER -R $USER_NAME/$REPO_NAME --body-file=- | ||
else | ||
# Create a new branch and push changes | ||
git checkout -b $BRANCH_NAME | ||
git commit -m "$COMMIT_MSG" | ||
git push -u origin $BRANCH_NAME | ||
# Some say this helps! https://github.com/cli/cli/issues/2691#issuecomment-1289521962 | ||
sleep 1 | ||
|