Skip to content
Hands-on IT IT Drills

Appendix B: Final Exam

Goal: Show without instructions that you master GitHub Actions in everyday work: a workflow with a path filter, a nightly run, closing a vulnerability, a release from tag to production and a job on ARC. · Duration: approx. 90 min · Prerequisite: Day 15

Rules of Play

  • Each exercise only describes the goal. You find the way yourself; the days in parentheses help you look things up.
  • Each exercise ends with a check block: individual commands with what they must show. Only when all of them match does the exercise count.
  • Everything happens in the notes-actions repository.
cd ~/gha-lab/notes-actions

Exercise 1: A workflow just for docs

Create .github/workflows/docs.yml. It runs on pushes to main that affect only Markdown files, and manually. It checks that README.md contains the word notes-actions and writes “Doku ok” to the summary. Permissions: read only. Afterwards, push a change to the README. (Day 2, Day 9)

Check block:

gh run list --workflow docs.yml --limit 1 --json event,conclusion --jq '.[0]'

Expected:

{"conclusion":"success","event":"push"}
gh run list --workflow ci.yml --limit 1 --json displayTitle --jq '.[0].displayTitle'

Expected: not the title of your README commit – ci does not run for Markdown.

Solution

cat > .github/workflows/docs.yml <<'EOF'
name: docs
on:
  push:
    branches: [main]
    paths: ['**.md']
  workflow_dispatch:
permissions:
  contents: read
jobs:
  pruefen:
    runs-on: ubuntu-24.04
    steps:
      - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
        with:
          persist-credentials: false
      - run: grep -q notes-actions README.md
      - run: echo "Doku ok" >> "$GITHUB_STEP_SUMMARY"
EOF
git add .github
git commit -qm "docs: README prüfen"
git push -q
echo "Übungsrepository zu GitHub Actions zum Anfassen." >> README.md
git commit -qam "README: ein Satz mehr"
git push -q

paths: is the counterpart of paths-ignore:. The first push (only docs.yml) does not start docs – it changes no Markdown file – but it does start ci.

Save your progress? Sign up for free

Exercise 2: A nightly run

Create .github/workflows/nacht.yml: every night at 02:30 UTC and manually, tests with the race detector (go test -race ./...) on ubuntu-24.04, using the composite action from Day 12. Start it once manually. (Day 2, Day 12)

Check block:

grep -A1 'schedule:' .github/workflows/nacht.yml

Expected:

  schedule:
    - cron: '30 2 * * *'
gh run list --workflow nacht.yml --limit 1 --json event,conclusion --jq '.[0]'

Expected:

{"conclusion":"success","event":"workflow_dispatch"}

Solution

cat > .github/workflows/nacht.yml <<'EOF'
name: nacht
on:
  schedule:
    - cron: '30 2 * * *'
  workflow_dispatch:
permissions:
  contents: read
jobs:
  race:
    runs-on: ubuntu-24.04
    steps:
      - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
        with:
          persist-credentials: false
      - uses: ./.github/actions/go-setup
      - run: go test -race ./...
EOF
git add .github
git commit -qm "nacht: Race-Detector"
git push -q
gh workflow run nacht.yml

-race needs CGO – a C compiler is available on GitHub’s runners.

Save your progress? Sign up for free

Exercise 3: Closing a vulnerability

A colleague wrote this workflow:

cat > .github/workflows/gruss.yml <<'EOF'
name: gruss
on: pull_request
jobs:
  gruss:
    runs-on: ubuntu-24.04
    steps:
      - run: echo "Danke für den Branch ${{ github.head_ref }}"
EOF

Use zizmor to find all problems and fix them until zizmor reports nothing more. Then commit and push. (Day 9)

Check block:

zizmor -q --offline .github/workflows/gruss.yml

Expected:

No findings to report. Good job! (2 suppressed)
grep -c 'github.head_ref' .github/workflows/gruss.yml

Expected:

1

The expression still occurs exactly once – under env:, not in run:.

Solution

zizmor -q --offline .github/workflows/gruss.yml | grep -E '^[a-z]+\['

Expected:

warning[excessive-permissions]: overly broad permissions
error[template-injection]: code injection via template expansion

A branch name like x";curl…|sh;" would be code. And without permissions:, the repository defaults apply:

cat > .github/workflows/gruss.yml <<'EOF'
name: gruss
on: pull_request
permissions:
  contents: read
jobs:
  gruss:
    runs-on: ubuntu-24.04
    steps:
      - env:
          BRANCH: ${{ github.head_ref }}
        run: echo "Danke für den Branch $BRANCH"
EOF
git add .github
git commit -qm "gruss: ohne Injection"
git push -q

Save your progress? Sign up for free

Exercise 4: From tag to production

Publish v0.7.0: release with binaries, image 0.7.0 with provenance, deployment to production with your approval. (Day 7, Day 8, Day 10, Day 11)

Check block:

gh release view v0.7.0 --json isPrerelease,assets \
  --jq '.isPrerelease, (.assets | length)'

Expected:

false
3
gh attestation verify oci://ghcr.io/<du>/notes-api:0.7.0 -R <du>/notes-actions \
  >/dev/null 2>&1; echo "Exit: $?"

Expected:

Exit: 0
curl -s localhost:30081/version

Expected:

0.7.0

Solution

git tag v0.7.0
git push -q origin v0.7.0

release.yml builds and publishes, image.yml builds the image, attests and signs it, and the deploy job in release.yml starts deploy.yml. Wait until image.yml is finished (gh run list --workflow image.yml --limit 1), then approve – with the ID from gh run list --workflow deploy.yml --limit 1:

gh api -X POST repos/{owner}/{repo}/actions/runs/<ID>/pending_deployments \
  -F 'environment_ids[]=26123220715' -f state=approved -f comment='v0.7.0' \
  --jq '.[].environment'

The environment ID is yours from Day 10.

Save your progress? Sign up for free

Exercise 5: A job without traces

Change vm.yml so that the job runs on ARC instead of gha-vm. Start it twice and show that ~/gha-lab/laeufe.txt is missing in the job both times. (Day 5, Day 14)

Check block:

gh run view <ID> --log | grep -E 'Z (Host|Lauf)'

Expected (for the second run, names differ):

wo  Wo bin ich? ... Host: arc-notes-runner-kxb5d, Benutzer: runner
wo  Spuren hinterlassen ... Lauf 41636401967

Only one Lauf line – the file was empty when the job began.

Solution

~/gha-lab doesn’t exist in the runner pod. The job creates the folder itself:

cat > .github/workflows/vm.yml <<'EOF'
name: vm
permissions:
  contents: read
on: workflow_dispatch

jobs:
  wo:
    runs-on: arc-notes
    steps:
      - name: Wo bin ich?
        run: |
          echo "Host: $(hostname), Benutzer: $(whoami)"
          echo "Arbeitsordner: $PWD"
      - name: Spuren hinterlassen
        run: |
          mkdir -p ~/gha-lab
          echo "Lauf $GITHUB_RUN_ID" >> ~/gha-lab/laeufe.txt
          cat ~/gha-lab/laeufe.txt
EOF
git commit -qam "vm: auf ARC"
git push -q
gh workflow run vm.yml

As soon as the run is finished, run gh workflow run vm.yml once more.

Save your progress? Sign up for free

Cleaning up

The runner, k3s and ARC keep running until you tear them down:

helm uninstall arc-notes -n arc-runners
helm uninstall arc -n arc-systems
cd ~/gha-lab/runner
sudo ./svc.sh stop
sudo ./svc.sh uninstall
TOKEN=$(gh api -X POST \
  repos/<du>/notes-actions/actions/runners/remove-token --jq .token)
./config.sh remove --token "$TOKEN"
/usr/local/bin/k3s-uninstall.sh
  • config.sh remove deregisters the runner from GitHub – with a separate, short-lived token.
  • k3s-uninstall.sh was created by the installation script; it removes k3s along with all pods and data.

The notes-actions repository and the packages in GHCR remain. You can delete them in the browser or with gh repo delete – for that, gh needs the delete_repo scope (gh auth refresh -s delete_repo).

Knowledge check

  1. Why does ${{ github.event.issue.title }} never belong directly in a run:?
  2. What is the difference between a cache and an artifact?
  3. What is persist-credentials: false for?
  4. Why do you pin actions to a SHA, and what keeps it up to date?
  5. What does the sub of an OIDC token from a job with environment: produktion contain?
  6. Why does a release that a workflow creates with the GITHUB_TOKEN not start any other workflow – and what exception is there?
  7. Composite action or reusable workflow: which bundles what?
  8. What distinguishes an ARC runner from the one from Day 5?

Answers

  1. Expressions are substituted before the shell sees the command. Foreign text thus becomes code. Via env: it stays text (Day 9).
  2. A cache may be missing and only speeds things up; an artifact is a result that later jobs or people rely on (Day 3).
  3. Otherwise checkout stores the token in .git/config, where later steps or uploaded artifacts can give it away (Day 9).
  4. Tags can be moved, a SHA cannot. Dependabot or Renovate update pinned SHAs based on the comment # vX.Y.Z (Day 9, Day 10).
  5. repo:<owner>@<id>/<repo>@<id>:environment:produktion (Day 10).
  6. Protection against infinite loops. workflow_dispatch and repository_dispatch are exempt – that is why release.yml starts the deployment with gh workflow run (Day 11).
  7. Composite: several steps in one step. Reusable workflow: whole jobs, with their own runs-on and their own permissions (Day 12).
  8. It is ephemeral: one pod per job, deleted afterwards – no traces, no dependency between jobs (Day 14).

What’s next?

  • More security: actionlint and zizmor in every pull request, rulesets at the organization level, SHA pinning as a policy.
  • GitOps: Instead of kubectl from the runner, CI writes the version into Git, and Argo CD rolls it out – without the runner having access to the cluster.
  • Organization: Central reusable workflows, runner groups, a GitHub App for ARC.

The sister books “Secure supply chains hands-on”, “Kubernetes hands-on” and “Renovate hands-on” pick up exactly there.