|
| 1 | +name: Automated PR |
| 2 | + |
| 3 | +on: |
| 4 | + workflow_dispatch: |
| 5 | + inputs: |
| 6 | + issue_key: |
| 7 | + description: 'Issue key' |
| 8 | + required: true |
| 9 | + issue_summary: |
| 10 | + description: 'Brief summary of the issue' |
| 11 | + required: true |
| 12 | + issue_description: |
| 13 | + description: 'Detailed issue description' |
| 14 | + required: true |
| 15 | + |
| 16 | +permissions: |
| 17 | + contents: write |
| 18 | + pull-requests: write |
| 19 | + |
| 20 | +jobs: |
| 21 | + automate: |
| 22 | + runs-on: ubuntu-latest |
| 23 | + |
| 24 | + steps: |
| 25 | + |
| 26 | + # Set up developer tools |
| 27 | + |
| 28 | + - name: Checkout code |
| 29 | + uses: actions/checkout@v4 |
| 30 | + with: |
| 31 | + fetch-depth: 0 |
| 32 | + submodules: recursive |
| 33 | + |
| 34 | + - name: Set up JDK |
| 35 | + uses: actions/setup-java@v4 |
| 36 | + with: |
| 37 | + distribution: 'temurin' |
| 38 | + java-version: '21' |
| 39 | + |
| 40 | + - name: Set up Gradle |
| 41 | + uses: gradle/actions/setup-gradle@v3 |
| 42 | + |
| 43 | + - name: Set up Node.js |
| 44 | + uses: actions/setup-node@v4 |
| 45 | + with: |
| 46 | + node-version: '20' |
| 47 | + |
| 48 | + # Symlink agents file to the root |
| 49 | + |
| 50 | + - name: Symlink agents |
| 51 | + run: ln -s .github/copilot-instructions.md AGENTS.md |
| 52 | + |
| 53 | + # Generate JS docs |
| 54 | + - name: Set up Node |
| 55 | + uses: actions/setup-node@v4 |
| 56 | + with: |
| 57 | + node-version: 22 |
| 58 | + |
| 59 | + - name: Install JS deps |
| 60 | + working-directory: js |
| 61 | + run: npm ci |
| 62 | + |
| 63 | + - name: Build JS docs |
| 64 | + working-directory: js |
| 65 | + run: npm run doc |
| 66 | + |
| 67 | + # Set up environment variables |
| 68 | + |
| 69 | + - name: Prepare variables |
| 70 | + run: | |
| 71 | + echo "ISSUE_KEY=${{ github.event.inputs.issue_key }}" >> $GITHUB_ENV |
| 72 | + echo "TITLE=${{ github.event.inputs.issue_summary }}" >> $GITHUB_ENV |
| 73 | + DESC_CLEANED=$(echo "${{ github.event.inputs.issue_description }}" | tr '\n' ' ' | sed 's/"/'\''/g') |
| 74 | + echo "DESC=$DESC_CLEANED" >> $GITHUB_ENV |
| 75 | + echo "BRANCH=${{ github.event.inputs.issue_key }}" >> $GITHUB_ENV |
| 76 | +
|
| 77 | + # Set up LLM Agent |
| 78 | + |
| 79 | + - name: Install Codex (npm) |
| 80 | + run: npm i -g @openai/codex |
| 81 | + |
| 82 | + # Run the LLM Agent and commit the output |
| 83 | + |
| 84 | + - name: 'Run Gemini CLI' |
| 85 | + id: 'run_gemini' |
| 86 | + uses: 'google-github-actions/run-gemini-cli@v0' # ratchet:exclude |
| 87 | + env: |
| 88 | + GITHUB_TOKEN: '${{ steps.mint_identity_token.outputs.token || secrets.GITHUB_TOKEN || github.token }}' |
| 89 | + IS_PULL_REQUEST: '${{ !!github.event.pull_request }}' |
| 90 | + REPOSITORY: '${{ github.repository }}' |
| 91 | + ADDITIONAL_CONTEXT: '${{ inputs.additional_context }}' |
| 92 | + AGENT_DIRECTIVES: '${{ steps.agent_directives.outputs.directives }}' |
| 93 | + with: |
| 94 | + gemini_api_key: '${{ secrets.GEMINI_API_KEY }}' |
| 95 | + gcp_workload_identity_provider: '${{ vars.GCP_WIF_PROVIDER }}' |
| 96 | + gcp_project_id: '${{ vars.GOOGLE_CLOUD_PROJECT }}' |
| 97 | + gcp_location: '${{ vars.GOOGLE_CLOUD_LOCATION }}' |
| 98 | + gcp_service_account: '${{ vars.SERVICE_ACCOUNT_EMAIL }}' |
| 99 | + use_vertex_ai: '${{ vars.GOOGLE_GENAI_USE_VERTEXAI }}' |
| 100 | + google_api_key: '${{ secrets.GOOGLE_API_KEY }}' |
| 101 | + use_gemini_code_assist: '${{ vars.GOOGLE_GENAI_USE_GCA }}' |
| 102 | + gemini_debug: '${{ fromJSON(vars.DEBUG || vars.ACTIONS_STEP_DEBUG || false) }}' |
| 103 | + gemini_model: '${{ vars.GEMINI_MODEL }}' |
| 104 | + settings: |- |
| 105 | + { |
| 106 | + "maxSessionTurns": 25, |
| 107 | + "telemetry": { |
| 108 | + "enabled": ${{ vars.GOOGLE_CLOUD_PROJECT != '' }}, |
| 109 | + "target": "gcp" |
| 110 | + }, |
| 111 | + "mcpServers": { |
| 112 | + "github": { |
| 113 | + "command": "docker", |
| 114 | + "args": [ |
| 115 | + "run", |
| 116 | + "-i", |
| 117 | + "--rm", |
| 118 | + "-e", |
| 119 | + "GITHUB_PERSONAL_ACCESS_TOKEN", |
| 120 | + "ghcr.io/github/github-mcp-server" |
| 121 | + ], |
| 122 | + "includeTools": [ |
| 123 | + "add_issue_comment", |
| 124 | + "get_issue", |
| 125 | + "get_issue_comments", |
| 126 | + "list_issues", |
| 127 | + "search_issues", |
| 128 | + "create_pull_request", |
| 129 | + "get_pull_request", |
| 130 | + "get_pull_request_comments", |
| 131 | + "get_pull_request_diff", |
| 132 | + "get_pull_request_files", |
| 133 | + "list_pull_requests", |
| 134 | + "search_pull_requests", |
| 135 | + "create_branch", |
| 136 | + "create_or_update_file", |
| 137 | + "delete_file", |
| 138 | + "fork_repository", |
| 139 | + "get_commit", |
| 140 | + "get_file_contents", |
| 141 | + "list_commits", |
| 142 | + "push_files", |
| 143 | + "search_code" |
| 144 | + ], |
| 145 | + "env": { |
| 146 | + "GITHUB_PERSONAL_ACCESS_TOKEN": "${GITHUB_TOKEN}" |
| 147 | + } |
| 148 | + } |
| 149 | + }, |
| 150 | + "coreTools": [ |
| 151 | + "run_shell_command(cat)", |
| 152 | + "run_shell_command(echo)", |
| 153 | + "run_shell_command(grep)", |
| 154 | + "run_shell_command(head)", |
| 155 | + "run_shell_command(tail)" |
| 156 | + ] } |
| 157 | + prompt: |- |
| 158 | + ${{ env.AGENT_DIRECTIVES }} |
| 159 | + Implement ticket ${{ env.ISSUE_KEY }}: ${{ env.TITLE }}. ${{ env.DESC }} |
| 160 | + - name: Agent commit |
| 161 | + run: | |
| 162 | + git add -A |
| 163 | + git commit -m "$ISSUE_KEY: $TITLE" |
| 164 | +
|
| 165 | + # Prepare and push Pull Request |
| 166 | + |
| 167 | + - id: cpr |
| 168 | + name: Create Pull Request |
| 169 | + uses: peter-evans/create-pull-request@v6 |
| 170 | + with: |
| 171 | + token: ${{ secrets.GITHUB_TOKEN }} |
| 172 | + base: main |
| 173 | + branch: ${{ env.BRANCH }} |
| 174 | + title: "${{ env.ISSUE_KEY }}: ${{ env.TITLE }}" |
| 175 | + body: | |
| 176 | + **${{ env.ISSUE_KEY }}** |
| 177 | +
|
| 178 | + ## Objective |
| 179 | + **${{ env.TITLE }}**. |
| 180 | +
|
| 181 | + ## Description |
| 182 | + ${{ env.DESC }} |
| 183 | +
|
| 184 | + ## Acceptance |
| 185 | + Compiles and checks pass. |
| 186 | +
|
0 commit comments