GitHub Actions: Your First Workflow File
A workflow file tells GitHub Actions what to do. It lives in the .github/workflows folder of the repository.
The file path
Every workflow file lives in the same folder.
.github/workflows/ci.ymlName and moment
The first two lines name the workflow and say when it runs.
name: CI
on: pushOne job
The job is called test and runs on Ubuntu.
jobs:
test:
runs-on: ubuntu-latestThree steps
Fetch the code, install Node, then run the tests.
steps:
- uses: actions/checkout@v7
- uses: actions/setup-node@v7
with:
node-version: '24'
- run: npm testExample
name: CI
on: push
jobs:
test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v7
- uses: actions/setup-node@v7
with:
node-version: '24'
- run: npm testKey points
- A workflow file is a text file that describes one workflow.
- Use the name line to give the workflow a title.
- The on line says when the workflow runs.
- A job groups steps that run on one runner.
- The uses line brings in a ready-made step.
- actions/checkout fetches the code onto the runner.
- actions/setup-node installs Node on the runner.
- The with block holds a step's settings, like the Node version.
- The @v7 after an action name is its version tag.
- The run line runs a command, like npm test.
- One file, one workflow: a name, a moment to run, and a job of steps.
In this example, the file is .github/workflows/ci.yml. The name line calls the workflow CI. The on line says it runs on a push. The job is called test and runs on Ubuntu. The first step fetches the code. The second step installs Node 24. The third step runs the tests. The file uses a plain format called YAML. A later lesson explains the format in full.
Note
The folder name is plural: workflows. A file in the wrong folder never runs.
Try it Yourself
Edit the code, then press Run.
Running is simulated · Rust Playground
Exercise
Where does the workflow file live?