Setting up CI/CD in SourceCraft to deploy an application to Yandex Serverless Containers using GitHub Actions
In this tutorial, you will set up a CI/CD process
Warning
To create a service connection, you need the Organization owner (organization-manager.organizations.owner) role
To set up CI/CD to deploy an application to Serverless Containers from aSourceCraft repository using GitHub Actions:
- Create a service account.
- Create a registry.
- Create a repository.
- Create a service connection.
- Configure CI/CD.
- Test CI/CD.
- Make sure the container has been created.
If you no longer need the resources you created, delete them.
Required paid resources
The infrastructure support cost includes:
- Fee for storing the created Docker images (see Container Registry pricing.
- Fee for the number of container invocations, computing resources allocated to the application, and outgoing traffic (see Serverless Containers pricing.
Create a service account
You will use this service account to upload Docker images to registries in Yandex Container Registry and deploy containers to Serverless Containers.
-
Log in to the Yandex Cloud management console
. -
On the left side of the screen, click the line with the name of the folder where you want to deploy your container.
-
In the list of services, select Identity and Access Management.
-
Click Create service account.
-
In the Name field, specify
github-action. -
Click
Add role and select these roles:container-registry.images.pusher: To work with Docker images in a registry.serverless-containers.editor: To manage the container.iam.serviceAccounts.user: To enable specifying a service account when creating a container revision. This account will be used to pull the Docker image from the registry.
-
Click Create.
-
Create a service account:
yc iam service-account create \ --name github-action --folder-name <folder_name>Result:
id: ajeab0cnib1p******** folder_id: b0g12ga82bcv******** created_at: "2025-10-03T09:44:35.989446Z" name: github-action -
Assign the service account the following roles for the folder:
-
iam.serviceAccounts.user: To enable specifying a service account when creating a container revision. This account will be used to pull the Docker image from the registry:yc resource-manager folder add-access-binding <folder_name> \ --service-account-name github-action \ --role iam.serviceAccounts.user \ --folder-name <folder_name> -
serverless-containers.editor: To manage the container:yc resource-manager folder add-access-binding <folder_name> \ --service-account-name github-action \ --role serverless-containers.editor \ --folder-name <folder_name> -
container-registry.images.pusher: To work with Docker images in the registry:yc resource-manager folder add-access-binding <folder_name> \ --service-account-name github-action \ --role container-registry.images.pusher \ --folder-name <folder_name>
-
-
Create a service account named
github-action. To do this, use the create REST API method for the ServiceAccount resource or the ServiceAccountService/Create gRPC API call. -
Assign the service account these roles for the current folder:
iam.serviceAccounts.user: To enable specifying a service account when creating a container revision. This account will be used to pull the Docker image from the registry.serverless-containers.editor: To manage the container.container-registry.images.pusher: To work with Docker images in the registry.
To do this, use the setAccessBindings REST API method for the Folder resource or the FolderService/SetAccessBindings gRPC API call.
Create a registry
The registry in Container Registry will house the application’s Docker image.
- In the management console
, select Container Registry. - Click Create registry.
- Specify
github-actionas the registry name. - Click Create registry.
- Save the new registry’s ID, you will need it later.
Create a registry named github-action:
yc container registry create --name github-action
Result:
id: crpd50616s9a********
folder_id: b1g88tflru0e********
name: github-action
status: ACTIVE
created_at: "2025-10-03T10:34:06.601Z"
Save the new registry’s ID, you will need it later.
Use the create REST API method for the Registry resource or the RegistryService/CreateRegistryRequest gRPC API call.
Save the new registry’s ID, you will need it later.
Create a repository
The repository will be created from the yc-ci-cd-serverlessDockerfile, auxiliary files for creating the Docker image, and the CI/CD process settings.
-
Open the service home page
. -
In the left-hand panel, click
Create repository. -
In the window that opens, select Blank repository.
-
Under Your new repository details:
-
In the Owner field, select the organization
in which you created the Yandex Cloud service account. -
In the Name field, specify a name for the repository.
The name must be unique within the organization. The name may contain the following ASCII characters
: lowercase and uppercase Latin letters, numbers, commas, hyphens, and underscores.The address to access the repository at is displayed below the name.
-
Optionally, in the Description field, enter a description for the repository.
-
-
Under Repository template, click Browse templates, select the yc-ci-cd-serverless
template, and click Use template.To view the template contents, click Preview.
The template contains:
- .sourcecraft/ci.yaml
file with a pre-installed configuration of the CI/CD process that runs when a commit is created and does the following:- Obtains a Yandex Cloud IAM token using a service connection named
default-service-connection. - Installs Docker Buildx
in the worker environment using the Docker Setup Buildx GitHub Action. - Authenticates with Container Registry using the Docker Login
GitHub Action and the Yandex Cloud IAM token. - Builds a Docker image from the
Dockerfilelocated at the repository root and pushes it to Container Registry using the Build and Push Docker images GitHub Action. - Deploys a container in Serverless Containers from the built Docker image.
- Obtains a Yandex Cloud IAM token using a service connection named
- Dockerfile
, index.html , and docker/nginx/conf.d/default.conf with the configuration of a container with a static web app based on Nginx .
- .sourcecraft/ci.yaml
-
Click Create repository.
Create a service connection
-
Open the SourceCraft home page
. -
Navigate to the
Organizations tab. -
Select the organization where you created the Yandex Cloud service account.
-
On the organization page, in the
Settings section, go to the Service connections section. -
Click New service connection.
-
Under Basic information, specify the service connection name,
default-service-connection. -
Under Scope, select the repository you created earlier.
-
Under Yandex Cloud settings, select:
-
Folder where you previously deployed the cloud infrastructure and assigned a role to the service account.
-
github-actionservice account.Tip
To re-request the list of clouds, folders, and service accounts from Yandex Cloud, click
Synchronize. This can be of use if alongside creating a service connection you also created a folder or service account.
-
-
Click Create service connection.
Wait for the operation to complete. The page that opens will display the service connection details.
A Yandex Identity and Access Management workload identity federation will be automatically created in Yandex Cloud.
To view the parameters of the new OIDC provider, click the federation name under
Workload identity federation.
Configure CI/CD
-
Open the SourceCraft home page
. -
On the
Home tab, under Your craftspace, navigate to Repositories. -
Select the repository you created earlier.
-
Select
.sourcecraft/ci.yaml. -
In the top-right corner, click
Edit. -
In the
YC_DOCKER_REGISTRY_URIparameter, specify the ID of the registry you previously created:YC_DOCKER_REGISTRY_URI: cr.yandex/<registry_ID> -
In the top-right corner, click Commit changes.
-
Commit:
- Enter a message about the changes.
- Under Commit branch, select Commit directly to the branch: main.
- Under After commit action, select Just commit.
- Click Commit changes.
After saving the changes, demo-service-connection-workflow will start.
Test CI/CD
- Open the SourceCraft home page
. - On the
Home tab, under Your craftspace, navigate to Repositories. - Select the repository you created earlier.
- Under
Code on the repository page, go to CI/CD. - In the list of automation executions, you will see a new execution. Wait for the status to change to
Success.
Make sure the container has been created
-
In the management console
, select Serverless Containers. -
In the list, you should see
demo-serverless-container1; select it.Under Revisions, you should now see the container revision with the same timestamp as the CI/CD process execution.
Run this command:
yc serverless container revision list \
--container-name demo-serverless-container1
Where --container-name is the container name specified in .sourcecraft/ci.yaml.
Result:
+----------------------+----------------------+--------------------------------------------------------+---------------------+
| ID | CONTAINER ID | IMAGE | CREATED AT |
+----------------------+----------------------+--------------------------------------------------------+---------------------+
| bba27hejd69a******** | bba83i1mrb5s******** | cr.yandex/yc/serverless/demo-serverless-container1 | 2025-10-04 09:38:14 |
+----------------------+----------------------+--------------------------------------------------------+---------------------+
Use the listRevisions REST API method for the Container resource or the RegistryService/CreateRegistryRequest gRPC API call.
Delete the resources you created
To stop paying for the resources you created:
See also
- Configuring CI/CD between SourceCraft and Yandex Cloud Functions
- Configuring a service connection to Yandex Cloud in SourceCraft
- Integration with GitHub Actions in SourceCraft
- serverless-functions
repository in SourceCraft - yc-ci-cd-serverless
repository in SourceCraft