Fundamental concepts of GitHub Actions - Week 1

Saul HernandezSaul Hernandez
3 min read

In this post, I'll be sharing my journey through the GitHub Actions Bootcamp.

The purpose is to share all the knowledge learned during this bootcamp.

I'll be following the Github Actions Bootcamp. The main goal of this free initiative is to help developers to dominate GitHub Actions and prepare for the official GitHub Actions Certification.

In this bootcamp, I'll learn how to create and maintain automated workflows, develop custom actions, and manage GitHub Actions implementations in an enterprise environment.

What are GitHub Actions?

It's a tool that help us to automatise tasks related with our repository.

  • CI (Continuous Integration): Software development process where developers integrate new code into the codebase throughout the development cycle

  • CD (Continuous Deployment): Software release process that uses automated testing to verify whether changes in a base code are correct and stable for immediate and autonomous deployment into a production environment.

How it works?

GitHub Actions allow us create workflows that will be executed by specific triggers like Push, Merge, Pull Request (PR), and so on.

Use Cases

This can be used to automate the software development process. This helps the development team focus on writing code instead of performing manual and repetitive tasks.

Some common use cases include:

  • Building the project

  • Running tests

  • Send notifications (Slack, E-mails, Notion, Asana, etc)

  • Performing security scans

Key concepts

Workflows: A set of automated processes defined in a YAML file located in the .github/workflows directory.

Triggers: Events that allow the execution of a workflow, defined using the on keyword.

Jobs: Independent units of work within a workflow. By default, this are executed in parallel, and each job runs in a runner. Jobs are defined using the jobs: keyword.

Steps: Individual tasks within a Job. A job can have multiple steps, which are executed sequentially in the same runner. Steps can use environment variables. We can define it using the steps: keyword. Each step can include name, uses, and/or run.

Runners: Environments (Virtual Machines) where jobs are executed. Github provides updated OS images such as Ubuntu, Windows, MacOs. We use runs-on: keyword to specify the runner.

Example

name: CI Pipeline

on: [push] # Trigger the workflow on every push event

jobs:
    build-and-test:
        runs-on: ubuntu-latest # Use the latest Ubuntu runner
        steps:
            - uses: actions/checkout@v4         # Check out the repository code
            - run: npm install                  # Install project dependencies
            - run: npm test                     # Execute tests
            - run: echo "Everything is ready"   # Custom message

Conclusion

This week, we explored the exciting world of GitHub Actions! We started with the fundamental concepts, understanding what GitHub Actions are and why they're so valuable for automating our workflows. We also learn about the core concepts and how to define them in YAML configuration files.

0
Subscribe to my newsletter

Read articles from Saul Hernandez directly inside your inbox. Subscribe to the newsletter, and don't miss out.

Written by

Saul Hernandez
Saul Hernandez

Continuously learning and growing in software development, with experience in web, mobile, and SQL. I love sharing my journey and exploring innovation in tech! ๐Ÿš€