GitHub Actions tutorial for beginners—create a custom Docker container action that greets a user and returns a timestamp output. Learn action.yml, Dockerfile, entrypoint.sh, and a workflow that runs on every push.
Lab 4 in the CI/CD learning path · Audience: beginners · Time: ~45–90 minutes · Level: beginner → intermediate
A minimal JavaScript-free Docker action:
| Piece | Role |
|---|---|
action.yml |
Action metadata, inputs, outputs, runner |
Dockerfile |
Alpine image + entrypoint |
entrypoint.sh |
Prints hello + sets time output |
.github/workflows/main.yml |
Demo workflow on push |
SEO keywords: GitHub Actions tutorial for beginners, custom Docker action example, action.yml explained, GitHub Actions hello world, CI/CD college lab, container action tutorial.
Push to repo
→ workflow job on ubuntu-latest
→ checkout
→ runs this Docker action with who-to-greet
→ entrypoint.sh echoes Hello … and sets output time
- Required: yes (default
World) - Description: Name of the person to greet
- Timestamp string produced when the greeting ran
git clone https://github.com/saurabhahuja71/github-action-demo.git
cd github-action-demoaction.yml (conceptually):
name: 'Hello World ...'
inputs:
who-to-greet:
required: true
default: 'World'
outputs:
time:
description: 'The time we greeted you'
runs:
using: 'docker'
image: 'Dockerfile'
args:
- ${{ inputs.who-to-greet }}entrypoint.sh:
echo "Hello $1"
time=$(date)
echo "::set-output name=time::$time"Note:
::set-outputis the classic syntax used in this sample. New workflows may prefer environment-file outputs (GITHUB_OUTPUT)—good upgrade exercise.
Push to GitHub (Actions enabled) or use Act locally if you have it. The included workflow:
- Checks out the repo
- Invokes the action (see workflow for the published ref you use)
- Echoes
steps.hello.outputs.time
- uses: actions/checkout@v3
- name: Hello world
uses: ./ # when testing the action from the same repo
id: hello
with:
who-to-greet: 'Mona the Octocat'
- run: echo "The time was ${{ steps.hello.outputs.time }}"- Change the greeting format (e.g. include emoji or repo name).
- Migrate output to
$GITHUB_OUTPUTmodern syntax. - Add a second input
uppercaseboolean. - Publish the action to your account and reference it by
@v1tag. - Add a workflow that runs on
pull_requestonly.
| # | Lab | Focus |
|---|---|---|
| 3 | terraform-azure-jenkins-sample | Jenkins on a VM |
| 4 (this) | github-action-demo | Pipelines on GitHub |
| Meta | sample-template-repo | OSS repo hygiene template |
Hub: learning-path
Docker action vs JavaScript action?
Docker is great when you need arbitrary OS tools; JS actions start faster. This lab teaches the Docker path.
Why Alpine?
Tiny base image for a fast-teaching Dockerfile.
Can I use this in other repos?
Yes—reference by owner/repo@ref after you push tags/releases.
github-actions ci-cd docker devops tutorial beginner custom-action yaml college education automation
Educational sample based on GitHub’s hello-world Docker action patterns.