Skip to content

Instantly share code, notes, and snippets.

@riazul701
Forked from tanaikech/submit.md
Created September 17, 2023 14:34
Show Gist options
  • Save riazul701/b75c6e90f62359c0bcb3b4d79e369210 to your computer and use it in GitHub Desktop.
Save riazul701/b75c6e90f62359c0bcb3b4d79e369210 to your computer and use it in GitHub Desktop.
Redeploying Web Apps without Changing URL of Web Apps for new IDE

Redeploying Web Apps without Changing URL of Web Apps for new IDE

At March 15, 2021, one endpoint is created for one deployment. Ref By this, when you redeploy "Web Apps", the endpoint is changed. Because the deployment ID is changed. It seems that this it the new specification. In this report, I would like to introduce the method for redeploying Web Apps without changing the URL of Web Apps for new IDE.

Deploy Web Apps

  1. Open "New deployment" dialog with "Deploy" -> "New deployment".

  2. Select "Web app" for "Select type".

  3. Input "Description" and as a sample, set "Web apps" as follows.

    • Execute as: Me
    • Who has access: Anyone

  4. Click "Deploy" button. And, copy the URL of "Web app" and click "Done" button. By this, you can see the following endpoint.

    • https://script.google.com/macros/s/###/exec

IMPORTANT POINT

  • When the script of Web Apps is changed and redeploy Web Apps, after March 15, 2021, the endpoint is changed. This is new specification. Because the deployment ID of ### in https://script.google.com/macros/s/###/exec is changed.

By this, there is an issue that the endpoint is changed. When you want to use the same endpoint by reflected the latest script to Web Apps, please do the following flow.

  1. Create new Google Apps Script project and copy and paste the following script.

    function doGet() {
      return ContentService.createTextOutput("sample1");
    }
  2. Deploy Web Apps as the following settings.

    • Execute as: Me
    • Who has access: Anyone
  3. Test the Web Apps using the following curl command.

    $ curl -L "https://script.google.com/macros/s/###/exec"
    • Please confirm that sample1 is returned.
  4. Modify the script of Web Apps as follows.

    function doGet() {
      return ContentService.createTextOutput("sample2"); // Modified
    }
  5. Update the deployment as follows.

    1. Open "New deployment" dialog with "Deploy" -> "Manage deployments".
    2. For the 1st deployment, click the pencil icon for editing the deployment.
    3. Set "version" as "New version".
    4. When you want to change the description, please modify it.
    5. Click "Deploy" button.
  6. Testing.

    • Please use above sample curl command. By this, you can confirm that sample2 is returned without changing the endpoint.

References

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment