← Back

What are GitHub Workflows?

I’ve written about GitHub Actions a couple of times (because they’re rad), but I haven’t talked much about workflows. They’re a vital part of actually using Actions, so let’s take a look at what they are, how to write them, and some 🔥 tips I’ve picked up from lurking in the Actions team’s Slack channel.

The heck is a workflow?

Hopefully you’re familiar with GitHub Actions; if not, check out this great article by @sarah_edo. Workflows are what define when and how a series of Actions should be run. You can think of it as the plan of Actions (pun 1000% intended).

GitHub will look for files with the .workflow extension in your repository’s .github folder. Let’s take a look at an example .github/main.workflow file:

workflow "Test my code" {
  on = "push"
  resolves = ["npm test"]
}

action "npm install" {
  uses = "actions/npm@v1"
  args = ["install"]
}

action "npm test" {
  uses = "actions/npm@v1"
  args = ["test"]
  needs = ["npm install"]
}

In non-code, this workflow says:

When someone pushes, it will trigger the npm test action—which ”needs” the npm install action.

GitHub doesn’t just enact workflows in the repo’s default branch—if you’re working on a .workflow file on a branch, be aware that GitHub will run the workflow.

The workflow object

workflow "Test my code" {
  on = "push"
  resolves = [