# GitHub Actions for custom models
URL: https://docs.datarobot.com/en/docs/classic-ui/mlops/deployment/custom-models/custom-model-workshop/custom-model-github-action.html

> The custom models action manages custom inference models and deployments in DataRobot via GitHub CI/CD workflows.

# GitHub Actions for custom models

> [!NOTE] Availability information
> GitHub Actions for custom models is a premium feature. Contact your DataRobot representative or administrator for information on enabling the feature.

The custom models action manages custom inference models and their associated deployments in DataRobot via GitHub CI/CD workflows. These workflows allow you to create or delete models and deployments and modify settings. Metadata defined in YAML files enables the custom model action's control over models and deployments. Most YAML files for this action can reside in any folder within your custom model's repository. The YAML is searched, collected, and tested against a schema to determine if it contains the entities used in these workflows. For more information, see the [custom-models-action repository](https://github.com/datarobot-oss/custom-models-action).

## GitHub Actions quickstart

This quickstart example uses a [Python Scikit-Learn model template](https://github.com/datarobot/datarobot-user-models/tree/master/model_templates/python3_sklearn) from the [datarobot-user-model repository](https://github.com/datarobot/datarobot-user-models/tree/master/model_templates). To set up a custom models action that will create a custom inference model and deployment in DataRobot from a custom model repository in GitHub, take the following steps:

1. In the.github/workflowsdirectory of your custom model repository, create a YAML file (with any filename) containing the following: 123456789101112131415161718192021222324252627282930313233name:Workflow CI/CDon:pull_request:branches:[master]push:branches:[master]# Allows you to run this workflow manually from the Actions tabworkflow_dispatch:jobs:datarobot-custom-models:# Run this job on any action of a PR, but skip the job upon merging to the main branch. This# will be taken care of by the push event.if:${{ github.event.pull_request.merged != true }}runs-on:ubuntu-lateststeps:-uses:actions/checkout@v3with:fetch-depth:0-name:DataRobot Custom Models Stepid:datarobot-custom-models-stepuses:datarobot-oss/custom-models-action@v1.6.0with:api-token:${{ secrets.DATAROBOT_API_TOKEN }}webserver:https://app.datarobot.com/branch:masterallow-model-deletion:trueallow-deployment-deletion:true Configure the following fields:
2. Commit the workflow YAML file and push it to the remote. After you complete this step, any push to the remote (or merged pull request) triggers the action.
3. In the folder for your DataRobot custom model, add a model definition YAML file (e.g.,model.yaml) containing the following YAML and update the field values according to your model's characteristics: user_provided_model_id:user/model-unique-id-1target_type:Regressionsettings:name:My Awesome GitHub Model 1 [GitHub CI/CD]target_name:Grade 2014version:# Make sure this is the environment ID is in your system.# This one is the '[DataRobot] Python 3 Scikit-Learn Drop-In' environmentmodel_environment_id:5e8c889607389fe0f466c72d Configure the following fields:
4. In any directory in your repository, add a deployment definition YAML file (with any filename) containing the following YAML: user_provided_deployment_id:user/my-awesome-deployment-iduser_provided_model_id:user/model-unique-id-1 Configure the following fields:
5. Commit these changes and push to the remote, then:

> [!WARNING] Warning
> Creating two commits (or merging two pull requests) in quick succession can result in a `ResourceNotFoundError`. For example, you add a model definition with a training dataset, make a commit, and push to the remote. Then, you immediately delete the model definition, make a commit, and push to the remote. The training data upload action may begin after model deletion, resulting in an error. To avoid this scenario, wait for an action's execution to complete before pushing new commits or merging new pull requests to the remote repository.

## Access commit information in DataRobot

After your workflow creates a model and a deployment in DataRobot, you can access the commit information from the model's version info and the deployment's overview:

**Model version info:**
In the
Model Registry
, click
Custom Model Workshop
.
On the
Models
tab, click a GitHub-sourced model from the list and then click the
Versions
tab.
Under
Manage Versions
, click the version you want to view the commit for.
Under
Version Info
, find the
Git Commit Reference
and then click the commit hash (or commit ID) to open the commit that created the current version.

[https://docs.datarobot.com/en/docs/images/pp-cus-model-github2.png](https://docs.datarobot.com/en/docs/images/pp-cus-model-github2.png)

**Registered model info:**
In the
Model Registry
, on the
Registered Models
tab, click a GitHub-sourced model package from the list.
On the
Info
tab, review the model information provided by your workflow, find the
Git Commit Reference
, and then click the commit hash (or commit ID) to open the commit that created the current model package.

[https://docs.datarobot.com/en/docs/images/pp-cus-model-github4.png](https://docs.datarobot.com/en/docs/images/pp-cus-model-github4.png)

**Deployment overview:**
In the
Deployments
inventory, click a GitHub-sourced deployment from the list.
On the deployment's
Overview
tab, review the model and deployment information provided by your workflow.
In the
Content
group box, find the
Git Commit Reference
and click the commit hash (or commit ID) to open the commit that created the deployment.

[https://docs.datarobot.com/en/docs/images/pp-cus-model-github1.png](https://docs.datarobot.com/en/docs/images/pp-cus-model-github1.png)

---
