> ## Documentation Index
> Fetch the complete documentation index at: https://docs.gcore.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Build and deploy containers to CaaS via GitHub Actions

## Overview

Gcore provides a public GitHub action for deploying containers to [Gcore Container as a Service](/cloud/caas) directly via GitHub workflows. The action is available in the [deploy-container repository](https://github.com/gcore-github-actions/deploy-container) and in the GitHub Marketplace under [GitHub Actions](https://github.com/marketplace/actions/deploy-to-gcore-container-as-a-service).

## GitHub Actions

The principle of Actions is described in the [detailed GitHub documentation](https://docs.github.com/en/actions/learn-github-actions/understanding-github-actions). Workflows are defined in a YAML file in the repository's *.github/workflows* directory. The 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 automate, customize, and execute software development workflows in a repository
* **Runners**, which are servers where workflows are executed

## Gcore action setup

1\. In the *.github/workflows/* directory, create a file with the *.yml* extension.

2\. Add the following content to the *.yml* file:

```yaml theme={null}
name: Deploy

on:
  workflow_dispatch:

jobs:
  deploy:
    name: deploy
    runs-on: ubuntu-latest

    steps:
      - id: deploy
        uses: gcore-github-actions/deploy-container@v1
        with:
          api-token: ${{ secrets.GCLOUD_API_TOKEN }}
          project-id: ${{ vars.GCLOUD_PROJECT }}
          region-id: ${{ vars.GCLOUD_REGION }}
          name: my-container
          image: nginx:latest

      - name: Use output
        run: echo "${{ steps.deploy.outputs.address }}"
```

Complete the required and optional fields as described below.

**Required fields:**

* `api-token` is an [API token](/account-settings/api-tokens) that authenticates the GitHub action to Gcore API.
* `project-id` is the ID of the Gcore project where the container should be deployed. Use the [list projects](/api-reference/cloud/projects/list-projects) API request to retrieve it.
* `region-id` is the ID of the region where the container should be deployed. Use the [list regions](/api-reference/cloud/regions/list-regions) API request to obtain it.
* `name` is the name of the container to be deployed.
* `image` is the name of the container image to be deployed. Specify the full registry path (e.g., `docker.io/nginx:latest`) or the short form (e.g., `nginx:latest`).

**Optional fields:**

* `listening-port` is the port on which the container will be listening for network connections. The default value is `80`.
* `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:

```yaml theme={null}
with:
   envs: |
     FOO=bar
     BAZ=biz
```

* `flavor` is the container flavor that determines the amount of memory and CPU allocated to each container instance. The default value is `80mCPU-128MB`.
* `timeout` is the duration in seconds that elapses before scaling down container instances. The default value is `60`.
* `scale-min` is the minimum number of instances to run. When set to `0`, the container will scale down to zero running instances when it receives no traffic for the duration of `timeout`. The default value is `1`.
* `scale-max` is the maximum number of instances to run. The value must be greater than or equal to scale-min. The default value is `1`.
* `is-disabled` is the field (boolean) that controls the state of the container (on or off.) When `true` is set, the container is disabled; any running instances are shut down. The default value is `false`.
* `is-api-key-auth` is the field (boolean) that enables API key authentication for the container endpoint address. API keys are created and assigned to the container in the [Gcore Customer Portal](https://portal.gcore.com). When `true` is set, API keys are enabled. The default value is `false`.
* `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 Customer Portal.

3\. In the GitHub repository settings, go to **Secrets and variables** > **Actions** and add `GCLOUD_API_TOKEN` as a repository secret with the value of the [API token](https://portal.gcore.com/accounts/settings/api-tokens).

4\. In the same **Variables** tab, add `GCLOUD_PROJECT` with the Gcore project ID and `GCLOUD_REGION` with the Gcore region ID.

The Gcore action has the following output elements:

* `address` is the endpoint address of the deployed container.
* `status` is the container status (e.g., *Pending*, *Deploying*, *Ready*, or *Error*).
* `status-message` is the last message associated with the current container status, which can help with troubleshooting deployment issues.
