Workflow file
- Git course
- Intermediate
- Lesson 66/82
- 4 min
Learn the structure of a workflow YAML file.
What is a workflow file?
GitHub Actions workflows are defined using YAML files located in the .github/workflows/ directory of a repository. Each file specifies the workflow name, the event that starts it, and the tasks it performs. These files commonly use the .yml or .yaml extension.
.github/
workflows/
tests.ymlThe basic structure of a YAML file
YAML is a readable configuration format that uses indentation to create a hierarchy. In a workflow file, name defines the workflow name, on defines the starting event, and jobs defines the tasks to perform. Nested fields use spaces for indentation, which must remain consistent.
name: Test Workflow
on: push
jobs:
test:
runs-on: ubuntu-latestPractice Write your first workflow file
Complete the contents of tests.yml. Set the workflow name to Basic CI, set the triggering event to push, and configure a job named test to run on ubuntu-latest.
Starter code
# Workflow adını yaz
# Başlangıç olayını yaz
# İş adını ve çalışma ortamını yazSample solution
name: Basic CI
on: push
jobs:
test:
runs-on: ubuntu-latestExpected output
Basic CI push test ubuntu-latest
Questions and answers
Review the lesson questions together with their answers. To test yourself, solve the lesson interactively.
1 In which directory should a workflow YAML file be located?
- .github/workflows/ Correct answer
- public/workflows/
- .git/workflows/
- src/actions/
Explanation: GitHub Actions workflow files are located in the .github/workflows directory at the repository root.
2 Define the workflow name
name: ____
on: push
jobs:
test:
runs-on: ubuntu-latest
name: Test Workflow
on: push
jobs:
test:
runs-on: ubuntu-latest
Explanation: The name field defines the displayed name of the workflow.
3 Workflow fields
| Term | Meaning |
|---|---|
name |
Workflow name |
on |
Triggering event |
jobs |
Tasks to perform |
runs-on |
Execution environment |