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 create a workflow using a starter file and customize it to trigger on specific events. You will also add steps to the workflow to interact with GitHub Actions and automate tasks.
Estimated Duration: 20-30 minutes
Copy the content of the starter file:
name: Intro - Custom Workflow
.github/workflows
and name it intro-custom-workflow.yml
.main
branch.intro-custom-workflow.yml
file.Add the following on
section to define the workflow triggers:
on:
workflow_dispatch:
push:
paths:
- '.github/workflows/intro-custom-workflow.yml'
main
branch.intro-custom-workflow.yml
file and commit the changes to see the workflow run.intro-custom-workflow.yml
file again.Add the following jobs
section to define tasks that the workflow will perform:
jobs:
execute:
runs-on: ubuntu-latest
steps:
- run: echo "🎉 The job was automatically triggered by a $ event."
- run: echo "🐧 This job is now running on a $ server hosted by GitHub!"
- run: echo "🔎 The name of your branch is $ and your repository is $."
- name: Check Code
uses: actions/checkout@v4
- run: echo "💡 The $ repository has been cloned to the runner."
- run: echo "🖥️ The workflow is now ready to test your code on the runner."
- name: List Files In Directory
run: |
ls $
- run: echo "🍏 This job's status is $."
- name: Adding Markdown
run: echo "### Hello world! :rocket:" >> "$GITHUB_STEP_SUMMARY"
# This step uses GitHub's hello-world-javascript-action
- name: Hello World
uses: actions/hello-world-javascript-action@main
with:
who-to-greet: 'Mona the Octocat'
id: hello
# This step prints an output (time) from the previous step's action.
- name: Echo Greeting's Time
run: echo 'The time was $.'
main
branch.The intro-custom-workflow.yml
workflow includes the following sections:
The workflow is named Intro - Custom Workflow
.
on
)workflow_dispatch
:
push
:
.github/workflows/intro-custom-workflow.yml
file is modified and committed.jobs.execute
)runs-on
:
ubuntu-latest
GitHub-hosted runner.Steps:
actions/checkout@v4
action to clone the repository into the runner.hello-world-javascript-action
.To run the workflow:
.github/workflows/intro-custom-workflow.yml
file and commit the change.If you want to run the workflow on any push to the repository:
Update the on
section as follows:
on:
workflow_dispatch:
push:
branches:
- main
Commit the changes to the main
branch.
In this lab, you:
This lab demonstrated how to create, customize, and execute a workflow using GitHub Actions.