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

# Deploy with GitHub Actions | Agent guide

> Validate Deepline Plays in pull requests and publish approved revisions after merge.

[Human guide: task steps and agent prompt →](https://deepline.com/docs/human/sdk-v2/github-deployments.md)

Use this workflow when your organization cannot install the Deepline GitHub
App, or uses GitHub Enterprise Server. For GitHub.com, start with
[Deploy from GitHub](https://deepline.com/docs/sdk-v2/git-deploys.md).

Actions checks out the source and runs `deepline plays deploy` on its runner.
Pull requests validate source; production jobs deploy a selected directory.

## Prepare the source and manifest

Commit one default-exported async Play function per `*.play.ts` file. The file
name supplies its default Play name; optional `export const config` can set a
name, description, and bindings. Keep the files under `plays/` for this example.
Store provider credentials and active Play secrets in Deepline. Keep customer
data, credentials, and live provider responses out of GitHub.

Commit `plays/deepline.json`:

```json theme={"languages":{"custom":["/languages/deepline-prompt.json"]}}
{
  "plays": ["**/*.play.ts"],
  "monitors": []
}
```

Globs are relative to that directory. The validation job checks every tracked
`*.play.ts` below it; deployment selects the manifest's complete Play set.
Keep those scopes aligned if you narrow the manifest.

Directory deployment cannot deploy Monitor files. Keep `monitors: []` for this
workflow. Use [linked-repository deployment](https://deepline.com/docs/plays/set-up-a-monitor.md#deploy-monitor-files-from-git)
or a separate reviewed Monitor deployment for those files.

## Pin the CLI and configure credentials

Select a tested CLI version. You can inspect the current release with:

```bash theme={"languages":{"custom":["/languages/deepline-prompt.json"]}}
npm view deepline version
```

Save the selected version in the repository variable `DEEPLINE_CLI_VERSION`.
Configure these Actions secrets:

| Secret | Scope | Purpose |
| - | - | - |
| `DEEPLINE_CHECK_API_KEY` | Repository | Validate against an isolated non-production org. |
| `DEEPLINE_API_KEY` | Protected `deepline-production` environment | Deploy to the production org. |

Restrict `deepline-production` to `main`. Add environment reviewers if deployment
requires approval. Each key must identify the intended org. Configure its
provider connections and every active Play secret declared by the source.
Use non-production provider credentials in the validation org.

This example supports pull requests from the same repository. GitHub withholds
repository secrets from forks. Review fork commits on a maintainer-controlled
branch; never expose secrets through `pull_request_target`. Keep production
keys out of pull-request jobs. Do not select an org from pull-request input.

## Add the workflow

Create `.github/workflows/deepline.yml` with the complete workflow below.
Change `PLAY_DIRECTORY` and `PLAY_MANIFEST` for a different source root or filename.

```yaml theme={"languages":{"custom":["/languages/deepline-prompt.json"]}}
name: Deploy Deepline Plays

on:
  pull_request:
  push:
    branches: [main]
  workflow_dispatch:

permissions:
  contents: read

env:
  DEEPLINE_HOST_URL: https://code.deepline.com
  DEEPLINE_CLI_VERSION: ${{ vars.DEEPLINE_CLI_VERSION }}
  PLAY_DIRECTORY: plays
  PLAY_MANIFEST: deepline.json

jobs:
  validate:
    name: Validate Plays
    if: github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name == github.repository
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
      - uses: actions/setup-node@v4
        with:
          node-version: '22'
      - name: Install Deepline
        shell: bash
        run: |
          set -euo pipefail
          : "${DEEPLINE_CLI_VERSION:?Set the DEEPLINE_CLI_VERSION repository variable}"
          npm install --global "deepline@${DEEPLINE_CLI_VERSION}"
      - name: Check Plays
        shell: bash
        env:
          DEEPLINE_API_KEY: ${{ secrets.DEEPLINE_CHECK_API_KEY }}
        run: |
          set -euo pipefail
          found=0
          while IFS= read -r -d '' play; do
            found=1
            echo "Checking ${play}"
            deepline plays check "${PLAY_DIRECTORY}/${play}"
          done < <(git -C "${PLAY_DIRECTORY}" ls-files -z -- '*.play.ts')
          test "${found}" -eq 1

  publish:
    name: Publish Plays
    if: github.event_name != 'pull_request' && github.ref == 'refs/heads/main'
    needs: validate
    runs-on: ubuntu-latest
    environment: deepline-production
    concurrency:
      group: deepline-production
      cancel-in-progress: false
    steps:
      - uses: actions/checkout@v4
        with:
          fetch-depth: 0
      - uses: actions/setup-node@v4
        with:
          node-version: '22'
      - name: Install Deepline
        shell: bash
        run: |
          set -euo pipefail
          : "${DEEPLINE_CLI_VERSION:?Set the DEEPLINE_CLI_VERSION repository variable}"
          npm install --global "deepline@${DEEPLINE_CLI_VERSION}"
      - name: Publish Plays
        shell: bash
        env:
          DEEPLINE_API_KEY: ${{ secrets.DEEPLINE_API_KEY }}
        run: |
          set -euo pipefail
          deepline plays deploy "$PLAY_DIRECTORY" \
            --manifest "$PLAY_MANIFEST" \
            --repo "$GITHUB_REPOSITORY" \
            --ref "$GITHUB_REF" \
            --commit "$GITHUB_SHA"
```

Pull requests check source without publishing or starting a Play run. A merge
or approved manual run on `main` deploys the selected directory. Changed Plays
are validated and registered before their live revisions are promoted together.
Unchanged Plays are skipped.

The CLI builds files from the checkout. `--repo`, `--ref`, and `--commit` record
provenance; they do not fetch or select source. Directory deployment has no
branch-head guard. This workflow serializes production jobs; the caller still
owns which commit is deployed.

## Verify the deployment

1. Open a pull request that changes a Play.
2. Confirm **Validate Plays** passes.
3. Merge the reviewed change.
4. Confirm **Publish Plays** succeeds.
5. Inspect the deployment receipt and warnings:

```bash theme={"languages":{"custom":["/languages/deepline-prompt.json"]}}
deepline plays deployments
DEPLOYMENT_ID="deployment-id-from-the-list-or-workflow"
deepline plays deployments "$DEPLOYMENT_ID"
```

Failed or cancelled deployments exit non-zero. `succeeded_with_warnings` and
`superseded` exit zero; an exit code alone does not establish publication.
Confirm the intended source commit and live revision:

```bash theme={"languages":{"custom":["/languages/deepline-prompt.json"]}}
PLAY_NAME="saved-play-name-from-the-deployment"
deepline plays versions --name "$PLAY_NAME"
deepline describe "$PLAY_NAME"
```

Deployment details mark **SDK updated** when a new SDK changes the artifact
without a source/import change. Test runtime behavior with approved synthetic
input in an internal or test org. Keep normal production publication in CI.

## Roll back and restore source agreement

Copy the previous immutable revision ID from `plays versions`, then promote it:

```bash theme={"languages":{"custom":["/languages/deepline-prompt.json"]}}
PLAY_NAME="saved-play-name-from-the-deployment"
REVISION_ID="previous-revision-id-from-plays-versions"
deepline plays set-live "$PLAY_NAME" --revision-id "$REVISION_ID"
```

Read the live version again. Revert or fix GitHub source so the next deployment
agrees with the restored revision.

## A Play a linked repository owns

Directory deployment can replace a linked repository's live Play. The receipt
warns about the owning repository; its next production push replaces that
version. Choose one source of truth before enabling this workflow:

* Keep the link and deploy reviewed source through it.
* To retire the link, get its ID from `deepline git list`, then unlink it:

```bash theme={"languages":{"custom":["/languages/deepline-prompt.json"]}}
LINK_ID="id-from-deepline-git-list"
deepline git unlink "$LINK_ID"
deepline git get "$LINK_ID"
```

Unlinking releases repository ownership and leaves live Plays running.
Deleting a Play file also leaves its live Play running. Decommission schedules,
webhooks, callers, and any related Monitors separately.

[Build a Play](https://deepline.com/docs/sdk-v2/plays.md) covers authoring. Continue with
[Integrate a Play into your app](https://deepline.com/docs/sdk-v2/production-integration.md) for production callers.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.