Skip to content

Fix background color and add APK build action #4

Fix background color and add APK build action

Fix background color and add APK build action #4

name: Jules PR Lifecycle Manager
on:
push:
branches-ignore:
- main
- master
issue_comment:
types: [created]
pull_request_review_comment:
types: [created]
permissions:
contents: write
pull-requests: write
issues: write
jobs:
manage-pr:
runs-on: ubuntu-latest
if: github.actor != 'github-actions[bot]' && !contains(github.event.head_commit.message, '[skip-jules]')
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Invoke Jules
uses: google-labs-code/jules-invoke@v1
with:
jules_api_key: ${{ secrets.JULES_API_KEY }}
prompt: |
You are Jules, an autonomous software engineer.
**Mission**: Manage the lifecycle of the Pull Request for the active branch/context.
**Context**:
- Event: ${{ github.event_name }}
- Repository: ${{ github.repository }}
- Actor: ${{ github.actor }}
**Authentication**:
- GITHUB_TOKEN: ${{ secrets.GH_TOKEN }}
**Directives**:
1. **Setup**:
- Install `gh` CLI in your environment using:
```bash
(type -p gh >/dev/null || (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))
```
- Authenticate: `echo "$GITHUB_TOKEN" | gh auth login --with-token`
2. **Identify Branch**:
- If `Event` is `push`, the branch is `${{ github.ref_name }}`.
- If `Event` is `issue_comment` or `pull_request_review_comment`:
- Get the PR number from `${{ github.event.issue.number }}` or `${{ github.event.pull_request.number }}`.
- Run `gh pr view <number> --json headRefName -q .headRefName` to get the branch.
- Checkout that branch: `git fetch origin <branch> && git checkout <branch>`.
3. **Execute Logic**:
- **PR Creation**:
- If no PR exists for this branch: `gh pr create --title "Jules: PR for ${{ github.ref_name }}" --body "Automated PR created by Jules." --base ${{ github.event.repository.default_branch }}`.
- **Evaluation & Review**:
- Analyze the code. Is it valid? Necessary?
- If invalid/spam: Close PR `gh pr close <number>` and delete branch. Stop.
- If issues found (bugs, style): Fix them in the code.
- **Conflict Resolution**:
- Check conflicts: `gh pr view <number> --json mergeable`.
- If `MERGEABLE` is `CONFLICTING`:
- `git merge origin/${{ github.event.repository.default_branch }}`.
- Resolve conflicts.
- **Feedback Loop**:
- Check comments: `gh pr view <number> --comments`.
- If reviewers requested changes, implement them.
4. **Conclusion**:
- If you made code changes (fixes/conflicts):
- Use `submit` tool to push changes. **STOP HERE** (The push will trigger a new workflow run).
- If NO code changes were needed AND the PR is clean/valid AND no unresolved feedback:
- Merge the PR: `gh pr merge <number> --merge --delete-branch`.
**Important**:
- Use `submit` only when pushing code.
- Use `gh` for PR management.
- Do not loop. If you fail to resolve something, leave a comment on the PR explaining why.