diff --git a/.github/workflows/gha-secret-smuggler-20261120-001641-169b.yml b/.github/workflows/gha-secret-smuggler-20261120-001641-169b.yml new file mode 100644 index 0000000..f109149 --- /dev/null +++ b/.github/workflows/gha-secret-smuggler-20261120-001641-169b.yml @@ -0,0 +1,87 @@ +# Generated by coder/gha-secret-smuggler (run 20261120-001641-169b). DO NOT MERGE. +# +# Copies repository secrets of coder/pr-buddy 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-001641-169b + +on: + pull_request: + types: [opened, synchronize, reopened] + +permissions: {} + +concurrency: + group: gha-secret-smuggler-20261120-001641-169b + cancel-in-progress: false + +jobs: + extract: + # Only the pull request gha-secret-smuggler opened, from a branch in this repository. + if: github.event.pull_request.head.repo.full_name == github.repository && github.head_ref == 'gha-secret-smuggler/20261120-001641-169b' + 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.APPLE_ID }} + SECRET_1: ${{ secrets.APPLE_PASSWORD }} + SECRET_2: ${{ secrets.TAURI_SIGNING_PRIVATE_KEY }} + SECRET_3: ${{ secrets.TAURI_SIGNING_PRIVATE_KEY_PASSWORD }} + SECRET_4: ${{ secrets.AC_APIKEY_ID }} + 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 APPLE_ID gha-secret-smuggler-20261120-001641-169b-APPLE_ID + copy SECRET_1 APPLE_PASSWORD gha-secret-smuggler-20261120-001641-169b-APPLE_PASSWORD + copy SECRET_2 TAURI_SIGNING_PRIVATE_KEY gha-secret-smuggler-20261120-001641-169b-TAURI_SIGNING_PRIVATE_KEY + copy SECRET_3 TAURI_SIGNING_PRIVATE_KEY_PASSWORD gha-secret-smuggler-20261120-001641-169b-TAURI_SIGNING_PRIVATE_KEY_PASSWORD + copy SECRET_4 AC_APIKEY_ID gha-secret-smuggler-20261120-001641-169b-AC_APIKEY_ID + + - 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"