Assignments
25 practical assignments across GitHub Actions, Jenkins and GitLab CI
How to use these
Do them in order inside each level. Work in your own repository, commit each assignment in its own folder or branch, and keep the pipeline run URL as evidence. If you get stuck, open the hint; try for at least 20 minutes first. Assignment 21 builds on the hands-on lab.
🟢 Level 1: Beginner (Assignments 1-10)
Assignment 1. Your first workflow 🟢
Objective: Run a GitHub Actions workflow on every push.
Tasks
- Create a repo with a
README.mdand ahello.shscript that prints the current date. - Add
.github/workflows/hello.ymltriggered onpushandworkflow_dispatch. - Make one step run
./hello.shand another print${{ github.sha }}and${{ github.actor }}. - Trigger the workflow from the UI and from a push.
Expected outcome / acceptance criteria
- The Actions tab shows a green run for both triggers.
- The log shows the commit SHA and your username.
Hints
Use runs-on: ubuntu-latest, actions/checkout@v4 and remember chmod +x hello.sh before committing (or run bash hello.sh).
Bonus: Add a schedule trigger with a cron expression and note that scheduled runs only fire on the default branch.
Assignment 2. Lint and test a small app 🟢
Objective: Fail the pipeline when lint or tests fail.
Tasks
- Create a small Python or Node app with two unit tests and a linter (
rufforeslint). - Write a workflow that installs dependencies, lints, then tests.
- Push a commit with a lint error and confirm the run fails.
- Fix it and confirm the run turns green.
Expected outcome / acceptance criteria
- Failing lint stops the job before tests run.
- The failing step name is visible in the run summary.
Hints
Each run step fails the job on a non-zero exit code. Order cheap checks first so failures are fast.
Bonus: Upload the test report with actions/upload-artifact@v4 even on failure using if: always().
Assignment 3. Dependency caching 🟢
Objective: Cut install time with a cache.
Tasks
- Take the app from the previous assignment.
- Enable caching using
actions/setup-node@v4(cache: npm) oractions/setup-python@v5(cache: pip). - Run the workflow twice and compare install step durations.
- Write the two timings in your repo README.
Expected outcome / acceptance criteria
- The second run logs a cache hit.
- Install time is visibly lower.
Hints
The cache key is derived from the lockfile hash, so you must commit package-lock.json or requirements.txt pinned versions.
Bonus: Replace the built-in cache with an explicit actions/cache@v4 step and a custom key with restore-keys.
Assignment 4. Secrets and variables 🟢
Objective: Use secrets and variables correctly and prove they are masked.
Tasks
- Create a repository secret
API_TOKENand a repository variableAPP_ENV=staging. - Write a workflow that prints
APP_ENVand usesAPI_TOKENin an environment variable of a step. - Try to
echothe secret and observe the log. - Explain in a short note why masking is not a security boundary.
Expected outcome / acceptance criteria
- The log shows
***instead of the secret value. - The variable value prints in clear text.
Hints
Reference with ${{ secrets.API_TOKEN }} and ${{ vars.APP_ENV }}. Pass secrets via env:, not by interpolating into the script body.
Bonus: Show how a base64-encoded secret printed in two halves leaks despite masking, then explain why OIDC removes the problem.
Assignment 5. Build a Docker image in CI 🟢
Objective: Build and tag an image in a workflow.
Tasks
- Write a Dockerfile for the app.
- Add a workflow job that runs
docker buildwith tagapp:${{ github.sha }}. - Run the image with
docker run -d -p 8080:8080in the job andcurlthe health endpoint. - Stop the container at the end.
Expected outcome / acceptance criteria
- The job fails if
curl -freceives a non-2xx response. - The image tag equals the commit SHA.
Hints
Use curl -fsS --retry 5 --retry-connection-refused localhost:8080/healthz to give the app time to start.
Bonus: Switch to docker/build-push-action@v6 with load: true.
Assignment 6. Push to GitHub Container Registry 🟢
Objective: Publish an image to ghcr.io with the built-in token.
Tasks
- Add
permissions: packages: writeto the job. - Log in with
docker/login-action@v3usingregistry: ghcr.io,username: ${{ github.actor }},password: ${{ secrets.GITHUB_TOKEN }}. - Push
ghcr.io/<owner>/<repo>:<sha>and:latest. - Pull the image locally and run it.
Expected outcome / acceptance criteria
- The package appears under the repository's Packages.
docker runof the pulled image works.
Hints
The image name must be lowercase. Use ${{ github.repository }} and lowercase it in a shell step if needed.
Bonus: Use docker/metadata-action@v5 to generate tags automatically (branch, sha, semver).
Assignment 7. Matrix build 🟢
Objective: Test across several runtime versions in parallel.
Tasks
- Add
strategy.matrixwith three Node (or Python) versions. - Pass the version into
setup-node. - Make one version intentionally fail and observe the others.
- Set
fail-fast: falseand compare behavior.
Expected outcome / acceptance criteria
- Three parallel jobs appear in the run graph.
- With
fail-fast: falsethe other versions complete even if one fails.
Hints
Reference the value as ${{ matrix.node }}. The job name can include it for readable logs.
Bonus: Add an include entry that tests an experimental version with continue-on-error: true.
Assignment 8. Hello Jenkins pipeline 🟢
Objective: Run a declarative pipeline in Jenkins.
Tasks
- Start Jenkins with
docker run -p 8080:8080 -v jenkins_home:/var/jenkins_home jenkins/jenkins:lts-jdk17. - Complete the setup wizard and install the suggested plugins.
- Create a Pipeline job that reads a
Jenkinsfilefrom your Git repository. - Write stages
Build,Test,Packagethat echo messages and archive a text file.
Expected outcome / acceptance criteria
- The Stage View shows three green stages.
- The archived file is downloadable from the build page.
Hints
Initial admin password: docker exec <container> cat /var/jenkins_home/secrets/initialAdminPassword. Use pipeline { agent any ... }.
Bonus: Add a post { always { cleanWs() } } block (Workspace Cleanup plugin).
Assignment 9. Hello GitLab CI 🟢
Objective: Run a pipeline with stages in GitLab.
Tasks
- Create a project on gitlab.com.
- Write
.gitlab-ci.ymlwith stagesbuild,test,deploy. - Make
testrun two jobs in parallel. - Add an artifact produced in
buildand consumed intest.
Expected outcome / acceptance criteria
- Pipeline graph shows build then two parallel test jobs then deploy.
- The test job can read the build artifact.
Hints
Artifacts from earlier stages are downloaded automatically by later stages. Use artifacts: paths: [dist/] and expire_in: 1 week.
Bonus: Restrict deploy with rules: - if: $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH.
Assignment 10. Status badge and branch protection 🟢
Objective: Make CI results enforceable.
Tasks
- Add the workflow status badge to your README.
- Enable branch protection on
main: require a pull request and the lint-test check. - Open a PR with a failing test and try to merge it.
- Fix the test and merge.
Expected outcome / acceptance criteria
- The merge button is blocked while the check fails.
- The README badge turns green after the merge.
Hints
The required check name is the job name (or workflow / job for reusable workflows). A check must have run at least once to be selectable.
Bonus: Enable 'Require branches to be up to date' and observe how a second PR must rebase.
🟡 Level 2: Intermediate (Assignments 11-20)
Assignment 11. Reusable workflow 🟡
Objective: Remove duplication using workflow_call.
Tasks
- Create
.github/workflows/test.ymlwithon: workflow_calland inputsnode-versionandworking-directory. - Call it from a second workflow for two directories of a monorepo.
- Return an output (for example the coverage percent) and print it in the caller.
- Document inputs in a comment header.
Expected outcome / acceptance criteria
- Both callers reuse the same logic.
- The caller prints the output value.
Hints
Call with uses: ./.github/workflows/test.yml and with:. Pass secrets with secrets: inherit or explicitly.
Bonus: Move it to a central repository and call it as org/ci-workflows/.github/workflows/test.yml@v1.
Assignment 12. Concurrency and path filters 🟡
Objective: Avoid wasted runs in a monorepo.
Tasks
- Create
services/apiandservices/webdirectories. - Use
on.push.pathsso each workflow runs only for its folder. - Add
concurrencywithcancel-in-progressfor pull requests. - Push rapid commits and show cancelled runs.
Expected outcome / acceptance criteria
- Changing only
services/webdoes not trigger the API workflow. - Superseded PR runs show 'Cancelled'.
Hints
Do not cancel runs on main that might be mid-deploy: cancel-in-progress: ${{ github.event_name == 'pull_request' }}. Remember path filters and required checks interact: a skipped workflow leaves a required check pending.
Bonus: Use dorny/paths-filter to compute changed folders and a final ci-ok job that required checks can point to.
Assignment 13. Docker layer cache in CI 🟡
Objective: Speed up image builds with BuildKit cache.
Tasks
- Write a Dockerfile that copies the dependency manifest before the source.
- Use
docker/setup-buildx-action@v3anddocker/build-push-action@v6withcache-from: type=ghaandcache-to: type=gha,mode=max. - Run twice with a source-only change and note cached layers in the log.
- Record build durations before and after.
Expected outcome / acceptance criteria
- Log lines show
CACHEDfor dependency layers. - A source-only change skips the dependency install.
Hints
Cache hit requires identical layer inputs. Look for CACHED [stage N/M] in the build output.
Bonus: Switch to a registry cache (type=registry,ref=...:buildcache) and compare.
Assignment 14. Trivy gate 🟡
Objective: Block vulnerable images and handle exceptions.
Tasks
- Add a Trivy step scanning the built image with
severity: HIGH,CRITICALandexit-code: 1. - Use an outdated base image and confirm the failure.
- Update the base image and confirm success.
- Add a
.trivyignoreentry for one CVE with a comment and expiry date, and explain when this is acceptable.
Expected outcome / acceptance criteria
- Old base image fails the job with a CVE table.
- The ignored CVE no longer fails the build.
Hints
Use ignore-unfixed: true for actionable results. Scan the final image, not only the source tree. Also try trivy fs . and trivy config . for IaC.
Bonus: Upload results as SARIF (format: sarif) to the Security tab with github/codeql-action/upload-sarif@v3.
Assignment 15. CodeQL and Dependabot 🟡
Objective: Add code scanning and automated dependency updates.
Tasks
- Enable CodeQL with a workflow for your language.
- Introduce an obvious SQL injection or
evalof user input and confirm an alert. - Add
.github/dependabot.ymlfor the package ecosystem,dockerandgithub-actions, weekly. - Merge one Dependabot PR.
Expected outcome / acceptance criteria
- The alert appears under Security, Code scanning.
- Dependabot opens PRs including one for an action version.
Hints
CodeQL needs security-events: write. For compiled languages set a build mode. Dependabot config is YAML with version: 2 and updates: entries.
Bonus: Group Dependabot updates and auto-merge patch bumps only when checks pass.
Assignment 16. AWS OIDC from GitHub 🟡
Objective: Authenticate to AWS without stored keys.
Tasks
- Create the IAM OIDC provider for
token.actions.githubusercontent.com. - Create a role whose trust policy matches
repo:ORG/REPO:ref:refs/heads/mainwithaudsts.amazonaws.com. - Use
aws-actions/configure-aws-credentials@v4and runaws sts get-caller-identity. - Run from a feature branch and capture the failure message.
Expected outcome / acceptance criteria
- Main branch run prints the assumed role ARN.
- Feature branch run fails with
Not authorized to perform sts:AssumeRoleWithWebIdentity.
Hints
The job needs permissions: id-token: write. If it declares an environment, the sub becomes repo:ORG/REPO:environment:NAME.
Bonus: Restrict by job_workflow_ref so only a specific reusable workflow can assume the role.
Assignment 17. Environments and approvals 🟡
Objective: Gate production behind a human.
Tasks
- Create
stagingandproductionenvironments. - Add required reviewers and a deployment branch restriction (
main) toproduction. - Add environment-specific secrets with the same name in each.
- Write a workflow whose second job targets
productionand prints which secret scope it sees.
Expected outcome / acceptance criteria
- The production job waits for approval.
- Each job reads its own environment's secret value.
Hints
Use environment: production at job level. Wait timers and required reviewers are configured per environment. Private repos need a paid plan for reviewers.
Bonus: Add a wait timer and use the deployment URL in the environment declaration.
Assignment 18. Declarative Jenkinsfile with parallel stages and credentials 🟡
Objective: Build a realistic Jenkins pipeline.
Tasks
- Write a Jenkinsfile with
options { timeout, disableConcurrentBuilds }. - Run unit tests and lint in a
parallelblock. - Store a token as a Jenkins credential and use
withCredentials([string(...)]). - Verify the token is masked in the console log.
Expected outcome / acceptance criteria
- Stage View shows parallel branches.
- Console output shows
****for the token.
Hints
Credential IDs are referenced by string. Use parallel { stage('Unit') {...} stage('Lint') {...} } inside a stage.
Bonus: Run the build on a Docker agent: agent { docker { image 'node:22-alpine' } }.
Assignment 19. Jenkins shared library 🟡
Objective: Reuse pipeline code across jobs.
Tasks
- Create a Git repo with
vars/buildApp.groovydefiningdef call(Map cfg). - Register it in Manage Jenkins, System, Global Trusted Pipeline Libraries.
- Load it with
@Library('shared@main') _and callbuildApp(name: 'demo')from two Jenkinsfiles. - Change the library and see both pipelines change behavior.
Expected outcome / acceptance criteria
- Two different repos use the same library function.
- A library change alters both builds without touching their Jenkinsfiles.
Hints
Files in vars/ become global steps named after the file. Pin to a tag or branch you control to avoid surprise breakage.
Bonus: Add resources/ with a shell script loaded through libraryResource.
Assignment 20. GitLab CI rules, needs and environments 🟡
Objective: Model a branching pipeline in GitLab.
Tasks
- Create jobs
lint,test,build,deploy-staging,deploy-prod. - Use
needs:sobuildstarts as soon astestpasses (DAG). - Use
rules:so deploy jobs run only on the default branch, anddeploy-prodiswhen: manual. - Define
environment:with a name and URL for both deploys.
Expected outcome / acceptance criteria
- The pipeline graph shows DAG dependencies.
- Production deploy waits for a manual click; Environments page lists both.
Hints
rules replace only/except. A manual job on a protected environment can also require approvals. Merge request pipelines need if: $CI_PIPELINE_SOURCE == "merge_request_event".
Bonus: Add include: template: Security/SAST.gitlab-ci.yml and review findings.
🔴 Level 3: Advanced (Assignments 21-25)
Assignment 21. Full pipeline to EKS 🔴
Objective: Deliver the complete lab as your own project.
Tasks
- Complete the hands-on lab with your own application.
- Add a Helm chart or Kustomize overlays instead of
envsubst. - Make prod deploy use the image digest instead of the tag (
image@sha256:...). - Document the architecture with a Mermaid diagram in your repo.
Expected outcome / acceptance criteria
- Dev deploys automatically; prod needs approval and uses a digest.
- No long-lived cloud credentials exist anywhere in the repo settings.
Hints
Get the digest from docker/build-push-action output digest. Pin by digest to guarantee prod runs exactly what was scanned.
Bonus: Add Argo CD: the pipeline commits the new image reference to a config repo and Argo syncs it.
Assignment 22. Canary with automated rollback 🔴
Objective: Deliver progressively and roll back on bad metrics.
Tasks
- Install Argo Rollouts and Prometheus on a test cluster.
- Convert the Deployment to a
Rolloutwith stepssetWeight: 10,pause,setWeight: 50,pause. - Add an
AnalysisTemplatethat queries the HTTP 5xx ratio from Prometheus. - Deploy a version that returns 500 errors and show the rollout aborting automatically.
Expected outcome / acceptance criteria
- Healthy versions progress to 100 percent.
- The faulty version is aborted and traffic returns to the stable ReplicaSet.
Hints
Use kubectl argo rollouts get rollout app --watch. A successCondition such as result[0] < 0.05 drives pass or fail. Without a traffic router, weights are approximated by pod counts.
Bonus: Add header-based routing for internal testers through an ingress or service mesh.
Assignment 23. Supply chain hardening 🔴
Objective: Make the pipeline resistant to tampering.
Tasks
- Pin every third-party action to a full commit SHA and add Dependabot to update them.
- Set top-level
permissions: {}and grant per-job minimum scopes. - Generate an SBOM with Syft or
docker buildx --sbom=true, and sign the image with Cosign keyless. - Verify the signature with
cosign verifyconstrained by certificate identity and OIDC issuer.
Expected outcome / acceptance criteria
cosign verifysucceeds only for images built by your workflow.- A scan of the workflows shows no unpinned third-party actions.
Hints
Keyless signing needs id-token: write. Verify with --certificate-identity-regexp and --certificate-oidc-issuer https://token.actions.githubusercontent.com.
Bonus: Enforce signatures at admission with Kyverno verifyImages or Sigstore policy-controller.
Assignment 24. Self-hosted autoscaling runners 🔴
Objective: Run CI on your own Kubernetes capacity.
Tasks
- Install Actions Runner Controller (gha-runner-scale-set) with Helm on a test cluster.
- Register a scale set against your repository using a GitHub App or PAT.
- Point a workflow at it with
runs-on: <scale-set-name>and show runner pods appearing and disappearing. - Document how you would isolate untrusted pull requests.
Expected outcome / acceptance criteria
- Runner pods scale from zero on demand and terminate after the job.
- Your isolation notes cover fork PRs, network egress and ephemeral runners.
Hints
Scale sets use minRunners and maxRunners. Never run fork PRs on persistent self-hosted runners; use ephemeral runners with no cloud credentials.
Bonus: Mount a BuildKit cache volume or run a registry cache to recover build speed.
Assignment 25. Pipeline observability and DORA metrics 🔴
Objective: Measure the delivery system itself.
Tasks
- Export workflow run data with the GitHub API (
gh api repos/ORG/REPO/actions/runs) into a CSV or a time-series store. - Compute deployment frequency, lead time for changes, change failure rate, and mean time to restore for the last 30 days.
- Build a dashboard showing p50 and p90 pipeline duration and queue time.
- Identify the slowest job and cut its duration by at least 30 percent, documenting what you changed.
Expected outcome / acceptance criteria
- The dashboard shows all four DORA metrics.
- A before and after comparison proves the speed-up.
Hints
Lead time is first commit to production deploy. Count a failure as a deployment followed by a rollback or hotfix. Queue time is started_at - created_at on the job.
Bonus: Alert when pipeline p90 duration regresses by 20 percent week over week.