liveBook · Manning

GitHub action

As explained in Learn Docker in a Month of Lunches, Second Edition

A GitHub Action is a reusable automation component that performs a step or operation within a GitHub Actions workflow.

A GitHub Action is a reusable automation component used as a step in a GitHub Actions workflow. Actions can check out repositories, build code, review code, or prepare deployment environments on a hosted runner. section 16.1

Use actions to assemble workflow automation, while keeping substantial application logic in scripts:

  • Define the workflow in YAML inside the repository. section 16.1
  • Reference an action with a uses entry, such as actions/checkout@master. section 16.1
  • Prefer scripts for most build logic when portability, local debugging, or migration to another build provider matters. section 16.1

Creating a Kubernetes test cluster

A deployment workflow can use AbsaOSS/k3d-action@v2 to create a single-node Kubernetes cluster on the GitHub runner, then run kubectl config use-context k3d-ch16. The action packages k3d setup so the workflow does not install and configure the tool separately. section 16.4

Listing 16.5 Running a test Kubernetes cluster with k3d
# this creates a single-node Kubernetes cluster in a container:
- name: create-cluster
  uses: AbsaOSS/k3d-action@v2
  with:
    cluster-name: ch16
    args: >-
      --agents 1
      --no-lb
      --k3s-arg "--no-deploy=traefik,servicelb,metrics-server"

# and this sets the Kubectl CLI to use that cluster:
- name: set-context
  run: |
    kubectl config use-context k3d-ch16

Inspect the complete action configuration for creating the cluster and selecting its Kubernetes context. section 16.4

Actions are convenient but specific to GitHub workflow YAML. Keeping the main logic in PowerShell or other scripts makes it runnable locally and easier to move between CI/CD services. section 16.1

How Learn Docker in a Month of Lunches, Second Edition covers it

How deep it goes
Demonstrates YAML references and a k3d deployment action, but defers action implementation internals.
Examples
Uses repository checkout, PowerShell builds, and a community k3d action that creates a temporary Kubernetes cluster.
What it assumes
Assumes GitHub and Git familiarity while requiring YAML workflow files and optionally PowerShell, Docker, kubectl, and Helm.
What you can do after
Builds workflows with referenced actions and combines them with locally testable scripts.
How it connects
Connects GitHub actions with workflows, YAML, runners, scripts, Kubernetes, k3d, kubectl, and Helm.

Also explained in

Compare how 3 books explain GitHub action →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Learn Docker in a Month of Lunches, Second Edition. The section links point to the parts of the book it draws on.