Build and Deploy from GitHub Action
Introduction
In this page you will learn how to build and deploy your apps in Docker Deploy from a Github Action, so your app is re-deployed automatically when you push new code.
Pre-requirements
This guide assumes that you already have a deployment in Docker Deploy that runs. If that is not the case, you can read the guide on how to delpoy your app.
Secrets for deployment
Access token
Access tokens let you perform actions in Docker Deploy without the need of logging in. This is useful to automate processes, like deploying your app.
To create an access token, go to Account -> Access Tokens.
Then pick a name to identify your new Token and hit Create.
Save this value somewhere, we will need it later and you will not be able to see it again later.
Registry credentials
If you want to deploy a private image, you have to publish it in the docker deploy registry. To deploy on it, you will need your registry credentials. You can see them in your app page, by hitting Show registry credentials:
Keep this values too, as we will also need them to deploy.
Save the secrets in Github
Now we need to save the Access token and the registry password.
- Go to the Github repository of your app
- Settings
- Secrets and variables -> Actions
- New repository secret
- Chose a name, like
DD_TOKEN
, and paste the value of your token in the Secret field. - If your image is private, you also need to save the registry password, so create another secret called for example
DD_REGISTRY_PASS
- Paste the value and save.
At the end, you should have two secrets:
Create an action
- Go to Actions in your repository
- Create a new one
- Paste this and replace with your values
- YOUR_REGISTRY_USERNAME: you see it when your press Show registry credentials in your deployment page
- YOUR_REGISTRY_NAMESPACE: you see it when your press Show registry credentials in your deployment page
- YOUR_APP_NAME: A name for your docker image
- YOUR_APP_ID: Is in the URL of your deployment page
dockerdeploy.cloud/dashboard/deployments/HERE
Thats it! Now, every time you push to main, you image will be built and deployed into Docker Deploy.