# Getting started

Add a workflow to a repository, watch its first run and read its log.

You add a native-format workflow that prints a line on every push to `main`, push it, and read
the run's log. Replace my-repo with your repository's name and repo-id with its
id.

## Prerequisites

- A repository whose default branch is `main` (see [Create a repository](/docs/git/guide/create-a-repository)).
- On the repository: `git:GetRepository` and `git:PushRepository` to commit the file;
  `ci:ListRuns`, `ci:GetRun` and `ci:GetRunLogs` to see the run and its log. For the console's
  check of the file before you commit it, `ci:ListRuns` on all of CI
  (`rn:ews::<organization id>:ci:*`).
- For the CLI tab, a clone of the repository and the CLI signed in.

## Step 1: Add the workflow

The run uses a platform machine: you pay for its job minutes from now on, for every run of this
file.

**Console**
1. Open the repository, then open its **CI** tab.
2. Choose **Add a workflow**.
3. For **File path**, enter `.dcloud/workflows/hello.yml`.
4. For **Workflow file**, enter:

   ```yaml
   name: Hello
   on:
     push:
       branches: [main]
   jobs:
     hello:
       steps:
         - run: echo "Hello from CI"
   ```

   Under the file the page says "This file parses. It runs when its triggers match."

5. Choose **Commit to main**.
6. In **Commit this workflow**, keep or change the **Commit message**, then choose **Commit**.

The console returns to the **CI** tab, where the run appears.

**CLI**
```sh
mkdir -p .dcloud/workflows
cat > .dcloud/workflows/hello.yml <<'EOF'
name: Hello
on:
  push:
    branches: [main]
jobs:
  hello:
    steps:
      - run: echo "Hello from CI"
EOF
git add .dcloud/workflows/hello.yml
git commit -m "Add a workflow"
git push origin main
```

## Step 2: Watch the run

**Console**
1. On the repository's **CI** tab, open the run. It is titled with the commit's message, and the
   line under it begins `Hello #`, the run's number in the repository, then `: Push`.
2. Select the job `hello`.

The run goes from **Queued** through **Provisioning** and **Running** to **Succeeded**, and the
job's log shows `Hello from CI`.

**CLI**
```sh
dcloud ci runs list repo-id
dcloud ci runs get run-id
dcloud ci jobs logs job-id
```

Take the run's `id` from the list, then a job's `id` from `ci runs get`. The log holds the line
`Hello from CI`.

## Clean up

Delete the workflow file, so no later push starts a run.

**Console:** not available. This tutorial removes the file with Git.

**CLI**
```sh
git rm .dcloud/workflows/hello.yml
git commit -m "Remove the hello workflow"
git push origin main
```

The run you made stays in the run list.

## Next steps

- [Workflows and runs](workflows-and-runs.md)
- [Workflow syntax](/docs/workflows)
- [Run GitHub Actions workflows](run-github-actions-workflows.md)
