Deploy an app from Cloud Source Repositories to App Engine

This quickstart describes how to deploy an app from Cloud Source Repositories to App Engine. In the steps that follow, you deploy your app, update the app's code and the repository, and redeploy the updated code.

Before you begin

  1. Complete the steps from Create a code repository in Cloud Source Repositories.

    After you complete that quickstart, you have an app you can deploy to App Engine.

  2. Enable the App Engine Admin API.
  3. Enable the Admin API

Deploy your app

  1. In a terminal window, go to the directory containing the repository:

    cd hello-world
    
  2. Deploy the sample app:

    gcloud app deploy app.yaml
    
  3. Verify that your app is running:

    gcloud app browse
    

    The browser displays the message Hello, World!.

Update your app

  1. In a terminal window, use a text editor to update the main.py file by pasting the following code:

    #!/usr/bin/env python
    
    import webapp2
    
    class MainHandler(webapp2.RequestHandler):
        def get(self):
            self.response.write('Goodbye, Moon!')
    
    app = webapp2.WSGIApplication([
        ('/', MainHandler)
    ], debug=True)
    
  2. Add the file so Git can commit it:

    git add main.py
    
  3. Commit the file with a comment describing the history of this action:

    git commit -m "Update main.py to say Goodbye Moon"
    
  4. Push the file to Cloud Source Repositories:

    git push origin master
    

Redeploy your app

  1. In a terminal window, enter the following command:

    gcloud app deploy app.yaml
    
  2. Open your app:

    gcloud app browse
    

    The browser displays the message Goodbye, Moon!.

Clean up

To avoid incurring charges to your Google Cloud account for the resources used on this page, follow these steps.

Disable your app

  1. In the Google Cloud console, go to the App Engine Settings page.

    Go to the Settings page

  2. Click Disable application and follow the instructions.

    Disabling your app takes effect immediately.

  3. Confirm that your app is disabled by visiting the URL of your app, for example, http://[YOUR_PROJECT_ID].appspot.com/, where [YOUR_PROJECT_ID] is the name of your Google Cloud project ID. If your app is disabled, an HTTP 404 Not Found status code is returned.

Delete the repository

  1. In the GCP Console, open the All repositories page for Cloud Source Repositories.

    Open Cloud Source Repositories

  2. Hold the pointer over the repository you want to delete and click Settings .

    The General settings page opens.

  3. Click Delete this repository .

    The Remove repository dialog opens.

  4. Type the name of the repository you want to delete.

  5. Click Delete.

What's next