GitHub Action to deploy docker images.
GitHub Action to deploy docker images.
Example workflow:
name: Deploy
on:
push:
branches:
- master
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: ambimax/action-docker-deploy@v2
with:
image: containous/whoami
host: "*.preview.company.com"
digitalocean_token: "${{ secrets.DIGITALOCEAN_TOKEN }}"
digitalocean_cluster: "preview"
# Add a comment to the commit with the deployed URL.
enable_commit_comment: true
github_token: ${{ secrets.GITHUB_TOKEN }}
Deploy a container to a digitalocean kubernetes cluster
- uses: ambimax/action-docker-deploy@v2
with:
image: containous/whoami
host: ${{ secrets.EXAMPLE_HOST }}
digitalocean_token: ${{ secrets.EXAMPLE_DIGITALOCEAN_TOKEN }}
digitalocean_cluster: ${{ secrets.EXAMPLE_DIGITALOCEAN_CLUSTER }}
enable_commit_comment: true
github_token: ${{ secrets.GITHUB_TOKEN }}
Undeploy a container from a digitalocean kubernetes cluster
- uses: ambimax/action-docker-deploy@v2
with:
image: containous/whoami
host: ${{ secrets.EXAMPLE_HOST }}
digitalocean_token: ${{ secrets.EXAMPLE_DIGITALOCEAN_TOKEN }}
digitalocean_cluster: ${{ secrets.EXAMPLE_DIGITALOCEAN_CLUSTER }}
undeploy: "true"
Deploy a container to a digitalocean kubernetes cluster
- uses: ambimax/action-docker-deploy@v2
with:
image: ${{ secrets.EXAMPLE_DOCKER_IMAGE }}
host: ${{ secrets.EXAMPLE_HOST }}
port: ${{ secrets.EXAMPLE_PORT }}
digitalocean_token: ${{ secrets.EXAMPLE_DIGITALOCEAN_TOKEN }}
digitalocean_cluster: ${{ secrets.EXAMPLE_DIGITALOCEAN_CLUSTER }}
docker_secret: ${{ secrets.EXAMPLE_PULL_SECRET }}
Undeploy a container from a digitalocean kubernetes cluster
- uses: ambimax/action-docker-deploy@v2
with:
image: ${{ secrets.EXAMPLE_DOCKER_IMAGE }}
host: ${{ secrets.EXAMPLE_HOST }}
port: ${{ secrets.EXAMPLE_PORT }}
digitalocean_token: ${{ secrets.EXAMPLE_DIGITALOCEAN_TOKEN }}
digitalocean_cluster: ${{ secrets.EXAMPLE_DIGITALOCEAN_CLUSTER }}
docker_secret: ${{ secrets.EXAMPLE_PULL_SECRET }}
undeploy: "1"
Deploy a container to a digitalocean kubernetes cluster with environment variables
- uses: ambimax/action-docker-deploy@v2
with:
image: containous/whoami
release: env-test
host: ${{ secrets.EXAMPLE_HOST }}
env: WHOAMI_NAME
digitalocean_token: ${{ secrets.EXAMPLE_DIGITALOCEAN_TOKEN }}
digitalocean_cluster: ${{ secrets.EXAMPLE_DIGITALOCEAN_CLUSTER }}
env:
WHOAMI_NAME: ${{ secrets.EXAMPLE_WHOAMI_NAME }}
Undeploy a container from a digitalocean kubernetes cluster with environment variables
- uses: ambimax/action-docker-deploy@v2
with:
image: containous/whoami
release: env-test
host: ${{ secrets.EXAMPLE_HOST }}
env: WHOAMI_NAME
digitalocean_token: ${{ secrets.EXAMPLE_DIGITALOCEAN_TOKEN }}
digitalocean_cluster: ${{ secrets.EXAMPLE_DIGITALOCEAN_CLUSTER }}
undeploy: yes
env:
WHOAMI_NAME: ${{ secrets.EXAMPLE_WHOAMI_NAME }}
Deploy a container to a digitalocean kubernetes cluster with custom values from a file
- uses: ambimax/action-docker-deploy@v2
with:
image: containous/whoami
host: ${{ secrets.EXAMPLE_HOST }}
digitalocean_token: ${{ secrets.EXAMPLE_DIGITALOCEAN_TOKEN }}
digitalocean_cluster: ${{ secrets.EXAMPLE_DIGITALOCEAN_CLUSTER }}
values_file: ./values.yml
Undeploy a container to a digitalocean kubernetes cluster with custom values from a file
- uses: ambimax/action-docker-deploy@v2
with:
image: containous/whoami
host: ${{ secrets.EXAMPLE_HOST }}
digitalocean_token: ${{ secrets.EXAMPLE_DIGITALOCEAN_TOKEN }}
digitalocean_cluster: ${{ secrets.EXAMPLE_DIGITALOCEAN_CLUSTER }}
values_file: ./values.yml
undeploy: "true"
Deploy a container on a digitalocean kubernetes cluster with a specific namespace
- uses: ambimax/action-docker-deploy@v2
with:
image: containous/whoami
host: ${{ secrets.EXAMPLE_HOST }}
digitalocean_token: ${{ secrets.EXAMPLE_DIGITALOCEAN_TOKEN }}
digitalocean_cluster: ${{ secrets.EXAMPLE_DIGITALOCEAN_CLUSTER }}
enable_commit_comment: true
github_token: ${{ secrets.GITHUB_TOKEN }}
namespace: kube-system
Undeploy a container on a digitalocean kubernetes cluster with a specific namespace
- uses: ambimax/action-docker-deploy@v2
with:
image: containous/whoami
host: ${{ secrets.EXAMPLE_HOST }}
digitalocean_token: ${{ secrets.EXAMPLE_DIGITALOCEAN_TOKEN }}
digitalocean_cluster: ${{ secrets.EXAMPLE_DIGITALOCEAN_CLUSTER }}
enable_commit_comment: true
github_token: ${{ secrets.GITHUB_TOKEN }}
namespace: kube-system
undeploy: "true"
Name | Description | Required | Default |
---|---|---|---|
image | The image to deploy. | true | |
host | The host under which to deploy the image. If the host contains "*" it will be replaced by the full deployment name. |
true | |
env | A comma separated list of environment variable names to provide to the container. |
false | |
app | The name of the app. If no name is given it will be set to the docker image name (without leading namespaces). |
false | |
release | The name of the release. If no release is given it will be set to the docker image tag. |
false | |
namespace | The namespace to deploy into. If no namespace is given, it defaults to default . |
false | |
port | The port to expose from the image. | false | 80 |
docker_secret | The secret to use to pull images. | false | |
digitalocean_token | The digitalocean token, if you are deploying to digitalocean. | false | |
digitalocean_cluster | The name of the digitalocean_cluster if you are deploying to digitalocean. | false | |
undeploy | Whether or not to undeploy instead of deploy the container. | false | false |
enable_commit_comment | Whether or not to add a comment to the commit with the deployment information. | false | false |
github_token | The github token used to create the commit comment. | false | |
values_file | Path to a yaml file that will be used to provide configuration values for the internal helm chart. See the ./k8s/helm for more information. | false |
Clone this repository
git clone https://github.com/ambimax/action-docker-deploy
Install all dependencies
yarn
Build the project
yarn build
Once done, commit the dist folder to a new feature branch and create a pull request.
NOTE This project makes heavy use of code generation. You really only want to edit action.yml, src/index.ts and the test folder. Sections in this readme marked with <!-- region:xyz start -->...<!-- region:xyz end --> are autogenerated.