Exercise - Create and run a basic GitHub Actions workflow

In this lab, you will learn how to create and run GitHub Actions workflows. Automation is key for repetitive tasks like testing, scanning, review, and deployment processes, and GitHub Actions is the best way to streamline that workflow. You'll learn how to create workflows, add jobs and steps, and see your automation in action.

You will learn how to:

  • Create a workflow file
  • Add a job to the workflow
  • Add run steps to execute commands
  • Trigger workflows on events
  • See workflow execution and results
  • Understand workflow syntax and structure

This lab takes approximately 30 minutes to complete.

Before you start

To complete the lab, you need:

  • A GitHub user account. If you don't have one, you can create a new account. If you need instructions on how to create a GitHub account, refer to the article Creating an account on GitHub.
  • Basic understanding of YAML syntax (helpful but not required).
  • Familiarity with the Introduction to GitHub course is recommended.
  • A web browser with access to the internet.

Complete the exercise on GitHub

In this exercise, you'll create your first GitHub Actions workflow through a hands-on GitHub Skills exercise.

Note: This exercise is hosted on GitHub Skills and provides an interactive learning experience. You'll create a workflow file, add jobs and steps, and watch as your automation runs automatically.

The exercise consists of the following activities:

  1. Start a web browser and navigate to the exercise repository: https://github.com/skills-dev/hello-github-actions

  2. On the exercise page, select the Use this template button to copy the exercise to your GitHub account.

    Note: Simply copy the exercise to your account, then give GitHub about 20 seconds to prepare the first lesson, then refresh the page.

  3. Follow the instructions on the repository's README to complete all the challenges, which include:

    • Creating a workflow file in the .github/workflows directory
    • Adding a job to define what work should be done
    • Adding a run step to execute shell commands
    • Configuring triggers to run the workflow automatically
    • Seeing the workflow run in the Actions tab
    • Understanding workflow output and logs
    • Merging your pull request with the new workflow
  4. Work through each step in the exercise, following the prompts and instructions provided.

    Note: Workflows are automatically triggered based on events you specify, such as pushes, pull requests, or scheduled times.

  5. When you finish all the challenges, you'll have created a functional GitHub Actions workflow that comments on pull requests.

What you've learned

After completing this exercise, you should be able to:

  • Understand what GitHub Actions is and its benefits
  • Create workflow files with proper YAML syntax
  • Define jobs and steps in workflows
  • Configure workflow triggers and events
  • Execute commands and scripts in workflows
  • View workflow runs and debug output
  • Use the Actions tab to monitor automation
  • Apply workflows to automate development tasks

Congratulations! You've completed the "Create and run a basic GitHub Actions workflow" exercise and taken your first step into automation!