Skip to content
Hands-on IT IT Drills

Day 15: Competition

Goal: Eight broken workflows, eight typical everyday mistakes. For each one, find the cause with gh, the log and zizmor, fix it and prove it with a green run. · Duration: approx. 90 min · Prerequisite: Days 0–14

Rules of Play

  • Each round writes a file .github/workflows/wk.yml, pushes it and starts it with gh workflow run wk.yml.
  • Search on your own first: gh run list, gh run view <ID> --log-failed, gh run view <ID> -v, zizmor -q --offline. Then the hint, then the solution.
  • A round is done when the run is green and does the right thing.
  • The ID of a run: gh run list --workflow wk.yml --limit 1.
cd ~/gha-lab/notes-actions

Round 1: The workflow that doesn’t exist

cat > .github/workflows/wk.yml <<'EOF'
name: wk
on: workflow_dispatch
permissions:
  contents: read
jobs:
  r1:
    runs-on: ubuntu-24.04
    steps:
      - run: echo "Status: alles gut"
EOF
git add .github
git commit -qm "wk: Runde 1"
git push -q
gh workflow run wk.yml

Expected:

could not create workflow dispatch event: HTTP 422: Workflow does not have 'workflow
_dispatch' trigger (https://api.github.com/repos/<du>/notes-actions/actions/workflows/…)

But the trigger is right there?

Hint: zizmor -q --offline .github/workflows/wk.yml. GitHub doesn’t even read an invalid file – and only reports that in the browser.

Solution

zizmor -q --offline .github/workflows/wk.yml 2>&1 | head -1

Expected:

 WARN zizmor::registry::input: failed to parse input: mapping values are not allowed
in this context at line 9 column 26

echo "Status: alles gut" is an unquoted YAML value, and the : inside it turns it into a second key. The whole command in quotes:

cat > .github/workflows/wk.yml <<'EOF'
name: wk
on: workflow_dispatch
permissions:
  contents: read
jobs:
  r1:
    runs-on: ubuntu-24.04
    steps:
      - run: 'echo "Status: alles gut"'
EOF
git commit -qam "wk: Runde 1 gelöst"
git push -q
gh workflow run wk.yml

Expected:

https://github.com/<du>/notes-actions/actions/runs/41633565092

Afterwards the log shows Status: alles gut.

Save your progress? Sign up for free

Round 2: The condition that is always true

cat > .github/workflows/wk.yml <<'EOF'
name: wk
on:
  workflow_dispatch:
    inputs:
      laut:
        type: boolean
        default: false
permissions:
  contents: read
jobs:
  r2:
    runs-on: ubuntu-24.04
    steps:
      - if: ${{ inputs.laut }} == 'true'
        run: echo "LAUT"
EOF
git commit -qam "wk: Runde 2"
git push -q
gh workflow run wk.yml -f laut=false

Check whether the step ran:

gh run view <ID> -v | grep 'echo'

Expected – unfortunately:

  ✓ Run echo "LAUT"

laut was false, but the step ran anyway.

Hint: What does ${{ inputs.laut }} == 'true' turn into after GitHub has substituted the expression?

Solution

GitHub substitutes ${{ inputs.laut }} and gets the text false == 'true'. A non-empty string is truthy. The whole comparison belongs inside the expression – for a boolean, the value itself is enough:

cat > .github/workflows/wk.yml <<'EOF'
name: wk
on:
  workflow_dispatch:
    inputs:
      laut:
        type: boolean
        default: false
permissions:
  contents: read
jobs:
  r2:
    runs-on: ubuntu-24.04
    steps:
      - if: inputs.laut
        run: echo "LAUT"
EOF
git commit -qam "wk: Runde 2 gelöst"
git push -q
gh workflow run wk.yml -f laut=false

As soon as the run is finished, gh run view <ID> -v shows a - in front of Run echo "LAUT": skipped.

Save your progress? Sign up for free

Round 3: The empty output

cat > .github/workflows/wk.yml <<'EOF'
name: wk
on: workflow_dispatch
permissions:
  contents: read
jobs:
  r3:
    runs-on: ubuntu-24.04
    steps:
      - id: v
        run: echo "version=1.2.3" >> "$GITHUB_OUTPUT"
      - env:
          VERSION: ${{ steps.v.outputs.versoin }}
        run: |
          echo "Version ist '$VERSION'"
          test -n "$VERSION"
EOF
git commit -qam "wk: Runde 3"
git push -q
gh workflow run wk.yml

As soon as the run is finished:

gh run view <ID> --log-failed | grep -E "Z Version ist"

Expected:

r3  Run echo "Version ist '$VERSION'"   ... Version ist ''

The run is red – test -n struck.

Hint: An unknown output is not an error – just empty.

Solution

Typo: versoin. Expressions don’t report unknown names, they return an empty string. test -n makes the error visible – a good guard for values that must never be empty.

sed -i 's/outputs.versoin/outputs.version/' .github/workflows/wk.yml
git commit -qam "wk: Runde 3 gelöst"
git push -q
gh workflow run wk.yml

As soon as the run is finished, the log shows Version ist '1.2.3'.

Save your progress? Sign up for free

Round 4: Too few permissions

cat > .github/workflows/wk.yml <<'EOF'
name: wk
on: workflow_dispatch
permissions:
  contents: read
jobs:
  r4:
    runs-on: ubuntu-24.04
    steps:
      - env:
          GH_TOKEN: ${{ github.token }}
        run: gh label create "wk-$GITHUB_RUN_ID" --repo "$GITHUB_REPOSITORY"
EOF
git commit -qam "wk: Runde 4"
git push -q
gh workflow run wk.yml

As soon as the run is finished:

gh run view <ID> --log-failed | grep -o 'HTTP 403.*'

Expected:

HTTP 403: Resource not accessible by integration (https://api.github.com/repos/<du>...

In full: …/repos/<du>/notes-actions/labels.

Hint: Resource not accessible by integration means: the GITHUB_TOKEN is not allowed to do that.

Solution

Labels belong to issues. The job needs issues: write – only that job, not the whole workflow:

cat > .github/workflows/wk.yml <<'EOF'
name: wk
on: workflow_dispatch
permissions:
  contents: read
jobs:
  r4:
    runs-on: ubuntu-24.04
    permissions:
      issues: write
    steps:
      - env:
          GH_TOKEN: ${{ github.token }}
        run: gh label create "wk-$GITHUB_RUN_ID" --repo "$GITHUB_REPOSITORY"
EOF
git commit -qam "wk: Runde 4 gelöst"
git push -q
gh workflow run wk.yml

As soon as the run is finished:

gh label list --search wk-

Expected (the number differs):

Showing 1 of 1 label in <du>/notes-actions

NAME            DESCRIPTION  COLOR
wk-41633979173               #5319E7

Clean up: gh label delete wk-41633979173 --yes with your number.

Save your progress? Sign up for free

Round 5: Green, although it fails

cat > .github/workflows/wk.yml <<'EOF'
name: wk
on: workflow_dispatch
permissions:
  contents: read
jobs:
  r5:
    runs-on: ubuntu-24.04
    steps:
      - run: |
          false | tee ergebnis.txt
          echo "Weiter nach dem Fehler"
EOF
git commit -qam "wk: Runde 5"
git push -q
gh workflow run wk.yml

As soon as the run is finished:

gh run view <ID> --log | grep -E 'Z (shell|Weiter)'
gh run view <ID> --json conclusion --jq .conclusion

Expected:

r5  Run false | tee ergebnis.txt    ... shell: /usr/bin/bash -e {0}
r5  Run false | tee ergebnis.txt    ... Weiter nach dem Fehler
success

false failed, yet the step is green.

Hint: Look at the line with shell:. What is missing compared to a script that aborts on errors in pipes?

Solution

Without shell:, run: runs with bash -e. The exit code of a pipe is that of the last command – here tee, and tee succeeds. With shell: bash, GitHub adds -o pipefail:

cat > .github/workflows/wk.yml <<'EOF'
name: wk
on: workflow_dispatch
permissions:
  contents: read
jobs:
  r5:
    runs-on: ubuntu-24.04
    steps:
      - shell: bash
        run: |
          false | tee ergebnis.txt
          echo "Weiter nach dem Fehler"
EOF
git commit -qam "wk: Runde 5 gelöst"
git push -q
gh workflow run wk.yml

As soon as the run is finished:

gh run view <ID> --log | grep -E 'Z (shell|Weiter)'
gh run view <ID> --json conclusion --jq .conclusion

Expected:

r5  Run false | tee ergebnis.txt    ... shell: /usr/bin/bash --noprofile --norc -e -o pi...
failure

Red now – as it should be. “Weiter nach dem Fehler” no longer appears. For all steps of a workflow: defaults: run: shell: bash at the top level.

Save your progress? Sign up for free

Round 6: Two artifacts, one name

cat > .github/workflows/wk.yml <<'EOF'
name: wk
on: workflow_dispatch
permissions:
  contents: read
jobs:
  r6:
    strategy:
      matrix:
        teil: [a, b]
    runs-on: ubuntu-24.04
    steps:
      - run: echo "Teil ${{ matrix.teil }}" > teil-${{ matrix.teil }}.txt
      - uses: actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9 # v7.0.2
        with:
          name: teile
          path: teil-*.txt
  zusammen:
    needs: r6
    runs-on: ubuntu-24.04
    steps:
      - uses: actions/download-artifact@9000827ccba6bdab643e8b6fd33ac0654aef8333 # v8.0.2
        with:
          name: teile
      - run: cat teil-*.txt
EOF
git commit -qam "wk: Runde 6"
git push -q
gh workflow run wk.yml

As soon as the run is finished:

gh run view <ID> --json conclusion --jq .conclusion
gh run view <ID> --log | grep -E 'zusammen.*Z Teil'

Expected:

success
zusammen    Run cat teil-*.txt  ... Teil b

Green – but part a is missing.

Hint: gh api repos/{owner}/{repo}/actions/runs/<ID>/artifacts --jq '.artifacts[].name'.

Solution

gh api repos/{owner}/{repo}/actions/runs/<ID>/artifacts --jq '.artifacts[].name'

Expected:

teile
teile

Both matrix jobs uploaded an artifact named teile – GitHub creates two without complaining. download-artifact with name: teile fetches only one of them. Every job needs a name of its own, and the download fetches all matching ones:

cat > .github/workflows/wk.yml <<'EOF'
name: wk
on: workflow_dispatch
permissions:
  contents: read
jobs:
  r6:
    strategy:
      matrix:
        teil: [a, b]
    runs-on: ubuntu-24.04
    steps:
      - run: echo "Teil ${{ matrix.teil }}" > teil-${{ matrix.teil }}.txt
      - uses: actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9 # v7.0.2
        with:
          name: teil-${{ matrix.teil }}
          path: teil-*.txt
  zusammen:
    needs: r6
    runs-on: ubuntu-24.04
    steps:
      - uses: actions/download-artifact@9000827ccba6bdab643e8b6fd33ac0654aef8333 # v8.0.2
        with:
          pattern: teil-*
          merge-multiple: true
      - run: cat teil-*.txt
EOF
git commit -qam "wk: Runde 6 gelöst"
git push -q
gh workflow run wk.yml

As soon as the run is finished:

gh run view <ID> --log | grep -E 'zusammen.*Z Teil'

Expected:

zusammen    Run cat teil-*.txt  ... Teil a
zusammen    Run cat teil-*.txt  ... Teil b

Older versions of upload-artifact aborted on the second identical name with Conflict. Today it stays silent – which is why a look at the artifact list pays off.

Save your progress? Sign up for free

Round 7: The action that doesn’t exist

cat > .github/workflows/wk.yml <<'EOF'
name: wk
on: workflow_dispatch
permissions:
  contents: read
jobs:
  r7:
    runs-on: ubuntu-24.04
    steps:
      - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b2 # v7.0.1
        with:
          persist-credentials: false
      - run: ls go.mod
EOF
git commit -qam "wk: Runde 7"
git push -q
gh workflow run wk.yml

As soon as the run is finished:

gh run view <ID> --log | grep -o 'Unable to resolve action.*'

Expected:

Unable to resolve action `actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b2`,
unable to find version `3d3c42e5aac5ba805825da76410c181273ba90b2`

Hint: Compare the SHA with Day 9.

Solution

The last character is wrong: …ba90b2 instead of …ba90b1. Nobody types a SHA by hand – fetch it:

gh api repos/actions/checkout/commits/v7.0.1 --jq .sha
sed -i 's/ba90b2 # v7.0.1/ba90b1 # v7.0.1/' .github/workflows/wk.yml
git commit -qam "wk: Runde 7 gelöst"
git push -q
gh workflow run wk.yml

Expected:

3d3c42e5aac5ba805825da76410c181273ba90b1
https://github.com/<du>/notes-actions/actions/runs/41634532754

As soon as the run is finished, the log shows go.mod.

Save your progress? Sign up for free

Round 8: The missing secret

cat > .github/workflows/wk.yml <<'EOF'
name: wk
on: workflow_dispatch
permissions:
  contents: read
jobs:
  r8:
    runs-on: ubuntu-24.04
    steps:
      - env:
          DEPLOY_TOKEN: ${{ secrets.DEPLOY_TOKEN }}
        run: |
          echo "Länge: ${#DEPLOY_TOKEN}"
          test -n "$DEPLOY_TOKEN"
EOF
git commit -qam "wk: Runde 8"
git push -q
gh workflow run wk.yml

As soon as the run is finished:

gh run view <ID> --log | grep 'Z Länge'

Expected:

r8  Run echo "Länge: ${#DEPLOY_TOKEN}"  ... Länge: 0

Hint: gh secret list and gh secret list --env produktion.

Solution

DEPLOY_TOKEN is a secret of the produktion environment (Day 10), not a secret of the repository. A job only sees it with environment: produktion:

cat > .github/workflows/wk.yml <<'EOF'
name: wk
on: workflow_dispatch
permissions:
  contents: read
jobs:
  r8:
    runs-on: ubuntu-24.04
    environment: produktion
    steps:
      - env:
          DEPLOY_TOKEN: ${{ secrets.DEPLOY_TOKEN }}
        run: |
          echo "Länge: ${#DEPLOY_TOKEN}"
          test -n "$DEPLOY_TOKEN"
EOF
git commit -qam "wk: Runde 8 gelöst"
git push -q
gh workflow run wk.yml

Approve as on Day 10. As soon as the run is finished, the log shows Länge: 20.

Missing secrets are empty, not an error – like the output in Round 3. test -n catches both.

Save your progress? Sign up for free

Scoring

Round Mistake Tool that reveals it
1 Invalid YAML zizmor, browser
2 Comparison outside of ${{ }} gh run view -v
3 Typo in the output name test -n in the step
4 Missing permission --log-failed, HTTP 403
5 Pipe without pipefail shell: line in the log
6 Duplicate artifact name Artifact list via gh api
7 Wrong SHA Log, Unable to resolve action
8 Secret in the wrong place test -n, gh secret list

Eight out of eight? Then clean up:

git rm -q .github/workflows/wk.yml
git commit -qm "wk: Wettkampf beendet"
git push -q

Enterprise Note

  • actionlint checks workflows for syntax, expressions and shell errors and would have found Rounds 1, 2 and 3 before the push. Together with zizmor, it belongs in every pull request that changes .github/workflows/.
  • defaults.run.shell: bash at the top level of every workflow prevents Round 5 everywhere.
  • Make errors visible: Empty values that must never be empty are checked by a step with test -n – better a red run than a deployment with an empty version.