Lädt...

🔧 Streamlining Development Workflow: Automating Tasks with GitHub Actions


Nachrichtenbereich: 🔧 Programmierung
🔗 Quelle: dev.to

Github Actions Icon

During the entire development process, from code to deployment, we encounter many repeated processes: updating snapshots, running unit tests, deploying to staging, completing production deployments... all these types of processes will inevitably become part of every task developed, without exception.

And like everything in life, it doesn't make sense to do something repetitive when you can automate it. Moreover, it doesn't make sense to work on improving other people's experiences without making our own lives easier, saving our time.

There are MANY tools that help automate your development process (a practice known as CI/CD), and one of them is directly tied to the main platform for those who work with software: GitHub.

Therefore, in this article, we will learn a bit more about GitHub Actions, so we can create, customize, and share automated workflows directly in the repository.

What is GitHub Actions?

GitHub Actions is a CI/CD service provided by GitHub. It allows you to automate various tasks in software development, such as testing, building, deployment, and much more. GitHub Actions is event-based, where each action is triggered by specific events, such as code pushes, pull request creations, or predefined schedules.

CI/CD interface

In this example above, we have an Express project with a MongoDB database. Here, as soon as we open a pull request, the pipeline defined with the help of GitHub Actions will run all the tests created in the API, in different versions of Node and the MongoDB driver (first and second number in parentheses, respectively).

Workflows

Workflows are the main units of automation in GitHub Actions. They are defined through YAML files that can be configured to respond to specific events or execute schedules. The file specifies the actions to be executed, in which environment, and in what order. These workflows can be easily configured and customized to meet the specific needs of a project.

Workflow example

Actions

Actions are the reusable components that make up a workflow. They are the fundamental building blocks of GitHub Actions. Actions can be created by the community or the development team and shared with other users. There are pre-made actions available on the GitHub Marketplace, as well as other custom actions that can be developed internally. Actions can be combined to create complex and customized workflows.

*Creating Our Workflow
*

  • In a project, let's start by going to the "Actions" tab and clicking on "set up a workflow yourself";

Github Actions Interface

  • Now, we can define the details of the YAML file on the next screen, that is, the definition of our workflow. On the right, we can see that GitHub Actions has a marketplace with several well-known and pre-made workflows (consider using this option to find a useful one and enhance it);

Github Actions Interface

  • We can define the events that will trigger the workflow. For example, to trigger the workflow whenever a push occurs on the main branch, we can do something like this:
on:
  push:
    branches:
      - main

Then, we add the steps that will be executed in the workflow. For example, let's add a step to install the project's dependencies and another to run the tests. In this case, we would do:

on:
  push:
    branches:
      - main

jobs:
  build:
    runs-on: ubuntu-latest

    steps:
    - name: Checkout code
      uses: actions/checkout@v2

    - name: Install dependencies
      run: npm install

    - name: Run tests
      run: npm test

Where:

  • jobs defines the tasks to be executed in the workflow. You can have multiple jobs within a workflow, allowing different actions to be executed simultaneously;
  • build is the name given to the job. You can give a descriptive name to each job in your workflow, such as "build", "test", "deploy", among others;
  • runs-on specifies the environment in which the job will be executed. In this example, we are using "ubuntu-latest", which is an Ubuntu operating system image in the most recent environment available on GitHub Actions. There are other options available, such as Windows and macOS;
  • steps defines the individual steps that will be executed within the job;
  • name is the name given to each step. It serves to identify the step in the workflow execution log, making it easier to understand what happens at each step;
  • uses specifies a marketplace action that will be used in the step. In the given example, we are using the actions/checkout@v2 action, which allows checking out the repository's source code; run executes commands or scripts in the step. In the given example, we are using the npm install command to install the project's dependencies and npm test to run the tests.

The definition of the YAML file can also be done directly in your development environment; I just exemplified it with the more user-friendly approach.

GitHub Actions usage examples

The test example is the most basic, but there are countless ways to leverage the power of GitHub Actions to automate tasks in a development workflow. Some common examples include:

  • Continuous deployment to a production environment after a pull request approval;
  • Automatic generation of documentation from the source code;
  • Notifying the team about changes or issues in the repository;
  • Performing routine tasks such as database cleaning or backup creation.

Github Actions Pros

  • Seamless integration with GitHub: As a native GitHub feature, GitHub Actions integrates perfectly with the existing workflow and allows direct automation in the repository;
  • Flexible configuration: Workflows can be easily configured and customized to fit the specific requirements of the project;
  • Wide variety of actions: The GitHub Marketplace has a wide range of pre-made actions that can be used, covering various technologies and use cases;
  • Efficient collaboration: Automated workflows facilitate collaboration among team members.

Simple, right? Did you like the tip? Leave your suggestion or comment and see you next time!

...

🔧 Streamlining Development Workflow: Automating Tasks with GitHub Actions


📈 68.71 Punkte
🔧 Programmierung

🎥 Automating Repetitive Tasks with GitHub Actions - AMER & EMEA


📈 38.65 Punkte
🎥 Video | Youtube

🔧 Automating Dev.to Article Publishing with GitHub Actions and Node.js: A Workflow Overview


📈 38.25 Punkte
🔧 Programmierung

🔧 Automating your workflow with GitHub Actions


📈 38.25 Punkte
🔧 Programmierung

🔧 10 Hidden Gems in GitHub Actions for Automating Your Workflow


📈 38.25 Punkte
🔧 Programmierung

🔧 10 Hidden Gems in GitHub Actions for Automating Your Workflow


📈 38.25 Punkte
🔧 Programmierung

🔧 Automating Dev.to Article Publishing with GitHub Actions and Node.js: A Workflow Overview


📈 38.25 Punkte
🔧 Programmierung

🔧 Cargo Actions: An efficient tool for managing and creating GitHub Actions workflow templates


📈 36.76 Punkte
🔧 Programmierung

🔧 Streamlining Angular Deployment with GitHub Actions, GitHub Container registry , Docker, and Nginx


📈 36.69 Punkte
🔧 Programmierung

🔧 Streamlining Development with GitHub Actions: A CI Adventure


📈 36.11 Punkte
🔧 Programmierung

🔧 Automating Flutter App Builds with GitHub Actions: Firebase App Distribution and GitHub Releases


📈 34.16 Punkte
🔧 Programmierung

🔧 Automating Workflows: Harnessing GitHub Actions, Docker, and GitHub npm Package


📈 34.16 Punkte
🔧 Programmierung

🔧 How to release a version of a web app using GitHub Workflow with GitHub Actions


📈 32.83 Punkte
🔧 Programmierung

🔧 Streamline Your Workflow: Automating Tasks with .NET 9’s New Tools and APIs


📈 32.6 Punkte
🔧 Programmierung

🔧 Macro tasks, Micro tasks and Long tasks - Web dev


📈 32.08 Punkte
🔧 Programmierung

🔧 10 Best AI workflow Automation In 2025: Supercharge Your Workflow and Say Goodbye to Tedious Tasks!


📈 31.27 Punkte
🔧 Programmierung

🔧 GitHub Workflow and Automation: Streamlining Project Management 🚀


📈 30.63 Punkte
🔧 Programmierung

🔧 Streamlining React CI/CD Pipelines with GitHub Actions


📈 30.48 Punkte
🔧 Programmierung

🔧 Streamlining Kubernetes Deployments: CI/CD with GitHub Actions and Helm for EKS


📈 30.48 Punkte
🔧 Programmierung

🔧 The Power of GitHub Actions for Streamlining DevOps Workflows


📈 30.48 Punkte
🔧 Programmierung

🔧 Streamlining CI/CD with AWS CodePipeline and GitHub Actions: A DevOps Perspective


📈 30.48 Punkte
🔧 Programmierung

🎥 Conversational Actions overview - Actions Builder & Actions SDK


📈 30.4 Punkte
🎥 Videos

🎥 Actions Project - Actions Builder & Actions SDK


📈 30.4 Punkte
🎥 Videos

🔧 Streamlining Remote Development: Strategies & Tools for an Efficient, Flexible Workflow


📈 30.05 Punkte
🔧 Programmierung

🔧 CI vs CD: Streamlining Your Development Workflow for Faster, Smarter Deployments


📈 30.05 Punkte
🔧 Programmierung

🔧 CI vs CD: Streamlining Your Development Workflow for Faster, Smarter Deployments


📈 30.05 Punkte
🔧 Programmierung

🔧 Deploying a Vite app on GitHub Pages using GitHub Actions with GitHub Secrets


📈 28.74 Punkte
🔧 Programmierung

🎥 Accelerating cloud-to-edge development flows with GitHub Copilot and GitHub Actions


📈 28.16 Punkte
🎥 Video | Youtube

🔧 Automating npm package releases with GitHub Actions


📈 27.96 Punkte
🔧 Programmierung