{"id":19268479,"url":"https://github.com/pnu/gcr-trigger-build-wip","last_synced_at":"2026-06-08T23:32:19.199Z","repository":{"id":44834636,"uuid":"236992985","full_name":"pnu/gcr-trigger-build-wip","owner":"pnu","description":"**work in progress** – Trigger Cloud Build jobs when new tags are inserted to GCR or webhook called.I've implemented similar for Cloud Run and at least for the current use-case it seems to be better fit.. but I'll save this here for later reference.","archived":false,"fork":false,"pushed_at":"2022-06-02T21:32:25.000Z","size":68,"stargazers_count":0,"open_issues_count":3,"forks_count":0,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-02-23T19:46:13.622Z","etag":null,"topics":["cloudbuild","gcf","gcloud","gcr","pubsub","secrets-manager","wip"],"latest_commit_sha":null,"homepage":"","language":"Shell","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/pnu.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2020-01-29T13:51:07.000Z","updated_at":"2020-01-29T13:57:39.000Z","dependencies_parsed_at":"2022-09-19T13:51:15.166Z","dependency_job_id":null,"html_url":"https://github.com/pnu/gcr-trigger-build-wip","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/pnu/gcr-trigger-build-wip","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pnu%2Fgcr-trigger-build-wip","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pnu%2Fgcr-trigger-build-wip/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pnu%2Fgcr-trigger-build-wip/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pnu%2Fgcr-trigger-build-wip/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/pnu","download_url":"https://codeload.github.com/pnu/gcr-trigger-build-wip/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pnu%2Fgcr-trigger-build-wip/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":34085321,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-26T15:22:16.424Z","status":"online","status_checked_at":"2026-06-08T02:00:07.615Z","response_time":111,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["cloudbuild","gcf","gcloud","gcr","pubsub","secrets-manager","wip"],"created_at":"2024-11-09T20:16:28.447Z","updated_at":"2026-06-08T23:32:19.176Z","avatar_url":"https://github.com/pnu.png","language":"Shell","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Setup\n\n    gcloud config set project \u003cPROJECT\u003e\n    gcloud config set functions/region \u003cREGION\u003e\n    ./gcloud-initial-setup.sh\n    yarn deploy\n\n# Components\n\n  GCR =\u003e `gcrWatcher` =\u003e PubSub\n\n  HTTP =\u003e `webhookWatcher` =\u003e PubSub\n\n  PubSub =\u003e `triggerBuild` =\u003e Cloud build =\u003e Firebase\n\n# Description\n\nCloud Function `gcrWatcher` subscribes to the GCR PubSub topic.\nIf a new tag that matches the configuration (see\n`gcloud-config-update.sh`) is inserted to the GCR, the function\ntriggers a new Cloud build task. This happens by publishing a\nmessage to another topic. Message body defines name of the\nrequested build job.\n\nCloud Function `triggerBuild` subcribes to this second topic\nand launches the actual Cloud build job, if build job name\nmatches the configured name.\n\nCloud Function `webhookWatcher` is attached to an HTTPS endpoint.\nThe request is authenticated with a shared secret. HTTP body\ncontains a JSON payload that defines the requested build job, which\nis then triggered by sending a message to `triggerBuild`.\n\nConfiguration is stored in GCP Secrects Manager, because it may\ncontain some sensitive API-keys or tokens for deployment. It also\nmeans that the configuration can be changed dynamically without\nredeploying the code. For example webhook authentication secret\ncan be rotated as a configuration task only. Script\n`gcloud-config-update.sh` can be used to update the configuration.\nThis script also generates a webhook authentication secret,\nwhich needs to be included in the webhook call.\n\n# Example use-case\n\nWhen new image is pushed to GCR and tagged with `latest`,\nthis automation takes the build image, and runs a prerendering\ntask _inside_ that prebuilt image (running in Cloud build runtime).\nThe created assets are then deployed to Firebase hosting.\nThis buildtask is defined as a json configuration, in `gcloud-config-prerender.json`.\n\nIn addition to new build images, the same prerendering task\nis run when content in an external CMS changes. The CMS system\ntriggers a webhook POST (with json payload describing the\nrequested buildtask). Webhook triggers the same build task\nas the GCR use-case above.\n\nSame automation can be used for triggering any build task on GCR\nchanges or webhooks, and can be deployed multiple times to same\nproject if taking care of naming the functions and configuration\nentries separately for each use-case.\n\n# Miscellaneous\n\nThe prerendering task in `gcloud-config-prerender.json` is included\nas part of the dynamic configuration (see `gcloud-config-update.sh`).\nIe. this _file_ is not shipped to the functions.\n\nFor testing purposes the bare JSON file can be used to trigger a cloud build job manually, eg:\n\n    GCP_PROJECT=\u003cPROJECT\u003e\n\n    gcloud builds submit --no-source --config gcloud-config-prerender.json --substitutions=\"_BUILD_IMAGE_NAME=gcr.io/${GCP_PROJECT}/build:latest,_FIREBASE_HOSTING_PROJECT=${GCP_PROJECT},_FIREBASE_HOSTING_TARGET=staging\"\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpnu%2Fgcr-trigger-build-wip","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fpnu%2Fgcr-trigger-build-wip","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpnu%2Fgcr-trigger-build-wip/lists"}