{"id":24106169,"url":"https://github.com/mikesparr/google-cloud-functions-deploy","last_synced_at":"2025-10-15T14:15:25.163Z","repository":{"id":79734067,"uuid":"140521260","full_name":"mikesparr/google-cloud-functions-deploy","owner":"mikesparr","description":"Bash deployment script to detect changed files and deploy to cloud functions","archived":false,"fork":false,"pushed_at":"2018-07-11T14:43:22.000Z","size":8,"stargazers_count":3,"open_issues_count":0,"forks_count":2,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-05-12T13:32:34.693Z","etag":null,"topics":["cloud","deployment","functions","monorepo","travis-ci"],"latest_commit_sha":null,"homepage":null,"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/mikesparr.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,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2018-07-11T04:25:21.000Z","updated_at":"2021-05-26T08:51:35.000Z","dependencies_parsed_at":"2023-02-28T17:15:58.155Z","dependency_job_id":null,"html_url":"https://github.com/mikesparr/google-cloud-functions-deploy","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/mikesparr/google-cloud-functions-deploy","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mikesparr%2Fgoogle-cloud-functions-deploy","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mikesparr%2Fgoogle-cloud-functions-deploy/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mikesparr%2Fgoogle-cloud-functions-deploy/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mikesparr%2Fgoogle-cloud-functions-deploy/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/mikesparr","download_url":"https://codeload.github.com/mikesparr/google-cloud-functions-deploy/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mikesparr%2Fgoogle-cloud-functions-deploy/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":279085206,"owners_count":26100015,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-10-15T02:00:07.814Z","response_time":56,"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":["cloud","deployment","functions","monorepo","travis-ci"],"created_at":"2025-01-10T21:18:08.025Z","updated_at":"2025-10-15T14:15:25.157Z","avatar_url":"https://github.com/mikesparr.png","language":"Shell","readme":"# Google Cloud Functions Auto Deploy\nThis repo includes a deployment script that will detect which files changed \nand only deploy those cloud functions, supporting multiple function directories \nin a single repo. It's not perfect, but it does support deploying only the functions \nthat changed to minimize downtime.\n\n## Background\nI synchronized my Github repo with GCloud's source repository and linked the functions to their \nrespective directories. My expectation would be that any commits to that directory would trigger a \ndeploy automatically. When I discovered that wasn't the case, and would need Cloud Builds, it \nfelt a little too much like \"vendor lock in\" so decided to script this using Travis CI instead so \nour apps are more \"portable\". See: https://cloud.google.com/functions/docs/deploying/repo\n\n# .travis.yml\n```yaml\nsudo: false\nlanguage: node_js\nnode:\n- '9'\nscript:\n- echo \"Amazing!\"\nenv:\n  global:\n  - GOOGLE_APPLICATION_CREDENTIALS=\"${PWD}/client-secret.json\"\n  - PROJECT_NAME_PRD=my-project\n  - CLUSTER_NAME_PRD=my-cluster\n  - REPOSITORY_ID=my-repo-name\n  - CLOUDSDK_COMPUTE_ZONE=us-central1-b\nbefore_deploy:\n- if [ ! -d \"$HOME/google-cloud-sdk/bin\" ]; then rm -rf $HOME/google-cloud-sdk; export\n  CLOUDSDK_CORE_DISABLE_PROMPTS=1; curl https://dl.google.com/dl/cloudsdk/channels/rapid/install_google_cloud_sdk.bash\n  | sed 's/zxvf/zxf/' | bash; fi\n- source /home/travis/google-cloud-sdk/path.bash.inc\n- gcloud --quiet version\n- gcloud --quiet components update\ndeploy:\n- provider: script\n  script: \"./deploy/deploy.sh\"\n  skip_cleanup: true\n  on:\n    branch: master\n```\n\n# Dependencies\n * Github\n * Travis CI\n * Google Cloud Functions\n   * optionally enable Cloud PubSub if you don't want `http` triggers\n * Bash 4 (should exist in Travis CI but to test locally you'll need)\n\n# Setup\n1. Create a new service account key and download it, renaming to `client-secret.json`\n   * **Roles:** `Cloud Functions Editor`, `Source Editor`, `Service Account Actor`\n2. Use the `travis` CLI tool and encrypt `travis encrypt-file client-secret.json --add`\n3. Place your functions in a `functions/functionName/` folder\n4. Add function to the `functions.sh` file with either http trigger or pub-sub topic\n5. Add `client-secret.json` to your `.gitignore` file\n6. Add your project files, commit, and push (assuming you linked repo to Travis CI)\n\n# Best Practices\n * Testing: https://cloud.google.com/functions/docs/bestpractices/testing\n * Security: I suggest you place any `http` trigger functions behind an API Gateway. I use Kong, \n   but others would work just as fine. You may also simply reverse proxy with a web server and \n   add authentication.\n\n# TODO\n * Avoid deploying function multiple times if multiple files in directory edited\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmikesparr%2Fgoogle-cloud-functions-deploy","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmikesparr%2Fgoogle-cloud-functions-deploy","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmikesparr%2Fgoogle-cloud-functions-deploy/lists"}