Use gh tool with token #2
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
name: Run Aider | ||
on: | ||
workflow_call: | ||
secrets: | ||
OPENAI_API_KEY: | ||
description: 'OpenAI API key' | ||
required: true | ||
DOCKER_HUB_USERNAME: | ||
description: 'Username for Docker Hub' | ||
required: true | ||
DOCKER_HUB_PASSWORD: | ||
description: 'Password for Docker Hub' | ||
required: true | ||
GITHUB_TOKEN: | ||
description: 'GitHub token' | ||
required: true | ||
# Secrets are inherited and include OPENAI_API_KEY, DOCKER_HUB_USERNAME, and DOCKER_HUB_PASSWORD | ||
jobs: | ||
run-aider: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout repository | ||
uses: actions/checkout@v2 | ||
- name: Login to Docker Hub | ||
uses: docker/login-action@v3 | ||
with: | ||
username: ${{ secrets.DOCKER_HUB_USERNAME }} | ||
password: ${{ secrets.DOCKER_HUB_PASSWORD }} | ||
- name: Run Aider from Docker container | ||
env: | ||
OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }} | ||
run: | | ||
docker run --rm -v ${{ github.workspace }}:/repo -e OPENAI_API_KEY bwehrle/aider-agent:0.1 healthcheck | ||
# docker run --rm -v ${{ github.workspace }}:/repo -e OPENAI_API_KEY --entrypoint /bin/sh bwehrle/aider-agent:0.1 -c 'git log ' | ||
- name: Check if branch is dirty | ||
id: check_dirty | ||
run: | | ||
echo $(git status -sb) | ||
if [ -n "$(git status -sb)" ]; then | ||
echo Found commits ahead of remote branch | ||
echo "dirty=true" >> "$GITHUB_OUTPUT" | ||
else | ||
echo No commits ahead of remote branch | ||
echo "dirty=false" >> "$GITHUB_OUTPUT" | ||
fi | ||
- name: Commit changes | ||
if: steps.check_dirty.outputs.dirty == 'true' | ||
run: | | ||
git checkout -b $BRANCH | ||
gh pr create -B main -H $BRANCH --title 'AI Agent PR ' --body 'Created by AI Agent' | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
BRANCH: ai-agent-${{ github.run_id }} |