---
metadata:
  - name: generator
    content: Diplodoc Platform v5.50.6
alternate:
  - https://sourcecraft.dev/portal/docs/en/sourcecraft/operations/gh-actions.md
  - https://sourcecraft.dev/portal/docs/ru/sourcecraft/operations/gh-actions.md
---
> **Documentation Index:** Fetch the complete configuration index at https://sourcecraft.dev/portal/docs/en/llms.txt

# Using GitHub Actions in SourceCraft CI/CD

<!-- source: en/_includes/sourcecraft/configuration-tip.md -->
{% note tip %}

You can set up and view repository configurations in the SourceCraft interface under <svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="none" viewBox="0 0 16 16"><path fill="currentColor" fill-rule="evenodd" d="M7.199 2H8.8a.2.2 0 0 1 .2.2c0 1.808 1.958 2.939 3.524 2.034a.2.2 0 0 1 .271.073l.802 1.388a.2.2 0 0 1-.073.272c-1.566.904-1.566 3.164 0 4.069a.2.2 0 0 1 .073.271l-.802 1.388a.2.2 0 0 1-.271.073C10.958 10.863 9 11.993 9 13.8a.2.2 0 0 1-.199.2H7.2a.2.2 0 0 1-.2-.2c0-1.808-1.958-2.938-3.524-2.034a.2.2 0 0 1-.272-.073l-.8-1.388a.2.2 0 0 1 .072-.271c1.566-.905 1.566-3.165 0-4.07a.2.2 0 0 1-.073-.27l.801-1.389a.2.2 0 0 1 .272-.072C5.042 5.138 7 4.007 7 2.199c0-.11.089-.199.199-.199M5.5 2.2c0-.94.76-1.7 1.699-1.7H8.8c.94 0 1.7.76 1.7 1.7a.85.85 0 0 0 1.274.735 1.7 1.7 0 0 1 2.32.622l.802 1.388c.469.813.19 1.851-.622 2.32a.85.85 0 0 0 0 1.472 1.7 1.7 0 0 1 .622 2.32l-.802 1.388a1.7 1.7 0 0 1-2.32.622.85.85 0 0 0-1.274.735c0 .939-.76 1.7-1.699 1.7H7.2a1.7 1.7 0 0 1-1.699-1.7.85.85 0 0 0-1.274-.735 1.7 1.7 0 0 1-2.32-.622l-.802-1.388a1.7 1.7 0 0 1 .622-2.32.85.85 0 0 0 0-1.471 1.7 1.7 0 0 1-.622-2.32l.801-1.389a1.7 1.7 0 0 1 2.32-.622A.85.85 0 0 0 5.5 2.2m4 5.8a1.5 1.5 0 1 1-3 0 1.5 1.5 0 0 1 3 0M11 8a3 3 0 1 1-6 0 3 3 0 0 1 6 0" clip-rule="evenodd"/></svg> **Repository settings** in the <svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="none" viewBox="0 0 16 16"><path fill="currentColor" fill-rule="evenodd" d="m13.874 8.25-2.72 4.712a.5.5 0 0 1-.434.25H5.28a.5.5 0 0 1-.433-.25L2.127 8.25a.5.5 0 0 1 0-.5l2.72-4.712a.5.5 0 0 1 .433-.25h5.44a.5.5 0 0 1 .433.25l2.72 4.712a.5.5 0 0 1 0 .5m1.3-1.25a2 2 0 0 1 0 2l-2.72 4.712a2 2 0 0 1-1.733 1H5.28a2 2 0 0 1-1.732-1L.828 9a2 2 0 0 1 0-2l2.72-4.712a2 2 0 0 1 1.732-1h5.44a2 2 0 0 1 1.732 1zM9.5 8a1.5 1.5 0 1 1-3 0 1.5 1.5 0 0 1 3 0M11 8a3 3 0 1 1-6 0 3 3 0 0 1 6 0" clip-rule="evenodd"/></svg> **Configurations** section. Learn more in [this article](https://sourcecraft.dev/portal/docs/en/sourcecraft/operations/configuration-edit.md).

{% endnote %}
<!-- endsource: en/_includes/sourcecraft/configuration-tip.md -->

<!-- source: en/_includes/sourcecraft/ci-cd/gh-actions-intro.md -->
SourceCraft [CI/CD](https://sourcecraft.dev/portal/docs/en/sourcecraft/concepts/ci-cd.md) workflows support [GitHub Actions](https://docs.github.com/en/actions).

_GitHub Actions_ is GitHub's native CI/CD platform that enables you to create, set up, and run workflows to automate builds, testing, deployment, and other tasks within the software lifecycle as well as reuse these workflows across repositories.

You can integrate both custom and public GitHub Actions available in the [GitHub Marketplace](https://github.com/marketplace?type=actions) into your SourceCraft CI/CD [workflows](https://sourcecraft.dev/portal/docs/en/sourcecraft/concepts/ci-cd.md#workflows).

To work with GitHub Actions in SourceCraft, you do not need to create a GitHub account or use the GitHub interface.
<!-- endsource: en/_includes/sourcecraft/ci-cd/gh-actions-intro.md -->

<!-- source: en/_includes/sourcecraft/ci-cd/gh-gl-cloud-workers.md -->
{% note warning %}

Only [cloud workers](https://sourcecraft.dev/portal/docs/en/sourcecraft/concepts/workers.md#cloud-workers) support running GitHub Actions or GitLab pipelines in SourceCraft CI/CD.

{% endnote %}
<!-- endsource: en/_includes/sourcecraft/ci-cd/gh-gl-cloud-workers.md -->

For more information, see [Integration with GitHub Actions in SourceCraft](https://sourcecraft.dev/portal/docs/en/sourcecraft/concepts/gh-actions.md).

To use GitHub Actions in SourceCraft CI/CD:
1. If you do not have a repository yet, [create](https://sourcecraft.dev/portal/docs/en/sourcecraft/operations/repo-create.md) one.
1. [Add](https://sourcecraft.dev/portal/docs/en/sourcecraft/operations/add-file-repo.md) the `.sourcecraft/ci.yaml` file with the [CI/CD process configuration](https://sourcecraft.dev/portal/docs/en/sourcecraft/ci-cd-ref/index.md) to the `main` repository branch. 
1. To enable GitHub Actions in SourceCraft CI/CD, use a [cube](https://sourcecraft.dev/portal/docs/en/sourcecraft/concepts/ci-cd.md#cubes) with the `action` and, optionally, `with` parameters:

    <!-- source: en/_includes/sourcecraft/ci-cd/gh-actions-template.md -->
    ```yaml
    on:
      push:
        - workflows: [test-workflow]
          filter:
            branches: ["main"]

    workflows:
      test-workflow:
        tasks:
          - name: demo-github-action-ci
            cubes:
              - name: run-github-action
                action: <GitHub_Action_name>@<version>
                with:
                  <GitHub_Action_parameter_1>: <value_1>
                  <GitHub_Action_parameter_2>: <value_2>
                  ...
    ```
    <!-- endsource: en/_includes/sourcecraft/ci-cd/gh-actions-template.md -->

    {% cut "Example of a CI/CD process with GitHub Actions" %}

    <!-- source: en/_includes/sourcecraft/ci-cd/gh-actions-example.md -->
    The example below shows a `.sourcecraft/ci.yaml` configuration file that describes the following steps:

    * Obtaining an IAM token for Yandex Cloud using a [service connection](https://sourcecraft.dev/portal/docs/en/sourcecraft/operations/service-connections.md).
    * Installing [Docker Buildx](https://github.com/docker/buildx) in the [worker](https://sourcecraft.dev/portal/docs/en/sourcecraft/concepts/workers.md) environment using the [Docker Setup Buildx](https://github.com/marketplace/actions/docker-setup-buildx) GitHub Action.
    * Authenticating with [Yandex Cloud Registry](https://yandex.cloud/en/docs/cloud-registry/) using the [Docker Login](https://github.com/marketplace/actions/docker-login) GitHub Action and the Yandex Cloud IAM token.
    * Building a Docker image from the `Dockerfile` located at the repository root and pushing it to Cloud Registry using the [Build and push Docker images](https://github.com/marketplace/actions/build-and-push-docker-images) GitHub Action.

    ```yaml
    tokens:
      # Token name (can be any).
      <token_name>:
        # Name of the service connection to Yandex Cloud
        service_connection: <service_connection_name>
        # Requested access scope:
        # org: All repositories
        # repo: Specific repository
        # ref: Branch or tag
        scope: repo

    workflows:
      test-workflow:
        tasks:
          - name: test-gh-actions-task
            cubes:
              # The cube exchanges the SourceCraft token for the Yandex Cloud IAM token
              # and saves it to the `IAM_TOKEN` variable within the `outputs` section.
              - name: get-iam-token
                env:
                  ID_TOKEN: ${{ tokens.<token_name>.id_token }}
                  YC_SA_ID: ${{ tokens.<token_name>.service_account_id }}
                image: cr.yandex/sourcecraft/yc-iam:latest

              # The cube installs and configures the Docker Buildx utility.
              - name: setup-buildx
                action: docker/setup-buildx-action@v3.11.1

              # The cube authenticates with Yandex Cloud Registry 
              # using the IAM token.
              - name: login
                action: docker/login-action@v3.5.0
                with:
                  registry: cr.yandex/<registry_ID>
                  username: iam
                  # Substitute to the `outputs` section the name of the IAM token cube,
                  # e.g., `get-iam-token`.
                  password: ${{ cubes.<IAM_token_cube_name>.outputs.IAM_TOKEN }}

              # The cube builds the Docker image from the Dockerfile and pushes it to the registry in
              # Cloud Registry.
              - name: build-and-push
                action: docker/build-push-action@v6.18.0
                with:
                  context: .
                  file: Dockerfile
                  platforms: linux/amd64
                  tags: |
                    cr.yandex/<registry_ID>/image-name:latest
                  push: true

    on:
      push: test-workflow
    ```
    <!-- endsource: en/_includes/sourcecraft/ci-cd/gh-actions-example.md -->

    {% endcut %}

    This CI process will start automatically after committing changes to the `main` branch.

1. Check the CI process:
    1. Under <svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="none" viewBox="0 0 16 16"><path fill="currentColor" fill-rule="evenodd" d="M1.22 11.22a.75.75 0 1 0 1.06 1.06l3.75-3.75a.75.75 0 0 0 0-1.06L2.28 3.72a.75.75 0 0 0-1.06 1.06L4.44 8zm13.03 1.28a.75.75 0 0 0 0-1.5h-6.5a.75.75 0 0 0 0 1.5z" clip-rule="evenodd"/></svg> **CI/CD** on the repository page, go to <svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="none" viewBox="0 0 16 16"><g clip-path="url(#svg-qbvx0kaf__a)"><path fill="currentColor" fill-rule="evenodd" d="M4.61 2.503a6.47 6.47 0 0 1 3.383-.984 6.48 6.48 0 0 1 4.515 1.77l-.004-.559a.75.75 0 1 1 1.5-.013l.021 2.5a.75.75 0 0 1-.743.756l-2.497.022a.75.75 0 1 1-.013-1.5l.817-.007a4.98 4.98 0 0 0-3.583-1.469 4.97 4.97 0 0 0-2.602.756.75.75 0 0 1-.795-1.272m9.097 8.716a6.5 6.5 0 0 0 .84-3.422.75.75 0 1 0-1.5.053 4.97 4.97 0 0 1-.646 2.63 4.98 4.98 0 0 1-3.064 2.37l.403-.712a.75.75 0 0 0-1.306-.738l-1.229 2.173a.75.75 0 0 0 .283 1.022l2.176 1.23a.75.75 0 1 0 .739-1.305l-.487-.275a6.48 6.48 0 0 0 3.79-3.026m-11.258.099a6.47 6.47 0 0 0 2.544 2.438.75.75 0 0 0 .704-1.325 4.97 4.97 0 0 1-1.955-1.875 4.98 4.98 0 0 1-.52-3.838l.415.705a.75.75 0 1 0 1.292-.762L3.66 4.511a.75.75 0 0 0-1.027-.266L.481 5.513a.75.75 0 1 0 .761 1.293l.483-.284a6.48 6.48 0 0 0 .724 4.796" clip-rule="evenodd"/></g><defs><clipPath id="svg-qbvx0kaf__a"><path fill="currentColor" d="M0 0h16v16H0z"/></clipPath></defs></svg> **CI/CD**.
    1. Open a running workflow.

        On the page that opens, you will see workflow tasks, cubes (task steps), as well as statuses and execution results.
    1. In the <svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="none" viewBox="0 0 16 16"><path fill="currentColor" fill-rule="evenodd" d="M12 3.5H4A1.5 1.5 0 0 0 2.5 5v6A1.5 1.5 0 0 0 4 12.5h8a1.5 1.5 0 0 0 1.5-1.5V5A1.5 1.5 0 0 0 12 3.5M4 2a3 3 0 0 0-3 3v6a3 3 0 0 0 3 3h8a3 3 0 0 0 3-3V5a3 3 0 0 0-3-3zm.47 8.53a.75.75 0 0 1 0-1.06L5.94 8 4.47 6.53a.75.75 0 0 1 1.06-1.06l2 2a.75.75 0 0 1 0 1.06l-2 2a.75.75 0 0 1-1.06 0M8.75 9.5a.75.75 0 0 0 0 1.5h2.5a.75.75 0 0 0 0-1.5z" clip-rule="evenodd"/></svg> **Logs** tab, expand the GitHub Actions cube and view its results.
    1. Wait for the workflow to complete.

#### Useful links {#see-also}

* [Integration with GitHub Actions in SourceCraft](https://sourcecraft.dev/portal/docs/en/sourcecraft/concepts/gh-actions.md)
* [Setting up CI/CD to deploy an application to Yandex Serverless Containers using GitHub Actions](https://sourcecraft.dev/portal/docs/en/sourcecraft/tutorials/ci-cd-sourcecraft-github-actions.md)
* [GitLab pipelines in the SourceCraft CI/CD](https://sourcecraft.dev/portal/docs/en/sourcecraft/concepts/gl-pipelines.md)
* [Using GitLab pipelines in the SourceCraft CI/CD](https://sourcecraft.dev/portal/docs/en/sourcecraft/operations/gl-pipelines.md)
* [Continuous integration and continuous deployment in SourceCraft](https://sourcecraft.dev/portal/docs/en/sourcecraft/concepts/ci-cd.md)
* [Service connections SourceCraft](https://sourcecraft.dev/portal/docs/en/sourcecraft/concepts/service-connections.md)
