Skip to content

Commit df75c70

Browse files
authored
Bug fixes (#240)
* Harden token generation: add validation, impersonate SA if provided; propagate CAPY_SERVICE_ACCOUNT to deploy workflow. * Fail fast if active gcloud account isn’t a service account and no CAPY_SERVICE_ACCOUNT is set. * Script bug fixes * Clean up
1 parent a4b6f30 commit df75c70

3 files changed

Lines changed: 9 additions & 9 deletions

File tree

.github/workflows/deploy.yml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,6 @@ jobs:
3737
CAPY_PROJECT_ID: ${{ secrets.CAPY_PROJECT_ID }}
3838
CAPY_SERVER_REGION: ${{ secrets.CAPY_SERVER_REGION }}
3939
CAPY_THERAPY_SESSION_URL: ${{ secrets.CAPY_THERAPY_SESSION_URL }}
40-
CAPY_AGENT_TOKEN: ${{ secrets.CAPY_AGENT_TOKEN }}
4140
shell: bash
4241

4342
create-tag:

scripts/deploy_functions.sh

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -16,12 +16,14 @@ PROJECT_ID=$CAPY_PROJECT_ID
1616
source ./scripts/get_version.sh
1717
APP_VERSION=$(get_version)
1818

19-
# Generate agent token and export into CAPY_AGENT_TOKEN
20-
# Use bash to avoid relying on executable bit in CI
21-
CAPY_AGENT_TOKEN="$(bash ./scripts/generate_agent_token.sh | tr -d '\n')"
22-
if [ -z "$CAPY_AGENT_TOKEN" ]; then
23-
echo "Failed to generate CAPY_AGENT_TOKEN" >&2
24-
exit 1
19+
# Ensure CAPY_AGENT_TOKEN is set; generate if missing
20+
if [ -z "${CAPY_AGENT_TOKEN:-}" ]; then
21+
# Use bash to avoid relying on executable bit in CI
22+
CAPY_AGENT_TOKEN="$(bash ./scripts/generate_agent_token.sh | tr -d '\n')"
23+
if [ -z "$CAPY_AGENT_TOKEN" ]; then
24+
echo "Failed to generate CAPY_AGENT_TOKEN" >&2
25+
exit 1
26+
fi
2527
fi
2628

2729
# Set environment variables

scripts/generate_agent_token.sh

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
11
#!/bin/bash
22

3-
# Use the active credentials (set by CI auth) to mint an identity token
4-
gcloud auth print-identity-token --audiences="$CAPY_THERAPY_SESSION_URL"
3+
gcloud auth print-identity-token

0 commit comments

Comments
 (0)