CodeBlanks Logo Icon CodeBlanks

Summary - Actions basics

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-latest

Practice 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

terminal
# Workflow adını belirle

# Başlangıç olaylarını tanımla

# İşleri ve çalışma ortamını belirle

Sample solution

terminal
name: Basic CI

on:
  push:
  pull_request:

jobs:
  test:
    runs-on: ubuntu-latest

Expected 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

Question
name: Basic CI

on:
  push:
  pull_request:

jobs:
  test:
    runs-on: ____
Answer
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

All lessons in Intermediate

20 Intermediate final

  1. Branch management
  2. Rebase
  3. Conflict
  4. PR flow