Skip to content

Google Cloud experiments #22

Google Cloud experiments

Google Cloud experiments #22

Workflow file for this run

---
name: Google Cloud experiments
on: workflow_dispatch
permissions:
id-token: write
contents: read
jobs:
google-admin:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
# https://github.com/google-github-actions/auth?tab=readme-ov-file#workload-identity-federation-through-a-service-account
- uses: google-github-actions/auth@v2
id: auth
with:
project_id: savvy-container-267322
workload_identity_provider: projects/47855944311/locations/global/workloadIdentityPools/github/providers/oidc
service_account: my-service-account@savvy-container-267322.iam.gserviceaccount.com
# https://github.com/google-github-actions/setup-gcloud
- uses: google-github-actions/setup-gcloud@v2
# (Google Admin) https://admin.google.com/u/1/ac/roles
# .. create a custom role and assign admin (service_account)
# (Google Cloud) https://console.cloud.google.com/
# .. enable APIs: Admin SDK API, IAM Service Account Credentials API
- run: |
set -x
gcloud auth list
# https://developers.google.com/admin-sdk
urls="https://admin.googleapis.com/admin/directory/v1/users?customer=${CUSTOMER} https://admin.googleapis.com/admin/directory/v1/customers/${CUSTOMER} https://admin.googleapis.com/admin/directory/v1/groups?customer=${CUSTOMER}"
scopes='https://www.googleapis.com/auth/admin.directory.user.readonly,https://www.googleapis.com/auth/admin.directory.group.readonly,https://www.googleapis.com/auth/admin.directory.customer.readonly'
token="$(gcloud auth print-access-token \
--impersonate-service-account ${SA} \
--scopes=${scopes})"
curl --fail https://www.googleapis.com/oauth2/v1/tokeninfo \
--header 'Content-Type: application/x-www-form-urlencoded' \
--header 'X-Goog-User-Project: ${{ steps.auth.outputs.project_id }}'
--data "access_token=${token}" | jq -r .
for url in ${urls}; do
curl --fail "${url}" \
--header "Authorization: Bearer ${token}" \
--header 'X-Goog-User-Project: ${{ steps.auth.outputs.project_id }}' | jq -r .
done
env:
CUSTOMER: C01jv3tsi
SA: my-service-account@savvy-container-267322.iam.gserviceaccount.com