Skip to content

Commit dfa0733

Browse files
authored
Merge pull request #434 from QuantStrategyLab/fix/ibkr-reconciliation-workflow-token
fix: mint audience-bound Cloud Run token for evidence reads
2 parents 44ed19b + 8f590fa commit dfa0733

1 file changed

Lines changed: 29 additions & 5 deletions

File tree

.github/workflows/collect-reconciliation-evidence.yml

Lines changed: 29 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -71,22 +71,46 @@ jobs:
7171
if: ${{ steps.selection.outputs.selected == 'true' }}
7272
uses: google-github-actions/setup-gcloud@v3
7373

74-
- name: Collect no-order reconciliation candidate
74+
- name: Resolve Cloud Run audience
75+
id: audience
7576
if: ${{ steps.selection.outputs.selected == 'true' }}
7677
env:
7778
SERVICE: ${{ matrix.service }}
78-
PROFILE: ${{ matrix.profile }}
7979
run: |
8080
set -euo pipefail
8181
service_url="$(gcloud run services describe "$SERVICE" --project "$GCP_PROJECT_ID" --region "$GCP_REGION" --format='value(status.url)')"
8282
test -n "$service_url"
83-
identity_token="$(gcloud auth print-identity-token --audiences="$service_url")"
83+
echo "service_url=$service_url" >> "$GITHUB_OUTPUT"
84+
85+
- name: Mint short-lived Cloud Run token
86+
id: cloud_run_token
87+
if: ${{ steps.selection.outputs.selected == 'true' }}
88+
uses: google-github-actions/auth@v3
89+
with:
90+
workload_identity_provider: ${{ env.GCP_WORKLOAD_IDENTITY_PROVIDER }}
91+
service_account: ${{ env.GCP_WORKLOAD_IDENTITY_SERVICE_ACCOUNT }}
92+
token_format: id_token
93+
id_token_audience: ${{ steps.audience.outputs.service_url }}
94+
create_credentials_file: false
95+
export_environment_variables: false
96+
request_reason: read-only IBKR reconciliation evidence collection
97+
98+
- name: Collect no-order reconciliation candidate
99+
if: ${{ steps.selection.outputs.selected == 'true' }}
100+
env:
101+
PROFILE: ${{ matrix.profile }}
102+
SERVICE_URL: ${{ steps.audience.outputs.service_url }}
103+
IDENTITY_TOKEN: ${{ steps.cloud_run_token.outputs.id_token }}
104+
run: |
105+
set -euo pipefail
106+
test -n "$SERVICE_URL"
107+
test -n "$IDENTITY_TOKEN"
84108
mkdir -p reports
85109
curl --fail --silent --show-error --max-time 90 \
86110
--request POST \
87-
--header "Authorization: Bearer ${identity_token}" \
111+
--header "Authorization: Bearer ${IDENTITY_TOKEN}" \
88112
--output "reports/${PROFILE}.json" \
89-
"${service_url}/reconcile"
113+
"${SERVICE_URL}/reconcile"
90114
jq -e --arg profile "$PROFILE" '
91115
.schema_version == "ibkr_reconciliation_candidate.v1"
92116
and .evidence.platform_id == "ibkr"

0 commit comments

Comments
 (0)