# Deployment

#### GitHub Actions

This project includes two GitHub Actions workflows, located in `.github/workflows/api.yml` and `.github/workflows/ui.yml`, each responsible for building, pushing, and deploying Docker images for the API and UI components. In both files we have only 2 jobs: build and deployment.

***

**API Workflow (`api.yml`)**

* **Workflow Name**: `[App] Your Name`
* **Triggers**: Executes on any push to the `develop` branch (can be production or stage, whatever you set) that includes changes in the `api/` directory.
* **Environment**: Staging
* **Key Steps**:
  1. **Checkout**: Clones the repository.
  2. **Docker Hub Login**: Logs into Docker Hub using stored credentials.
  3. **Docker Setup**: Sets up Docker Buildx for multi-platform builds.
  4. **Build and Push**: Builds and pushes the Docker image using `Dockerfile_api` with the tag `staging`.
  5. **Deployment**: Triggers a POST request to initiate the deployment of the newly built image on the staging server.

***

**UI Workflow (`ui.yml`)**

* **Workflow Name**: `[App] Intercode Common UI Staging`
* **Triggers**: Executes on any push to the `develop` branch that includes changes in the `ui/` directory.
* **Environment**: Staging
* **Key Steps**:
  1. **Checkout**: Clones the repository.
  2. **Docker Hub Login**: Logs into Docker Hub using stored credentials.
  3. **Docker Setup**: Sets up Docker Buildx for multi-platform builds.
  4. **Build and Push**: Builds and pushes the Docker image using `Dockerfile_ui` with the tag `staging` and necessary environment variables for the UI.
  5. **Deployment**: Triggers a POST request to initiate the deployment of the newly built image on the staging server.

Each workflow is designed for efficient staging deployment, with automated Docker image building and pushing, and deployment triggered through HTTP requests to a configured endpoint.

For correct work you should set necessary secrets and variables in your repository settings. In settings tab find Security module click on Secrets and variables and choose actions. To secrets add next variables with your values:

* DOCKER\_HUB\_ACCESS\_TOKEN
* DOCKER\_HUB\_USERNAME

Then on tab "Variables" add next variables with your values:

* DEPLOYMENT\_HOST
* DEPLOYMENT\_PASSWORD
* DEPLOYMENT\_USERNAME

You can create Docker Hub account and necessary variables following next official guide:

{% embed url="<https://docs.docker.com/docker-hub/quickstart/>" %}

To run deployment type next command in your production server terminal:

```yaml
curl https://gist.github.com/YOUR-REPOSITORY-NAME/install.sh 
--ui-subdomain YOUR-DOMAIN --api-subdomain YOUR-DOMAIN
```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://intercode.gitbook.io/intercode-saas-kit/basics/deployment.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
