What's the difference between a GitHub action and a workflow?
Tags: github, devops, actionshackathon21, actionshackathon
Published: 2021-12-10 11:31:55

The [GitHub Actions Hackathon](https://dev.to/devteam/join-us-for-the-2021-github-actions-hackathon-on-dev-4hn4) has just concluded. Congrats to everyone who submitted an Action. Throughout the hackathon, we noticed some questions on the [Actions help thread](https://dev.to/devteam/github-actions-hackathon-2021-help-thread-1lk0) 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](https://docs.github.com/en/actions/learn-github-actions/events-that-trigger-workflows). 

### 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](https://github.com/marketplace?type=actions).

### 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](https://docs.github.com/en/actions/hosting-your-own-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](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/mgqzpz7yrlrc6z0pgb9p.png)

GitHub Actions really gives you the power to automate anything you like. There are thousands of actions to [check out on the GitHub Marketplace](https://github.com/marketplace?type=actions), and we've just [released reusable workflows](https://github.blog/2021-11-29-github-actions-reusable-workflows-is-generally-available/). You can find out more about GitHub Actions, [check out the GitHub Docs](https://docs.github.com/en/actions/learn-github-actions/understanding-github-actions).