Skip to content

About

GitHub Actions tutorial — custom Hello World Docker container action for CI/CD beginners

Topics

Resources

Stars

1 star

Watchers

1 watching

Forks

Use this GitHub action with your project
Add this Action to an existing workflow or create a new one
View on Marketplace

Latest commit

 

History

5 Commits

Folders and files

Repository files navigation

GitHub Actions Tutorial: Build a Hello World Docker Container Action

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

What is this project?

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.

How it works

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

Inputs and outputs

Input: who-to-greet

  • Required: yes (default World)
  • Description: Name of the person to greet

Output: time

  • Timestamp string produced when the greeting ran

Quick start

git clone https://github.com/saurabhahuja71/github-action-demo.git
cd github-action-demo

1. Understand the action

action.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-output is the classic syntax used in this sample. New workflows may prefer environment-file outputs (GITHUB_OUTPUT)—good upgrade exercise.

2. Run via workflow

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

Example consumer snippet

- 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 }}"

Lab exercises

  1. Change the greeting format (e.g. include emoji or repo name).
  2. Migrate output to $GITHUB_OUTPUT modern syntax.
  3. Add a second input uppercase boolean.
  4. Publish the action to your account and reference it by @v1 tag.
  5. Add a workflow that runs on pull_request only.

Learning path

# 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

FAQ — GitHub Actions for students

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.

Topics / SEO tags

github-actions ci-cd docker devops tutorial beginner custom-action yaml college education automation

Author

Saurabh Ahuja · learning-path

License

Educational sample based on GitHub’s hello-world Docker action patterns.

About

GitHub Actions tutorial — custom Hello World Docker container action for CI/CD beginners

Topics

Resources

Stars

1 star

Watchers

1 watching

Forks

Releases

Packages

Used by

Contributors

Languages