What's the difference between a GitHub action and a workflow?

Michelle Mannering - Dec 10 '21 - - Dev Community

The GitHub Actions Hackathon has just concluded. Congrats to everyone who submitted an Action. Throughout the hackathon, we noticed some questions on the Actions help thread were about Actions Vs. workflows. We thought we'd clear things up with a blog post on the difference between an Action and a workflow.

GitHub Actions

One of the confusing things about actions vs. workflows is the entire platform is called "GitHub Actions". This platform allows users to automate their build, test, and deployment pipeline. So it's not just CI/CD, but an entire automation platform. There are a number of actions you can setup to do multiple things.

The GitHub Actions platform (or product) consist of several components including:

  • Events
  • Workflows
  • Jobs
  • Actions
  • Runners

This is where the confusion can begin. You'll notice the platform is called GitHub Actions, but one of the components of GitHub Actions is also called actions. Let's go through each component above.

Events

An event is something that happens in a GitHub repository. Events include things like creating a pull request, opening an issue, or making a commit. Check the full list of events on the GitHub Docs.

Workflows

A workflow is the 'thing' (or all the things) which happen after a specific other 'thing' (ie. event) occurs. A workflow can be triggered after an event happens. Workflows can also be run manually, or set to run at a specific time. Workflows are created as *.yml files. Both manually run workflows and timed workflows are still classed as an 'event'.

The 'thing' that happens next is a series of steps defined by the user. The workflow can be anything from sending out a tweet on release publish, or deploying an application when a release is published, or even adding a label once an issued is opened.

Jobs

A job is a series of steps inside the workflow which are executed. Each step is either a script to be executed, or an action that would run. Steps are executed in the order they are written and are dependent on the previous step being complete. Jobs can be run in parallel, but the steps need to run individually.

Actions

An action is one of the 'thing's that happens inside the workflow. Actions are used to perform complex tasks that require repetition. Thus, by using an action, you can reduce the amount of time of time and repetitive code needed to write the workflow file. For example, an action could pull your git repo, or pull your contributions. You can write our own actions, or use actions from the GitHub Marketplace.

Runners

The runners are the process on the server that runs the workflow once the workflow is triggered. Each runner can only run one job at a time, and that job is a collection of steps as we mentioned above. Hosted runners are in the cloud, and users can specify the type of runner they'd like to use. You can also use self-hosted runners if you want to customise your environment completely.

How they work together

GitHub Actions combines all the components mentioned above. The workflow is the entire process that happens once the event occurs. Actions are individual events that happen within each job:

Actions Overview

GitHub Actions really gives you the power to automate anything you like. There are thousands of actions to check out on the GitHub Marketplace, and we've just released reusable workflows. You can find out more about GitHub Actions, check out the GitHub Docs.

. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .