Lab: Hello World Workflow
Introduction
In this lab, you will create a simple GitHub Actions workflow from scratch that echoes “Hello, World!” to the console. This will help you understand how to define and trigger a basic workflow in GitHub Actions.
Estimated Duration: 15–20 minutes
Instructions
Step 1: Set up your repository
-
Navigate to the repository you created in the previous lab.
- If you haven’t completed the previous lab, clone the template repository by following the instructions to clone the template repository.
Step 2: Create the workflow from scratch
-
In your repository, click the Code tab (if not already there).
-
Navigate to the
.github
folder. If it doesn’t exist, create it:- Click Add file > Create new file.
- Name the new folder:
.github/
(GitHub will treat it as a folder when followed by another folder or file).
-
Inside the
.github
folder, create a new folder namedworkflows
:- Name the new file:
.github/workflows/intro-hello-world-workflow.yml
.
- Name the new file:
-
Paste the following YAML content into the editor:
name: Intro - Hello World Workflow on: push jobs: run: runs-on: ubuntu-latest steps: - name: Say Hello to the World run: echo "Hello, World!"
-
Scroll down and click the Commit new file button to save the workflow.
Step 3: Understand the workflow
- The workflow is named Intro - Hello World Workflow.
- It is triggered by the
push
event, meaning it will run anytime you push changes to the repository. - It runs on the ubuntu-latest virtual machine.
- It has a single job named run.
- The job has one step that prints “Hello, World!” to the console.
Step 4: Trigger the workflow
-
Make a small change in your repository to trigger the workflow (since it runs on
push
).- For example, edit the
README.md
file and add a comment line. - Commit the change to the
main
branch.
- For example, edit the
-
Go to the Actions tab.
- You should see a new workflow run listed for Intro - Hello World Workflow.
Step 5: View the results
- Click on the workflow run to open its details.
- Click on the run job.
- Expand the step titled Say Hello to the World.
- You should see the message
Hello, World!
in the logs.
Summary
In this lab, you created a GitHub Actions workflow manually, without using any built-in templates. You learned how to define a basic workflow file, trigger it by pushing changes, and inspect its execution output.