Kanji
・Ingeniero Cloud / Freelance ・Nacido en 1993 ・De Ehime / Residente en Shibuya, Tokio ・5 años de experiencia en AWS Detalles del perfil
Índice
Direct commit commenting to trigger Google Chat webhooks may experience limitations depending on workspace policies. Triggering automated notifications upon Release creation or Pull Request merge events is recommended for enterprise environments. A follow-up guide covering Release-driven notifications is planned.
Standard personal (free) Google accounts cannot natively receive direct Cloud Build webhook notifications inside Google Chat.
While the Cloud Build integration appears selectable in Google Chat app directories, attempting configuration fails because the underlying Google Chat API requires a Google Workspace enterprise plan.
Direct incoming webhooks are similarly restricted, making notification setups less out-of-the-box compared to Slack or Discord.
However, by leveraging the Google Chat GitHub App integration (which remains available on free accounts), we can route Cloud Build completion events by commenting directly on the GitHub commit, which immediately forwards a formatted card to Google Chat.
Google Cloud project created. [Ref 1]
The following APIs enabled in your GCP project: [Ref 2]
Cloud Build API
Secret Manager API
A GitHub account. [Ref 3]
GitHub CLI ( gh ) installed in your local terminal environment. [Ref 4]
gh
References:
Ref 1: Creating and Managing Projects | Resource Manager Documentation | Google Cloud
Ref 2: Enabling APIs in Your Google Cloud Project | Cloud Endpoints
Ref 3: Creating a GitHub Account | GitHub Docs
Ref 4: GitHub CLI Manual | cli.github.com
Only select repositories
All repositories
Administration: Read-only
Contents: Read and write
GIT_HUB_PERSONAL_ACCESS_TOKEN
gh repo create test-repository --private --clone # Output: # ✓ Created repository <owner>/test-repository on GitHub
test-repository-master
GitHub (Cloud Build GitHub App)
Comments
python/post_deploy/__main__.py
python/requirements.post_deploy.txt
cloudbuild.yaml
#!/usr/bin/env python3 from datetime import datetime import json import logging import os import sys from google.cloud import secretmanager import requests GIT_HUB_REPO_OWNER = "${REPO_OWNER}" LOG_LEVEL = os.environ.get("LOG_LEVEL", "INFO") class TimeFormatter(logging.Formatter): converter = datetime.fromtimestamp def formatTime(self, record, datefmt=None): created_time = self.converter(record.created).astimezone() timezone = created_time.strftime('%z') return created_time.strftime('%Y/%m/%d %H:%M:%S.%f') + timezone[:3] + ':' + timezone[3:] def init_logger(): logger = logging.getLogger(__name__) log_format_string = json.dumps({ 'logLevel': '%(levelname)s', 'time': '%(asctime)s', 'line': "%(filename)s: %(lineno)d", 'message': '%(message)s', }, indent=None) handler = logging.StreamHandler(sys.stdout) handler.setFormatter((TimeFormatter(log_format_string))) logger.addHandler(handler) logger.setLevel(LOG_LEVEL) return logger def get_git_hub_token(project_id): client = secretmanager.SecretManagerServiceClient() name = client.secret_version_path(project_id, 'GIT_HUB_PERSONAL_ACCESS_TOKEN', 1) response = client.access_secret_version(name=name) return response.payload.data.decode('UTF-8') def create_comment_on_commit(token, repo_name, commit_sha, comment, logger): url = f"https://api.github.com/repos/{repo_name}/commits/{commit_sha}/comments" headers = {'Authorization': f'token {token}'} data = {'body': comment} response = requests.post(url, headers=headers, json=data) if response.status_code != 201: raise Exception(f'Failed to create comment on commit: {response.content}') logger.info("Created comment on commit") return response.json() def main(): logger = init_logger() project_id = os.environ["PROJECT_ID"] repo_name = os.environ["REPO_NAME"] commit_sha = os.environ["COMMIT_SHA"] build_id = os.environ["BUILD_ID"] create_comment_on_commit( repo_name=f"{GIT_HUB_REPO_OWNER}/{repo_name}", commit_sha=commit_sha, comment='\n'.join([ "## Deployed", f"Commit ID: {commit_sha}", f"Cloud Build URL: https://console.cloud.google.com/cloud-build/builds;region=global/{build_id};step=0?hl=en&project={project_id}", ]), token=get_git_hub_token(project_id=project_id), logger=logger ) if __name__ == "__main__": main()
requests==2.28.2 google-cloud-secret-manager==2.16.4
steps: # Deploy steps execute here... - id: "PostDeploy" name: python:3.9 entrypoint: sh args: - -c - | export PROJECT_ID="${PROJECT_ID}" && \ export BUILD_ID="${BUILD_ID}" && \ export PROJECT_NUMBER="${PROJECT_NUMBER}" && \ export LOCATION="${LOCATION}" && \ export TRIGGER_NAME="${TRIGGER_NAME}" && \ export COMMIT_SHA="${COMMIT_SHA}" && \ export REVISION_ID="${REVISION_ID}" && \ export SHORT_SHA="${SHORT_SHA}" && \ export REPO_NAME="${REPO_NAME}" && \ export BRANCH_NAME="${BRANCH_NAME}" && \ export TAG_NAME="${TAG_NAME}" && \ export REF_NAME="${REF_NAME}" && \ export TRIGGER_BUILD_CONFIG_PATH="${TRIGGER_BUILD_CONFIG_PATH}" && \ pip install --quiet --upgrade pip && \ pip install --quiet --user -r ./python/requirements.post_deploy.txt && \ python3 ./python/post_deploy
Real-time AI quant analysis of corporate earnings reports.
Entrene habilidades sociales con llamadas simuladas realistas, retroalimentación en 5 ejes, academia interactiva y fotos de perfil con IA.
Fotografíe recibos para un desglose instantáneo con IA. Conexión directa con LINE para liquidar gastos compartidos sin fricción.
Personajes de IA (Adivina, Mayordomo, Barman) moderan dinámicas y retos en tiempo real para animar cualquier reunión.
人工甘味料や添加物のNG除外と有効成分あたりの実質単価比較データベース。