Mostafa Elhavary

๐Ÿงฉ Workflow Components in GitHub Actions

Lesson 3 of 8

Course outline ยท lesson 3 of 8
Finished 0 of 8 lessonsAsk on WhatsApp

๐Ÿงฉ Workflow Components in GitHub Actions

What Is a Workflow?

๐Ÿ”น A workflow is a set of Actions that run automatically in response to specific events in the repository.
๐Ÿ”น Workflows are defined in YAML files and stored in the folder:
.github/workflows


โœจ Core Components of a Workflow

1๏ธโƒฃ name: a descriptive name for the workflow.

2๏ธโƒฃ on: the events (triggers) that start the workflow, such as:

  • push

  • pull_request

  • schedule (Cron Jobs)

3๏ธโƒฃ jobs: a set of jobs. Each job contains steps that run in a specific runner environment.


โš™๏ธ Components of a Job

โ–ถ๏ธ name: the name of the job.
โ–ถ๏ธ runs-on: the execution environment (for example: ubuntu-latest, windows-latest, macos-latest).
โ–ถ๏ธ steps: the list of steps the job runs (running commands or using ready-made Actions).


๐Ÿ“„ Example workflow.yml File

name: Testing Python Code Workflow

on:
  push:
    branches:
      - main
  pull_request:
    branches:
      - main

jobs:
  build:
    name: Construir y Testear
    runs-on: ubuntu-24.04
    
    steps:
      - name: Checkout del cรณdigo
        uses: actions/checkout@v4
        
      - name: Configurar Python 3.11
        uses: actions/setup-python@v2
        with:
          python-version: '3.11'
        
      - name: Instalar dependencias
        run: |
          python -m pip install --upgrade pip setuptools wheel
          pip install -r ./requirements.txt
        
      - name: Ejecutar pruebas
        run: |
          python -m unittest discover -s tests

๐Ÿ”Ž Explaining the Example

  • Trigger: starts when a push or pull_request happens on the main branch.

  • Job: named build, and it runs on an Ubuntu 24.04 environment.

  • Steps:

    • โœ… Checkout code โ†’ fetches the code from the repository.

    • โœ… Setup Python โ†’ installs Python 3.11.

    • โœ… Install dependencies โ†’ installs the required libraries.

    • โœ… Run tests โ†’ runs the unit tests.

โžก๏ธ This scenario lets you automate building and testing your projects (such as Odoo add-ons) on every change to the main branch.


๐Ÿ’ก Where Does the Workflow Run?

  • All workflows run on a Runner (a temporary server provided by GitHub).

  • The runner can be a virtual server or even a Docker container.

  • As soon as the workflow finishes, this server is destroyed.


๐Ÿš€ What Can We Do Next?

Using this runner, you can connect to your Odoo server (VPS or Cloud) to run automated tasks such as:

  • ๐Ÿ”„ Updating the code (repositories).

  • ๐Ÿ’พ Creating backups.

  • ๐Ÿ—„๏ธ Upgrading the database.

Sign in to save your progress

Sign in with your Google account. Your course progress is saved to your account and follows you to any device.