Skip to content

Commit

Permalink
ci: simplified bot workflow
Browse files Browse the repository at this point in the history
  • Loading branch information
ErikBjare committed Nov 2, 2023
1 parent c8cc507 commit 4980bce
Showing 1 changed file with 16 additions and 16 deletions.
32 changes: 16 additions & 16 deletions .github/workflows/bot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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: |
Expand All @@ -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
Expand Down Expand Up @@ -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 }}"
Expand All @@ -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
Expand Down

0 comments on commit 4980bce

Please sign in to comment.