Summary - Actions basics
- Git course
- Intermediate
- Lesson 68/82
- 5 min
Combine the workflow parts to set up a simple CI flow.
Combine a basic CI workflow
To create a CI workflow, the name, triggering events, and jobs are combined. The YAML file is saved in the .github/workflows/ directory and read by GitHub Actions. This allows the same workflow to start for both push and pull_request events.
name: Basic CI
on:
push:
pull_request:
jobs:
test:
runs-on: ubuntu-latestPractice Create a complete CI workflow
Complete the basic-ci.yml file. Set its name to Basic CI. Make it run on both push and pull_request events. Define a job named test that runs in an Ubuntu environment.
Starter code
# Workflow adını belirle
# Başlangıç olaylarını tanımla
# İşleri ve çalışma ortamını belirleSample solution
name: Basic CI
on:
push:
pull_request:
jobs:
test:
runs-on: ubuntu-latestExpected output
Basic CI push pull_request test ubuntu-latest
Questions and answers
Review the lesson questions together with their answers. To test yourself, solve the lesson interactively.
1 Which structure defines both push and pull request events in a basic CI workflow?
- Two separate jobs under jobs
- Two events under on Correct answer
- Two events under name
- Two environments under runs-on
Explanation: Both triggers are defined under the on field. The jobs field specifies the tasks to execute.
2 Complete the workflow execution environment
name: Basic CI
on:
push:
pull_request:
jobs:
test:
runs-on: ____
name: Basic CI
on:
push:
pull_request:
jobs:
test:
runs-on: ubuntu-latest
Explanation: ubuntu-latest specifies that the test job runs in an Ubuntu environment on GitHub Actions.
3 CI workflow components
| Term | Meaning |
|---|---|
.github/workflows/ |
Workflow files directory |
name |
Workflow name |
on |
Triggering events |
jobs |
Jobs to execute |