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). - On the repository:
git:GetRepositoryandgit:PushRepositoryto commit the file;ci:ListRuns,ci:GetRunandci:GetRunLogsto see the run and its log. For the console's check of the file before you commit it,ci:ListRunson 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.
Open the repository, then open its CI tab.
Choose Add a workflow.
For File path, enter
.dcloud/workflows/hello.yml.For Workflow file, enter:
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."
Choose Commit to main.
In Commit this workflow, keep or change the Commit message, then choose Commit.
The console returns to the CI tab, where the run appears.
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 mainStep 2: Watch the run
- 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. - Select the job
hello.
The run goes from Queued through Provisioning and Running to Succeeded, and the
job's log shows Hello from CI.
dcloud ci runs list repo-id
dcloud ci runs get run-id
dcloud ci jobs logs job-idTake 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.
Not available in Console. This tutorial removes the file with Git.
git rm .dcloud/workflows/hello.yml
git commit -m "Remove the hello workflow"
git push origin mainThe run you made stays in the run list.