Skip to content
Hands-on IT IT Drills

Day 0: The Training Ground

Goal: A lab VM with Docker, Git and the GitHub command line gh, and a repository of your own, notes-actions, on GitHub with the code of notes-api. · Duration: approx. 45 min · Prerequisite: a GitHub account

Briefing

  • GitHub Actions runs workflows when something happens in the repository: a push, a pull request, a schedule, a click. A workflow is a YAML file under .github/workflows/.
  • The jobs run on runners. At first you use GitHub’s runners, from Day 5 also one of your own on your VM.
  • gh is the command line for GitHub: create repositories, view runs, read logs, open pull requests. Almost everything in this book works without a browser.
 Laptop ──ssh──► VM gha ── git push ──► github.com/<du>/notes-actions
                   │                         │
                   └──── gh run watch ◄──────┘  GitHub's runners (from Day 5: VM)

Drill 1: The lab VM

On the laptop (Multipass from multipass.run):

multipass launch 26.04 --name gha --cpus 4 --memory 8G --disk 40G
multipass exec gha -- bash -c "echo '$(cat ~/.ssh/id_ed25519.pub)' \
  >> ~/.ssh/authorized_keys"
multipass info gha | grep IPv4
ssh ubuntu@<IP from the output>

From here on, everything runs in the VM.

Save your progress? Sign up for free

Drill 2: Docker

sudo install -m 0755 -d /etc/apt/keyrings
sudo curl -fsSL https://download.docker.com/linux/ubuntu/gpg \
  -o /etc/apt/keyrings/docker.asc
sudo tee /etc/apt/sources.list.d/docker.sources >/dev/null <<'EOF'
Types: deb
URIs: https://download.docker.com/linux/ubuntu
Suites: resolute
Components: stable
Signed-By: /etc/apt/keyrings/docker.asc
EOF
sudo apt-get update -qq
sudo apt-get install -y -qq docker-ce docker-ce-cli containerd.io \
  docker-buildx-plugin jq git >/dev/null
sudo usermod -aG docker ubuntu
  • First the key Docker signs its packages with, then the package source. resolute is the codename of Ubuntu 26.04.
  • usermod -aG docker allows the user ubuntu to use Docker without sudo.

Log out (exit) and back in so that the docker group takes effect:

docker --version

Expected:

Docker version 29.9.2, build a82e528

Save your progress? Sign up for free

Drill 3: The GitHub command line

gh comes from a package source of its own run by GitHub – the same procedure as for Docker:

sudo curl -fsSL https://cli.github.com/packages/githubcli-archive-keyring.gpg \
  -o /etc/apt/keyrings/githubcli.gpg
sudo tee /etc/apt/sources.list.d/github-cli.sources >/dev/null <<'EOF'
Types: deb
URIs: https://cli.github.com/packages
Suites: stable
Components: main
Signed-By: /etc/apt/keyrings/githubcli.gpg
EOF
sudo apt-get update -qq
sudo apt-get install -y -qq gh >/dev/null
gh --version | head -1

Expected:

gh version 2.103.3 (2026-10-26)

Log in – with three more scopes than gh normally asks for:

gh auth login -h github.com -p https -w -s workflow,write:packages,delete:packages

gh shows an eight-character code. On the laptop, open https://github.com/login/device, enter it and confirm.

  • workflow allows pushing files under .github/workflows/. Without this scope, GitHub rejects every push that contains a workflow file.
  • You need write:packages and delete:packages from Day 6 on for images in the GitHub Container Registry.
gh auth status

Expected (your user name appears instead of <du>, the scopes line is shortened):

github.com
  ✓ Logged in to github.com account <du> (keyring)
  - Active account: true
  - Git operations protocol: https
  - Token: gho_************************************
  - Token scopes: 'delete:packages', 'gist', 'read:org', 'repo', 'workflow', ...

So that git push uses this login too:

gh auth setup-git
git config --global user.name "Dein Name"
git config --global user.email "<du>@users.noreply.github.com"
git config --global init.defaultBranch main
  • The noreply address keeps your real e-mail address out of the commits.
  • init.defaultBranch main: Without this line, the first branch in a freshly cloned, empty repository is called master, and git push origin main fails with src refspec main does not match any.

Save your progress? Sign up for free

Drill 4: Companion code and repository

mkdir -p ~/gha-lab
git clone -q https://github.com/thomaszachmann/github-actions-zum-anfassen.git \
  ~/gha-lab/code
ls ~/gha-lab/code

Expected:

LICENSE
README.md
notes

Now your own repository. gh repo create creates it on GitHub and clones it:

cd ~/gha-lab
gh repo create notes-actions --public --clone
cd notes-actions
cp -r ~/gha-lab/code/notes/notes-api/. .
cp ~/gha-lab/code/notes/.gitignore .
ls -A

Expected:

.dockerignore
.git
.gitignore
Dockerfile
go.mod
go.sum
main.go
main_test.go
metrics.go
oidc.go
oidc_test.go
store.go
git add -A
git commit -qm "notes-api"
git push -q -u origin main
gh repo view --json name,visibility,defaultBranchRef

Expected:

{"defaultBranchRef":{"name":"main"},"name":"notes-actions","visibility":"PUBLIC"}

The repository is public: runs on GitHub’s runners then cost nothing. What is public, everyone can see – that is why this book only uses lab values.

Save your progress? Sign up for free

Checkpoint

docker run --rm hello-world | grep -m1 Hello

Expected:

Hello from Docker!
gh repo view --json url --jq .url

Expected:

https://github.com/<du>/notes-actions
git log --oneline

Expected (the commit ID differs):

3535972 (HEAD -> main, origin/main) notes-api

Challenge

Use gh to set the description of your repository – “notes-api mit GitHub Actions” – and display it without opening the browser.

Hint: gh repo edit --help and gh repo view --json ….

Solution

gh repo edit --description "notes-api mit GitHub Actions"
gh repo view --json description --jq .description

Expected:

notes-api mit GitHub Actions

Save your progress? Sign up for free

Enterprise Note

  • Organizations instead of personal accounts: In a team, code lives in a GitHub organization. There, teams, rulesets and policies control who may use which actions and runners.
  • Login without long-lived tokens: gh auth login in the browser is meant for humans. Automation uses GitHub Apps or the short-lived GITHUB_TOKEN of a run (Day 9), not personal tokens.
  • GitHub Enterprise Server has the same Actions syntax, but its own runners and its own catalog of approved actions.