# Convert a workflow

Translate a GitHub Actions, GitLab CI or other CI file into the native workflow format, checked by the parser before you commit it.

A GitHub Actions file does not need converting: left in `.github/workflows/`, it runs as it is
(see [Run GitHub Actions workflows](run-github-actions-workflows.md)). Convert one when you want it
in the native format, or bring a GitLab CI file across.

The conversion is done by the AI model of your installation. What comes back has been through the
same parser a push runs: an invalid first answer gets one repair round, kept only if it parses.
Anything without an equivalent is left out and listed as `# note:` comments at the top of the
result. Read the result before you commit it.

## Prerequisites

- `ci:ListRuns` on all of CI (`rn:ews::<organization id>:ci:*`). In the console, without it
  **Convert** says "Your permissions do not allow converting a file here. Ask an administrator for
  ci:ListRuns."
- An AI provider configured for your installation.
- In the console, the **Add a workflow** page: `git:GetRepository` on the repository (without it
  the page is not found), `git:PushRepository` (without it the page shows an access-denied notice)
  and `ci:ListRuns` on the repository to open its **CI** tab.

## Convert the file

**Console**
1. Open the repository, then open its **CI** tab.
2. Choose **Add a workflow**.
3. Under **Convert from GitHub Actions or GitLab CI**, for **Where it comes from**, choose
   **GitHub Actions**, **GitLab CI** or **Something else**.
4. For **The file you are converting**, paste the file.
5. Choose **Convert**.

The result replaces **Workflow file**, the check below it says whether it parses, and
**What the conversion could not carry over** lists the notes. Commit it as in
[Add a workflow](add-a-workflow.md).

**CLI**
```sh
dcloud ci workflows convert --from gitlab --source "$(cat .gitlab-ci.yml)" --filename .gitlab-ci.yml
```

**API**
```http
POST /ci/api/workflows/convert
{ "from": "github", "source": "name: CI\non: push\njobs:\n  test:\n    runs-on: ubuntu-latest\n    steps:\n      - run: make test\n", "filename": "ci.yml" }
```

## Result

`200` with `{ yaml, valid, issues, notes }`: the file in the native format, whether it parses, the
parser's issues when it does not, and what was left out. Nothing is committed.

- `503` "No AI provider is configured for this installation. …" when the installation has none.
- `502` "The AI provider did not answer: …".

## Do it in your own AI session

The instructions the conversion uses are public at `/docs/workflows/prompt.md` on the console's
host, with no sign-in. Paste them into the AI session you have open on the repository, where the
model can also read your Dockerfile and scripts, then paste your old file after them. Check the
result with [Add a workflow](add-a-workflow.md) before you commit it.

## Related

- [Add a workflow](add-a-workflow.md)
- [Workflow syntax](/docs/workflows)
- `ci.workflows.convert` · `dcloud ci workflows convert`
