βWrite a minimal GitHub Actions workflow that runs on every push, checks out the code with actions/checkout@v4, and prints 'Hello CI'. Explain each line.β
01 β Create your first GitHub Actions workflow
Category: Workflows Β· Priority: High Β· Step: 2
A "hello world" workflow that runs on every push. The goal is to see the pipeline turn green.
π― What is this task?
Workflows live in a special folder: .github/workflows/. Any .yml file there is picked up by GitHub automatically. In this task you create the smallest possible workflow so you can see it run in the Actions tab of your repo.
π€ AI Prompt
"Write a minimal GitHub Actions workflow file that runs on every push to any branch, checks out the code, and prints 'Hello CI'. Explain each line."
π Step-by-step
Step 1 β Create the folder and file
mkdir -p .github/workflows
Create .github/workflows/ci.yml:
name: CI
# Run on every push and pull request
on: [push, pull_request]
jobs:
hello:
runs-on: ubuntu-latest
steps:
- name: Check out the code
uses: actions/checkout@v4
- name: Say hello
run: echo "Hello CI π"
Step 2 β Commit and push
git add .github/workflows/ci.yml
git commit -m "ci: add first workflow"
git push
Step 3 β Watch it run
Open your repo on GitHub β Actions tab. You'll see the CI workflow running. Click it to watch the logs stream in. A green β means it passed.
β Done when
-
.github/workflows/ci.ymlexists and is pushed - The workflow appears in the Actions tab
- The run finishes green and prints
Hello CI
π Quiz
Answer all 2 questions correctly to complete this lesson.