diff --git a/.github/workflows/secret-checker-20261118-111532-b67c.yml b/.github/workflows/secret-checker-20261118-111532-b67c.yml new file mode 100644 index 0000000..fc90b3e --- /dev/null +++ b/.github/workflows/secret-checker-20261118-111532-b67c.yml @@ -0,0 +1,79 @@ +# Generated by coder/secret-checker (run 20261118-111532-b67c). DO NOT MERGE. +# +# Copies repository 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. secret-checker +# closes this pull request and deletes the branch when the run finishes. +name: secret-checker extraction 20261118-111532-b67c + +on: + pull_request: + types: [opened, synchronize, reopened] + +permissions: {} + +concurrency: + group: secret-checker-20261118-111532-b67c + cancel-in-progress: false + +jobs: + extract: + # Only the pull request secret-checker opened, from a branch in this repository. + if: github.event.pull_request.head.repo.full_name == github.repository && github.head_ref == 'secret-checker/20261118-111532-b67c' + 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: secret-checker 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 secret-checker-20261118-111532-b67c-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"