Navigation
Getting started- Creating a workflow (this task)
- Building code in a workflow
- Running multiple jobs in parallel
- Running jobs in sequence
- Deploying to GitHub Pages
- Using other events to run workflows
- Outputs from steps and jobs
- Keeping dependencies up to date with Dependabot
- Matrices
- Workflow dispatch inputs and security verification
- Learn more about GitHub Actions
Your first task will be to create a simple workflow that prints a message to the terminal. This will help you get familiar with the basic structure of a workflow file.
Workflow files reside within the .github/workflows
directory.
They have a name
, one or more triggers (on
) and jobs
which will run when the event triggers.
- Create a new workflow
- Print a message to the terminal
-
Create a new branch
-
Create a new file in the
.github/workflows
directory (it's important to spell the directory names correctly). You can call itpull-request.yml
-
Add the following content to the file:
# Workflow names are optional, but should be provided. # They are displayed on GitHub when the action is run. name: Hello world ✨ # The `on` property configures the events that will trigger the workflow. # In our case we want it to run when the `pull_request` event is triggered. # In short, that means that the workflow will run when a pull request is # either opened or updated (but not renamed or labeled – code needs to # be changed). on: - pull_request # Jobs are what actually do the work. We can add as many jobs as we want. # These will be run in parallel. jobs: hello_world_job: # As with workflow names (and even step names), job names are not # strictly required, but they are good practice. name: Hello world 🌱 # There are many virtual machines we can run our jobs on. The most # common one is `ubuntu-latest`. See this page for a full list of # officially supported runners: https://github.com/actions/runner-images runs-on: ubuntu-latest # Each job can have multiple steps. These will be run in sequence. steps: - name: Print message to terminal run: echo "Hello 🌏!"
-
Commit and push your changes
-
Open a pull request
-
Check the "Checks" tab to see the status of your workflow
-
See that the
Hello 🌏!
message is displayed ✨
Tip
Did you create a pull request, but the workflow didn't run? There are a few things that could be wrong:
- The workflow file is not in the correct directory — Remember, the file needs to be in a folder called
.github/workflows
exactly - The workflow file is not named correctly — The file needs to end with
.yml
or.yaml
- The workflow file is not valid YAML — YAML is very strict, so make sure you don't have any typos. If you click the
checks
button in your PR, GitHub will tell you if there are any syntax errors in your workflow file
Great work! You've now created your first workflow 🎉 Let's do something a little more productive in the next task.