0 / 2 embers
0 / 3000 xp
click for more info
Complete a lesson to start your streak
click for more info
Difficulty: 3
click for more info
No active XP Potion
Accept a Quest
Login to submit answers
Let's dissect this workflow file and understand what each line is doing.
name: ci
on:
pull_request:
branches: [main]
jobs:
tests:
name: Tests
runs-on: ubuntu-latest
steps:
- name: Check out code
uses: actions/checkout@v4
- name: Set up Go
uses: actions/setup-go@v5
with:
go-version: "1.25.1"
- name: Echo Go version
run: go version
name: ci
The first line simply assigns a human-readable name to the workflow.
on:
pull_request:
branches: [main]
The on
key specifies when the workflow should run. In our case, we want to run the workflow when a pull request is opened to the main
branch.
jobs:
tests:
name: Tests
runs-on: ubuntu-latest
The jobs
key is a list of jobs that make up the workflow. In our case, we only have one job called tests
.
Each job has a few pieces of metadata associated with it. The name
key assigns a human-readable name to the job. The runs-on
key specifies the type of runner to use. In our case, we want to use the latest version of Ubuntu/Linux.
- name: Check out code
uses: actions/checkout@v4
Each job has a list of steps that make up the job. In our case, we have three steps. The first step checks out the code by using the pre-built checkout action to clone the repository into the runner. You'll almost always want to include this step in your workflows. The uses
key specifies the action to use, and the with
key specifies the inputs to the action.
An action is a reusable custom application that helps reduce the complexity of creating workflows. The checkout action is a publicly available action that checks-out your repository so your workflow can access it.
- name: Set up Go
uses: actions/setup-go@v5
with:
go-version: '1.25.1'
The second step sets up Go by using the pre-built setup-go action to configure a Go environment for use in workflows.
- name: Echo Go version
run: go version
The third step runs the go version
command to print the version of Go installed in the runner. The run
key specifies the command to run. The run
key is used to run arbitrary command-line commands in the runner.
Which is the correct hierarchy? (from top to bottom)