@@ -11,7 +11,7 @@ inputs:
1111 description : GitHub token used to create and update issue comments.
1212 required : true
1313 copilot-github-token :
14- description : Fine-grained GitHub token with Copilot access for the Copilot CLI.
14+ description : Fine-grained GitHub token with Copilot access for the Copilot CLI. Supports multiple tokens, one per line, and randomly picks one.
1515 required : true
1616 bot-name :
1717 description : Bot mention to strip from issue_comment messages before appending extra requirements.
@@ -223,10 +223,33 @@ runs:
223223 shell : bash
224224 run : npm install -g "${{ inputs.copilot-package }}"
225225
226+ - name : Resolve Copilot token
227+ id : resolve_copilot_token
228+ shell : bash
229+ env :
230+ INPUT_COPILOT_GITHUB_TOKEN : ${{ inputs.copilot-github-token }}
231+ run : |
232+ python <<'PY'
233+ import os
234+ import secrets
235+
236+ raw_value = os.environ["INPUT_COPILOT_GITHUB_TOKEN"]
237+ tokens = [line.strip() for line in raw_value.splitlines() if line.strip()]
238+
239+ if not tokens:
240+ raise SystemExit("Input copilot-github-token is empty after trimming blank lines.")
241+
242+ selected_token = secrets.choice(tokens)
243+
244+ with open(os.environ["GITHUB_OUTPUT"], "a", encoding="utf-8") as fh:
245+ fh.write(f"copilot_token={selected_token}\n")
246+ fh.write(f"copilot_token_count={len(tokens)}\n")
247+ PY
248+
226249 - name : Run Copilot analysis with streaming updates
227250 shell : bash
228251 env :
229- COPILOT_GITHUB_TOKEN : ${{ inputs.copilot-github-token }}
252+ COPILOT_GITHUB_TOKEN : ${{ steps.resolve_copilot_token.outputs.copilot_token }}
230253 GITHUB_TOKEN : ${{ inputs.github-token }}
231254 GITHUB_SERVER_URL : ${{ github.server_url }}
232255 COMMENT_ID : ${{ steps.initial_comment.outputs.comment-id }}
@@ -256,6 +279,7 @@ runs:
256279 echo " comment-url: $COMMENT_URL"
257280 echo " model: $COPILOT_MODEL"
258281 echo " reasoning-effort: $COPILOT_REASONING_EFFORT"
282+ echo " copilot-token-count: ${{ steps.resolve_copilot_token.outputs.copilot_token_count }}"
259283 echo " stream-update-interval-seconds: $STREAM_UPDATE_INTERVAL"
260284 echo " analysis-prompt-file: $ANALYSIS_PROMPT_FILE"
261285 echo " output-file: $OUTPUT_FILE"
0 commit comments