1

I am trying to deploy a node app, which is in a repository in GitHub, and mirrored by the Google App Engine.

The steps I took:

  1. Create the app on my local machine

  2. Published the Repository on Github

  3. In the Google Console, I told App Engine to mirror this Repository, which works: If I go to Development, the repository shows up:

enter image description here

  1. Then I open the remote shell Google is providing, and tried to run gcloud app deploy, which gave an error, then I noticed the files are not in the directory. So I browsed through all the folders of this machine via the shell, and I can't find it.

Question: What am I missing here? Does Google mirroring my Repo not imply it is somewhere saved on the instance? Do I need to clone it to there as well?

ffritz
  • 2,180
  • 1
  • 28
  • 64

1 Answers1

4

I'm using as reference the solution pointed to by this answer: https://stackoverflow.com/a/40693455/4495081.

In the web-cached article all the ops are done inside the cloud shell, basically a local repo exists in your cloud shell "homedir". From there it is saved/uploaded to the cloud source repository:

Save your source code in Cloud Source Repositories

  1. Switch to the tab with the open shell pane and go to your app’s directory:

    cd helloworldapp
    
  2. Initialize git and your repo. The first two steps aren't necessary if you've done them before:

    git config --global user.email "you@example.com" 
    git config --global user.name "Your Name" 
    git init 
    git add . -A
    git commit -m "Initial commit"
    
  3. Authorize Git to access GCP:

    git config credential.helper gcloud.sh
    
  4. Add the repository as a remote named ‘google’ to your local Git repository, first replacing [PROJECT_ID] with the name of your Cloud project:

    git remote add google /web/20161119132814/https://source.developers.google.com/p/[PROJECT_ID]/r/default
    
    git push google master
    

In your case you went in the other direction: you created your cloud source repository and linked it to your github one using the Developer Console, but no repo exists in your cloud shell homedir.

All you need to do is to clone your cloud source repository into your cloud shell homedir, which I think can be done in the cloud shell, following the custom steps indicated in the Clone your Cloud Repository to a local Git repository section of the Source Code page, then deploy from there. Something along these lines:

gcloud init
gcloud source repos clone repo_name --project=proj_name
cd repo_name
gcloud app deploy ...
Community
  • 1
  • 1
Dan Cornilescu
  • 39,470
  • 12
  • 57
  • 97
  • Ok this is an awesome answer, thank you, but I still find it confusing :D Which one is the "cloud source repository"? What I did now (which fixed it), is just cloning my repo from github via the shell in the browser to my homedir. Not sure where the linked stuff comes into play. – ffritz Feb 08 '17 at 20:53
  • The "cloud source repo" is the google equivalent of your github repo from the cloud shell prospective - you're not working directly in it, you're working on a local repo cloned from it. This local repo copy (in the cloud shell) was what you were missing. Of course, we're talking git, so really they can all be replicated virtually in almost any direction: so sure, you can clone your local copy from either google cloud source repo or from github directly. You only need to decide which one is your "master" copy and in which direction flow the changes. – Dan Cornilescu Feb 08 '17 at 21:03
  • @DanCornilescu do you know how to SSO in GAE? – Avinash Raj Feb 09 '17 at 12:49
  • To some degree - I'm still using the older GAE SDK method, not the gcloud SDK one and I'm reluctant to experiment to not break my setup :) – Dan Cornilescu Feb 09 '17 at 12:59
  • I've been looking also [here](https://stackoverflow.com/questions/10274118/how-to-set-up-auto-deploy-to-appengine-when-pushing-to-git-repository) to find a way to automate [the deploy](https://cloud.google.com/functions/docs/deploying/repo) to GAE by creating a [custom build](https://cloud.google.com/container-builder/docs/create-custom-build-steps) on Google Cloud that initiated via a [webhook](https://developer.github.com/webhooks/) from GitHub each time there is a commit to the repo. Still unsuccessful but seems your answer is the best one that I can get for this case at the moment. – eQ19 Jun 21 '18 at 09:27