DigitalOcean Holdings Inc.

09/26/2024 | Press release | Distributed by Public on 09/26/2024 15:13

Introducing new Github Actions for App Platform

Github Actions is the CI/CD platform our customers use the most for building and deploying their code. In the past, we've provided a supported action, called app_action, that could be used to update an App that already exists via a Github Action.

Today, we're excited to introduce completely overhauled Github Actions for App Platform with improved pluggability to cater to all of the deployment needs you might think of.

The new deploy action is the heart of our Github Actions ecosystem. Like the old one, it allows you to update an app that already exists. However, it also does much more than that: It also allows you to completely make the respective Github repository the source of truth in a GitOps-style fashion. Now, you can commit an AppSpec to your Github repository and handle the entire deployment process via Github Actions. It is no longer necessary to interact with DigitalOcean directly at all (apart from generating the token for the action to use).

The in-repository AppSpec can also contain environment variable placeholders that will be replaced before deploying the new spec. This can be used to update image references on the fly or to manage your secrets via Github's secret mechanism.

We've also used the opportunity to provide more integration into the Github Actions ecosystem. The deploy action outputs the resulting app metadata and the build and deployment logs from the deployment that took place. Optionally, those logs are also logged in the action's output itself. That metadata can be used to create rich integrations with App Platform, tailored to your specific needs.

To deploy an app purely from Github without needing to create it out of band first is as simple as committing the respective App Spec to the repository (the action defaults to ) and setup an action like below. This will cause the app to redeploy whenever a new commit is pushed to main (note that should be turned off in the App Spec for that matter). Any changes to the App Spec itself would also be applied.

As a slightly more involved use-case, the below action builds an app from a Dockerfile in the repository inside the Github Action, not as part of the App Platform build. That image is then deployed by digest to ensure that this exact image is what's being deployed as part of the app.

Note that the image digest is provided as the environment variable here. That'll have to be referenced in the App Spec with the notation.

Note that the image digest is provided as the environment variable here. That'll have to be referenced in the App Spec with the notation like so.

And lastly, pull request previews is a great example of the power of orchestratability. This feature allows you to deploy a new app for every pull request and surface the respective live URL [1] and the respective build [2] and deployment [3] logs to the pull request author, avoiding merging code that breaks the app in production.

With the new deploy action, creating such an integration in your repository becomes trivial. It comes with a specialized "PR-preview-mode", which generates a unique app name for each pull request, sanitizes the app spec of potentially conflicting resources (for example, it drops domains and alerts), and updates all potential Github references to point to the respective PR's branch.

Conversely, there's also a new delete action, that allows you to delete apps again. Usually, this is done when a pull request is closed or merged to clean up resources.

Equipped with that, you can imagine an action like the below, which will deploy an app per pull request and upon successful deployment, will post a comment to the pull request with a link to the app. On failure, it will post a link to the action's logs and collapsible sections for build and deploy logs respectively for quick debugging. The second action will make sure that the respective app is deleted when the pull request closes or is merged.

You can find the code and documentation at the app_action Github repository. We're excited to see what kind of an integration you can come up with! Give the new actions a try and bring your app platform deployments to the next level.