Kanji
・Cloud engineer / freelance ・Born in 1993 ・From Ehime / Living in Shibuya, Tokyo ・5 years AWS experience Profile details
Table of Contents
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.
Google Cloud project created. [Ref 1]
The following APIs enabled in your GCP project: [Ref 2]
A GitHub account. [Ref 3]
GitHub CLI ( gh ) installed in your local terminal environment. [Ref 4]
gh
References:
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
Master conversation skills with realistic AI phone training and 5-axis feedback. Includes 16-lesson interactive academy and studio AI portraits.
Effortlessly snap receipts for instant AI itemization. Integrated with LINE for seamless group expense tracking and pain-free settlement.
Interactive AI personas (Fortune Teller, Butler, Bartender) host real-time games, challenges, and conversation starters for unforgettable gatherings.
Real-time AI quant analysis of earnings reports, corporate filings, and momentum indicators for global equities and Japanese stocks.
Unbiased healthcare database featuring zero-additive filters and active ingredient cost performance metrics.
Get the complete configuration pack featured in this article: universal AGENTS.md, deterministic hooks.json, Git safety guardrails, and validation scripts tested across Antigravity, Kiro, Claude Code, and Codex.