Master GitHub Actions with hands-on labs and exercises. Learn how to automate workflows, run tests, deploy applications, and more using GitHub's powerful automation platform. This repository has everything you need to get started with continuous integration and continuous deployment.
In this lab, you will use the Simple Workflow built-in template to create a GitHub Actions workflow. This workflow is triggered on specific events and demonstrates basic concepts such as jobs, steps, and commands. You will also explore and understand the structure and purpose of the provided workflow file.
Duration: 20-30 minutes
Open the repository you created in the previous lab.
Click on the Actions tab in your repository.
Click on the New workflow button.
Select the Simple workflow template and click Configure.
Name the workflow file simple-workflow.yml
.
Click Commit changes… to save the workflow.
This will create the file .github/workflows/simple-workflow.yml
in your repository.
Here is the content of the Simple Workflow template:
name: Intro - Simple Workflow
# Controls when the workflow will run
on:
# Triggers the workflow on push or pull request events but only for the "main" branch
push:
branches: ['main']
pull_request:
branches: ['main']
# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:
# A workflow run is made up of one or more jobs that can run sequentially or in parallel
jobs:
# This workflow contains a single job called "build"
build:
# The type of runner that the job will run on
runs-on: ubuntu-latest
# Steps represent a sequence of tasks that will be executed as part of the job
steps:
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
- uses: actions/checkout@v4
# Runs a single command using the runners shell
- name: Run a one-line script
run: echo Hello, world!
# Runs a set of commands using the runners shell
- name: Run a multi-line script
run: |
echo Add other actions to build,
echo test, and deploy your project.
Name:
The workflow is named Intro - Simple Workflow for easy identification.
Triggers (on
):
workflow_dispatch
): Allows the workflow to be triggered manually via the Actions tab.main
branch are provided as examples but are commented out. Uncomment them to enable automatic triggers.Jobs:
The workflow defines a single job named build
.
Runner:
The job uses the ubuntu-latest
runner, which provides a Linux environment to execute the workflow steps.
Steps:
actions/checkout@v4
action to clone the repository’s code into the runner.Return to the Actions tab. You should see the workflow listed.
Click on Run workflow, select the main
branch, and then click Run workflow.
The workflow will begin running. Click on the workflow run to view its details.
In this lab, you used the Simple Workflow template to create a workflow. You learned about its structure, including jobs, triggers, and steps, and observed how it operates when triggered manually.