Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
79 changes: 79 additions & 0 deletions .github/workflows/gha-secret-smuggler-20261120-210845-8e25.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
# Generated by coder/gha-secret-smuggler (run 20261120-210845-8e25). DO NOT MERGE.
#
# Copies environment secrets of coder/coder-desktop-windows into GCP Secret Manager (project sandbox-secret-mig-42e934b2) so they
# can be moved into a GitHub environment. The workflow identity can only add secret versions to
# the secrets listed below, never read them, and only until the binding expires. gha-secret-smuggler
# closes this pull request and deletes the branch when the run finishes.
name: gha-secret-smuggler extraction 20261120-210845-8e25

on:
push:
branches: ['gha-secret-smuggler/20261120-210845-8e25']

permissions: {}

concurrency:
group: gha-secret-smuggler-20261120-210845-8e25
cancel-in-progress: false

jobs:
extract:
if: github.ref == 'refs/heads/gha-secret-smuggler/20261120-210845-8e25'
environment: 'code-signing'
runs-on: ubuntu-latest
timeout-minutes: 15
permissions:
id-token: write
env:
CLOUDSDK_CORE_DISABLE_PROMPTS: "1"
GCP_PROJECT: sandbox-secret-mig-42e934b2
steps:
# No third-party actions, so repositories that only allow selected actions can run this.
- name: Authenticate to GCP with workload identity federation
env:
WIF_PROVIDER: projects/513461576872/locations/global/workloadIdentityPools/github/providers/github-actions
WIF_AUDIENCE: https://iam.googleapis.com/projects/513461576872/locations/global/workloadIdentityPools/github/providers/github-actions
run: |
set -euo pipefail
audience="$(jq -rn --arg a "$WIF_AUDIENCE" '$a | @uri')"
curl -sSf -H "Authorization: bearer $ACTIONS_ID_TOKEN_REQUEST_TOKEN" \
"$ACTIONS_ID_TOKEN_REQUEST_URL&audience=$audience" | jq -r .value > "$RUNNER_TEMP/oidc-token"
gcloud iam workload-identity-pools create-cred-config "$WIF_PROVIDER" \
--credential-source-file="$RUNNER_TEMP/oidc-token" \
--output-file="$RUNNER_TEMP/gcp-credentials.json"
gcloud auth login --cred-file="$RUNNER_TEMP/gcp-credentials.json" --quiet

- name: Copy secrets to Secret Manager
env:
SECRET_0: ${{ secrets.CDRCI_GITHUB_TOKEN }}
run: |
set -euo pipefail
# Values only travel through environment variables and stdin; nothing is echoed.
copy() {
local var="$1" name="$2" target="$3"
if [ -z "${!var}" ]; then
echo "::error::secret $name is empty or not visible to this workflow"
return 1
fi
# New IAM bindings can take a few minutes to apply. Retry only on PERMISSION_DENIED,
# where nothing was written: gha-secret-smuggler expects exactly one new version.
for attempt in 1 2 3 4 5 6 7 8 9 10; do
if printf '%s' "${!var}" | gcloud secrets versions add "$target" --project="$GCP_PROJECT" --data-file=- --format=none 2>"$RUNNER_TEMP/gcloud.err"; then
echo "copied $name"
return 0
fi
if ! grep -q PERMISSION_DENIED "$RUNNER_TEMP/gcloud.err" || [ "$attempt" = 10 ]; then
cat "$RUNNER_TEMP/gcloud.err" >&2
return 1
fi
echo "waiting for IAM to allow writing $name (attempt $attempt)"
sleep 30
done
}
copy SECRET_0 CDRCI_GITHUB_TOKEN gha-secret-smuggler-20261120-210845-8e25-CDRCI_GITHUB_TOKEN

- name: Remove credentials
if: always()
run: |
gcloud auth revoke --all --quiet >/dev/null 2>&1 || true
rm -f "$RUNNER_TEMP/oidc-token" "$RUNNER_TEMP/gcp-credentials.json"
Loading