Your First GitHub Action: Hello World

Ready to automate something on GitHub? Let's build your very first GitHub Actions workflow—a simple Hello World that you can run manually with the click of a button. No prior experience needed.

Manual Trigger Simple YAML Run Commands
What We're Building

We're going to create a GitHub Actions workflow that you can trigger manually from the GitHub website. When triggered, it will run on a GitHub-hosted runner, display a friendly "Hello World" message, show some system information, and list the files in your repository. This simple workflow will teach you the fundamental structure of GitHub Actions: workflow files, jobs, steps, and manual triggers.

The best part? Once you understand this basic pattern, you can build anything—from running tests to deploying applications. Think of this as your "Hello World" for automation, the first step toward building powerful CI/CD pipelines.

By the end of this tutorial, you'll understand how to create a workflow file, define a job, add steps, and trigger it manually. These are the building blocks for every GitHub Actions workflow.
Prerequisites

To follow along, you need a GitHub repository. It can be any repository—public or private, new or existing. If you don't have one, create a new repository on GitHub (it's free). The repository can be empty; we're not working with actual code files for this example.

That's it! You don't need any special permissions beyond being able to create files in your repository. GitHub Actions is enabled by default for all repositories, so no additional setup is required.

Quick start: Go to GitHub, create a new repository (any name works), and you're ready to begin.
Step 1: Create the Workflow File

GitHub Actions workflows are defined in YAML files stored in the .github/workflows/ directory of your repository. If these directories don't exist yet, you'll create them as you go.

In your repository, create a new file at .github/workflows/hello-world.yml. You can do this directly on GitHub by clicking "Add file" > "Create new file". Paste the following YAML content into the file.

name: Hello World Workflow

# Allows you to run this workflow manually from the Actions tab
on:
  workflow_dispatch:

# A workflow run is made up of one or more jobs
jobs:
  hello-world-job:
    # The type of runner that the job will run on
    runs-on: ubuntu-latest

    # Steps represent a sequence of tasks that will be executed
    steps:
      # Runs a single command using the runner's shell
      - name: Say Hello
        run: echo "Hello, World! Welcome to GitHub Actions."

      # Another command - show current date and time
      - name: Show Date
        run: echo "Current date and time: $(date)"

      # Show system information
      - name: System Info
        run: |
          echo "Operating System: $(uname -a)"
          echo "Current directory: $(pwd)"
          echo "Files in repository:"
          ls -la

Click "Commit changes" to save the file to your main branch. Congratulations—you've just created your first GitHub Actions workflow!

The workflow_dispatch event is what enables manual triggering. It adds a "Run workflow" button to the Actions tab, allowing you to trigger the workflow whenever you want.
Step 2: Understanding What We Just Wrote

Let's break down each part of our workflow file to understand what it does. The name field gives our workflow a display name. When you look at the Actions tab, you'll see this name.

The on: workflow_dispatch section defines the trigger. workflow_dispatch is a special event that allows manual triggering. This adds a "Run workflow" button to the Actions tab. It's perfect for workflows you want to run on demand rather than automatically.

Under jobs, we defined a single job called hello-world-job. This job runs on ubuntu-latest, which is GitHub's hosted Ubuntu runner. Within the job, we have three steps. Each step runs a command using the runner's shell. The first step prints "Hello, World!" The second shows the current date and time. The third shows system information and lists the files in the repository.

The | symbol in the third step allows us to write multi-line shell commands. This is useful when you need to run several commands in sequence within a single step.

Step 3: Run Your Workflow

Now for the exciting part—let's run your workflow! Navigate to the "Actions" tab in your repository. You'll see "Hello World Workflow" listed on the left side. Click on it.

On the workflow page, you'll see a "Run workflow" button. Click it, then select the branch you want to run on (usually main), and click "Run workflow" again. GitHub will immediately start executing your workflow.

After a moment, you'll see a new run appear in the list. Click on it to view the details. You'll see your job, and you can click on each step to expand and view the output. You should see your "Hello, World!" message, the current date, and the system information you asked for.

What you'll see: The logs will show each command being executed and their output. It's like watching a virtual computer follow your instructions in real-time.
Step 4: View the Results

After your workflow finishes, you can explore the detailed logs. Click on the "Say Hello" step to see the output. You should see something like:

Run echo "Hello, World! Welcome to GitHub Actions."
Hello, World! Welcome to GitHub Actions.

The "Show Date" step will display the current date and time on the GitHub runner. The "System Info" step will show information about the Ubuntu runner, including the kernel version, current directory, and a list of files in your repository (which should include your .github/workflows directory).

Each step shows the exact commands that were executed and their output. If any step fails, the workflow stops and shows you exactly where the error occurred. This makes debugging straightforward.

The runner's environment is clean for each workflow run. It starts fresh every time, ensuring consistent results.
Customizing Your Workflow

Now that you have a working workflow, try customizing it! Here are a few simple modifications you can make:

Change the message: Modify the echo command in the "Say Hello" step to print something else. Commit the change, then run the workflow again to see your new message.

Add another step: Add a fourth step that runs something like echo "This is my custom step!" or ls -la to explore the file system.

Use a different runner: Change runs-on: ubuntu-latest to runs-on: windows-latest or runs-on: macos-latest to see how the workflow behaves on different operating systems.

Add inputs: You can add inputs to your manual workflow so you can pass values when triggering it. Add this to your workflow_dispatch section:

on:
  workflow_dispatch:
    inputs:
      name:
        description: 'Your name'
        required: true
        default: 'World'

steps:
  - name: Greet
    run: echo "Hello, ${{ github.event.inputs.name }}!"
Each time you experiment, you're learning the fundamentals that will let you build powerful automation pipelines.
What's Next? Common Use Cases

Now that you know how to create a simple workflow, you can build more practical automations. Here are some common use cases to explore next:

Automated Testing: Replace the echo commands with npm test, pytest, or your language's test runner. Run tests automatically on every pull request.

Deployment: Add steps to deploy your application to AWS, Azure, or a VPS. Use secrets to store credentials securely.

Code Linting: Run linters like ESLint, Prettier, or Rubocop to enforce code quality standards automatically.

Dependency Updates: Schedule a workflow to check for outdated dependencies and create pull requests automatically.

Security Scanning: Integrate tools like CodeQL or Snyk to scan your code for vulnerabilities on every push.

Each of these starts with the same basic structure you just learned. The difference is the commands you run and the actions you use.

Frequently Asked Questions
Why doesn't my workflow run automatically?
We used workflow_dispatch which is a manual trigger. To run automatically, change the on section to on: push or on: [push, pull_request]. The workflow will then run every time you push code.
My workflow failed. What should I do?
Click on the failed run, then click on the failing step to see the error message. The logs will show exactly what went wrong. Common issues include typos in YAML, indentation problems, or commands that don't exist on the runner.
Can I run commands that require special permissions?
Yes! The runner has full access to the repository for the duration of the workflow. You can push changes, create issues, or comment on pull requests. Be careful with these capabilities—they can be powerful.
How do I view the logs after the workflow finishes?
Go to the Actions tab, click on your workflow, then click on a specific run. The logs are always available and are preserved for months. You can also download logs as ZIP files for offline analysis.
Can I cancel a running workflow?
Yes! In the Actions tab, open the running workflow and click the "Cancel workflow" button. This stops the workflow immediately.
What's the difference between steps and jobs?
Steps run sequentially within a job on the same runner. Jobs can run in parallel on different runners. Use steps for related commands, use separate jobs for independent tasks that can run simultaneously.
How do I add comments to my workflow file?
YAML comments start with #. You can add comments anywhere to explain what your workflow does. This is great for documenting complex workflows.
Can I use environment variables in my workflow?
Yes! You can set environment variables with env: at the workflow, job, or step level. Use ${{ env.VAR_NAME }} to reference them. GitHub also provides many built-in environment variables about the repository and workflow.
My workflow is taking a long time to start. Is something wrong?
Sometimes there's a short queue for GitHub-hosted runners, especially during peak hours. Your workflow will start when a runner becomes available. Self-hosted runners can eliminate this wait.
Can I run this workflow on my own computer?
Yes! You can set up a self-hosted runner on your local machine. Install the GitHub Actions runner software, register it with your repository, and then your workflows will run on your own hardware.
Previous: What are GitHub Actions? Next: CI with GitHub Actions

You've just written your first automation. Keep experimenting—every great CI/CD pipeline started with a simple Hello World.