My Journey Into GitHub Actions - #3 - What’s The Minimum Amount Of Stuff Needed For A Workflow File

2 minute read

This post is going to start off with how you can set a display name for your GitHub Action workflow file, and then kinda goes off the rails into what is the minimum amount of “stuff you need in your workflow file to have a working workflow.

Currently I have two GitHub Actions workflow files in my repo:

  • mickeys-first-workflow.yml
  • testing.yml

If I click the Actions tab, I see the following:

What caught my attention were the individual workflows listed under All workflows. I see that one of them is the path name and file name for testing.yml, and the other is just a name, CI. I’m curious why one file seems to have a “name” and the other doesn’t. Turns out, there is a property you can set in the YAML file for the display name, and if that property is not there, then it defaults to showing the fully pathed filename.

This property is, aptly called, name. Here you can see the name property is set in my mickeys-first-workflow.yml file to CI:

While in my testing.yml file, all I have in there is a single comment. No name property, so it defaults to the full path name. Following the logic above, if I add the name attribute, then I should see an actual display name for the workflow. Let’s try it:

As usualy, once I make the change, I click the Start Commit button in the top right, give it a commit message, then completely break best practice and commit to master. I click back to the Actions tab, and I see this:

Hmmmm, it didn’t change the name. But now I’m noticing that the testing.yml workflow has a red “X”, indicating something must be wrong with the workflow. If I click it to see some details, I see this:

Ah, my workflow is currently invalid because I don’t have a trigger defined for it. Interesting. What it looks like is happening is that, on my commit, it checks all the workflows in the .github/workflows folder and validates them. And it also looks for any that need to be triggered. In the case of testing.yml, it didn’t pass the validation stage, because I don’t have enough “stuff” in it yet to be a valid workflow file. Ok, so I’m going to add a trigger:

I’ll commit my changes back to master, and go back to the Actions tab. The testing.yml failed to validate again. If I click into the failed validation, I see this:

Ok, so I don’t have a job defined. Let’s go do that.

When I added the keyword jobs, it automatically added the job_id value for me. I can change that to be anything I want, but I’ll leave it alone for now. I commit that back, and the validation fails again. This time the error message is:

Which makes sense, I mean, what is a job without any steps that do something. So I added a step that checks out the repo:

OK, now it is gonna work! I commit my changes, and boom, another validation fail! This time the error message is:

oh, yeah. It might help if I specify the type of build machine I want to use. Let’s just grab a Linux machine:

Commit that back to master, and look! It worked! The workflow passed validation, ran, and it changed the name:

It looks like, for it to pick up the display name, you have to have a valid YAML file. And that the minimum viable product for a GitHub Actions workflow file is:

  • Name
  • On
  • Job
  • Runs on
  • Step