Add a workflow
Write a workflow file, check it with the same parser a push runs, and commit it to the repository.
A workflow is a file in the repository: committing it is a push like any other, refused by the same branch protection rules. Every key of the native format is in Workflow syntax.
Prerequisites
git:PushRepositoryon the repository to commit the file. In the console, without it the Add a workflow page shows an access-denied notice.- In the console, also
git:GetRepositoryon the repository (without it the page is not found) andci:ListRunson the repository to open its CI tab. Withoutgit:PushRepositorythe tab does not offer Add a workflow. - To check a file, in the console as through the CLI or the API,
ci:ListRunson all of CI (rn:ews::<organization id>:ci:*). Without it the console's check reads "Could not check this file: …"; you can still commit the file. - A repository that is not archived, a mirror or still importing: those refuse every commit.
Write, check and commit the file
- Open the repository, then open its CI tab.
- Choose Add a workflow.
- Under Start from a template, choose Test on every pull request, Build and push an image or Build on macOS; or convert a file you have (see Convert a workflow); or write the file yourself.
- For File path, keep the proposed path or enter another
.ymlor.yamlfile directly in.dcloud/workflows/(or.ews/workflows/). The console adds native-format files only; commit a GitHub-syntax file with Git. - Edit the file under Workflow file. Below it the page says "This file parses. It runs when its triggers match.", or lists the problems.
- Choose Commit to main (the repository's default branch).
- (Optional) For Commit message, enter a message.
- Choose Commit. For a file with problems the button reads Commit anyway; every run of such a file is refused until they are fixed.
The console opens the CI tab. If you leave the page before committing, what you wrote is kept for the next time.
Check the file, then commit and push it with Git:
dcloud ci workflows validate --source "$(cat .dcloud/workflows/ci.yml)"
git add .dcloud/workflows/ci.yml && git commit -m "Add CI" && git pushFor a GitHub-syntax file, add --path .github/workflows/ci.yml so it is checked as GitHub
Actions.
POST /ci/api/workflows/validate
{ "source": "name: CI\non:\n push:\n branches: [main]\njobs:\n test:\n steps:\n - run: make test\n" }The answer is 200 with { valid, issues }, also for an invalid file; each issue names the key
and, where it can, the line. A path under .github/workflows/ checks the file as GitHub Actions.
Result
The file is on the default branch. It starts a run from the next event its triggers match; a push trigger on that branch matches the commit that added it. A file that does not parse never blocks a push, but starts no run.
The console's Add a workflow is offered on a repository's CI tab when the tab lists runs, or when the repository has no workflow yet.