GitHub Action
DigitalOcean App Platform deployment
v1.1.6
Latest version
Deploy a DigitalOcean App Platform app using GitHub Actions.
- Auto-deploy your app from source on commit, while allowing you to run tests or perform other operations before.
- Auto-deploy your app from source and also update DockerHub / DigitalOcean Container Registry (DOCR) configuration in DigitalOcean App Spec and deploy application with updated container image.
- Get DigitalOcean Personal Access token by following this instructions.(skip this step if you already have DigitalOcean Personal Access Token)
- Declare DigitalOcean Personal Access Token as DIGITALOCEAN_ACCESS_TOKEN variable in the secrets of github repository.
- Create a GitHub Action workflow file and add this step below to it or add this to your existing action.
- name: DigitalOcean App Platform deployment uses: digitalocean/app_action@v1.1.5 with: app_name: my_DO_app token: ${{ secrets.DIGITALOCEAN_ACCESS_TOKEN }}
- This step will trigger a deploy to your App on DigitalOcean App Platform
- Get DigitalOcean Personal Access token by following this instructions(skip this step if you already have DigitalOcean Personal Access Token)
- Declare DigitalOcean Personal Access Token as DIGITALOCEAN_ACCESS_TOKEN variable in the secrets of github repository.
- Add this step to update DigitalOcean Container Registry configuration of single or multiple component in app_spec
- name: DigitalOcean App Platform deployment uses: digitalocean/app_action@v1.1.5 # replace this with current version from https://github.com/digitalocean/app_action/releases with: app_name: my_DO_app token: ${{ secrets.DIGITALOCEAN_ACCESS_TOKEN }} images: '[ { "name": "sample-golang", "image":{ "registry_type": "DOCR", "repository": "add_sample", "tag": "a5cae3e" }, }, { "name": "sample-add", "image":{ "registry_type": "DOCKER_HUB", "registry": "nginxdemos", "repository": "hello", "tag": "0.2" }, ]'
- DigitalOcean App Platform will now update your container image information in App Spec and then deploy your application.
- This step will trigger a DigitalOcean App Platform deployment of your app using the images specified.
Note: Always use unique tag names (i.e. v1.1.15
instead of latest
or main
) to push image to the DigitalOcean Container Registry. This will allow you to deploy your application without delay. ref
app_name
- Name of the app on App Platform.images
- (optional)List of json objects (of type ImageSourceSpec, see Reference for App Specification) for providing information about name, registry type, repository, and tag of the image in .[{ "name": " ", #component name "image":{ "registry_type": "DOCKER_HUB", #Registry type, DOCR and DOCKER_HUB are supported "registry": "nginxdemos", # DockerHub only, the registry name "repository": "hello", # repository name "tag": "0.2" # tag name }, }]
name
- name of the component in App Specrepository
- name of the DOCR repository with the following format- registry.digitalocean.com//tag
- tag of the image provided while pushing to DOCR (by default latest tag is used). We suggest always use unique tag value)
token
- doctl authentication token (generate token by following this instructions
Update DigitalOcean container image configuration of single component in App Spec example
DigitalOcean App Platform Auto-deploy with same app spec. example
- App Platform Guided App Spec Declaration
- App Platform App Spec Blog
- App Platform App Spec Components
Because image manifests are cached in different regions, there may be a maximum delay of one hour between pushing to a tag that already exists in your registry and being able to pull the new image by tag. This may happen, for example, when using the :latest tag. To avoid the delay, use:
- Unique tags (other than :latest)
- SHA hash of Github commit
- SHA hash of the new manifest
- Install gomock with
go install github.com/golang/mock/mockgen@v1.6.0
go generate ./...
to generate the mocks
This GitHub Action and associated scripts and documentation in this project are released under the MIT License.