Build and deploy containers to CaaS via GitHub actions
Overview
We’ve developed a public GitHub action that allows you to deploy your containers to Gcore Container as a Service directly via GitHub workflows. This action can be found in the deploy-container repository repository and in the Marketplace under GitHub Actions.
GitHub Actions
The principle of Actions is described in the detailed GitHub documentation. You create a YAML file in your repository’s .github/workflows directory. This YAML file contains the code that is executed during a workflow run. Other key components of GitHub Actions include:
- Events, which trigger workflows (e.g., pull_request)
- Jobs, which define the steps that will be executed on the runner or actions that will be run
- Actions, which allow you to automate, customize, and execute your software development workflows directly in your repository
- Runners, which are servers where workflows are executed
How to use the Gcore action
1. In the .github/workflows/ directory, create a file with the .yml extension.
2. Add the following content to your .yml file:
Complete the required and optional fields per the below.
Required fields :
api-token
is a permanent API token that authenticates the GitHub action to Gcore API.project-id
is the ID of the Gcore project where the container should be deployed. You can use the list projects API request to retrieve this.region-id
is the ID of the region where the container should be deployed. This can be obtained using the list regions API request.name
is the name of the container to be deployed.image
in the name of the container image to be deployed (e.g., docker.io/nginx:latest.)
Optional fields :
listening-port
is the port on which the container will be listening for network connections. The default value is80
.description
is a custom description of the container.envs
is the list of newline-separated key-value pairs to set as environment variables. For example:
flavor
is the container flavor that determines the amount of memory and CPU allocated to each container instance. The default value is80mCPU-128MB
.timeout
is the duration in seconds that elapses before scaling down container instances. The default value is60
.scale-min
is the minimum number of instances to run. When set to0
, the container will scale down to zero running instances when it receives no traffic for the duration oftimeout
. The default value is1
.scale-max
is the maximum number of instances to run. The value must be greater than or equal to scale-min. The default value is1
.is-disabled
is the field (boolean) that controls the state of the container (on or off.) Whentrue
is set, the container is disabled; any running instances are shut down. The default value isfalse
.is-api-key-auth
is the field (boolean) that enables API key authentication for the container endpoint address. You can create and assign API keys to the container in the Gcore Customer Portal. Whentrue
is set, API keys are enabled. The default value isfalse
.pull-secret
is the name of the private registry credentials to use when fetching the container image. The credentials must already be configured in the Gcore Customer Portal.
3. Create a .secrets file with your GCLOUD_API_TOKEN
value obtained from the Customer Portal.
4. Create a .vars file with your GCLOUD_API_URL
, GCLOUD_PROJECT
and GCLOUD_REGION
values.
The Gcore action has the following output elements:
address
is the endpoint address of your container.status
is the status of your container (e.g., Pending, Deploying, Ready, or Error.)status-message
is the last message associated with the current container status. This can be useful for troubleshooting deployment issues.