INFRASTRUCTURE LEARNINGINFRASTRUCTURE LEARNING
インフラ大全インフラ大全IT INFRASTRUCTURE / LEARNING
Infrastructure learning guide
Find a lesson or lab/

Esc to close · Search terms stay on your device

LEARNING日本語

GITHUB · FOUNDATIONS

GitHub Actions basics: workflows, jobs, runners and permissions

GitHub Actions runs defined processes in response to events and other triggers. Use a proposed SQL change to identify what starts a workflow, where it runs and which privileges it uses. Keep a successful check separate from review, merging and delivery.

What you will learn

Explain events, workflows, jobs, steps and runners, and identify the boundary between untrusted code and privileges.

Prerequisite

A PR proposes integration; checks report validation of a particular target. YAML is a configuration format. No live workflow or runner is created here.

What triggers the work, and where does it run?

A conceptual structure for a PR check
EVENT
A PR is updated

A trigger; the workflow specifies which events it handles.

WORKFLOW
Workflow definition

YAML defines triggers and one or more jobs.

JOB / RUNNER
A job runs on a runner

The runner is the environment; the job is a unit of work on it.

STEPS
Steps inside the job

For example: identify the revision, validate a rule, then report.

These labelled areas distinguish triggering from execution; they are not run logs. Multiple jobs can run concurrently or in a dependency sequence.

An event is a trigger, a workflow the overall definition, a job a unit of work, a step an operation within it, and a runner the execution environment. YAML definitions live under .github/workflows. Manual and scheduled triggers also exist. Code and PR titles become input when a runner handles them.

Jobs do not necessarily run serially in YAML order. Dependencies use needs; independent jobs can run concurrently. Distinguish this from step ordering inside a job. Conditions, failures and skips also affect the execution path.

Identify the revision actually tested

Fictional PR #42 proposes H, adding region = JP to an approved-report query. For a normal pull_request event on an open, mergeable PR, the default ref identifies a test-merge target, labelled T here. H and T differ; a trigger alone does not establish which revision was checked out.

Do not interchange these values
ValueWhat it identifies
GITHUB_REFThe event ref; a test-merge ref for a normal open PR.
GITHUB_SHAThe commit associated with that event ref.
github.event.pull_request.head.shaThe proposed branch head, distinct from a default test-merge commit.

Fix the validation scope too: R-A = approved / JP, R-B = approved / US, R-C = pending / JP. The added AND predicate yields the expected set {R-A}. That fixture does not cover a real database’s collation, NULLs, scale or complete business requirements.

Separate GitHub tokens from AWS authentication

Three credential roles
MaterialPurpose
GITHUB_TOKENA per-job token for GitHub operations on the workflow repository; narrow with permissions.
OIDC identity tokenAn identity assertion for an external service; fetching it requires id-token: write.
Temporary AWS credentialsUsed for AWS API requests after AWS allows role assumption.
Reading a GitHub permission fragment, not a complete workflow
permissions:
  contents: read

Start with the operations a check actually needs, rather than write-all. In this fragment, unspecified permissions become none and no OIDC token retrieval is granted. Determine the required APIs and organization or event constraints for a real job. GitHub write access does not authorize S3 PutObject.

Keep untrusted input away from privileges

Treat PR code, workflow edits and metadata as untrusted until reviewed. Executing an untrusted PR checkout in a privileged pull_request_target or workflow_run context is dangerous. Assess the code, token, secrets and reachable systems, not merely the event name.

Secrets are sensitive values, and log redaction is not guaranteed. A third-party action is executable code: review its provenance, contents, dependencies and privileges. Pinning a reviewed full commit SHA helps control changes but is not a complete safety guarantee.

What does a successful check establish?

  1. Identify the tested revision, environment and defined validation.
  2. Read success, failure or skipped states and check whether the necessary validation ran.
  3. Keep human review and post-merge build, delivery and behavior separate.

Choose an option to see the result and explanation.

Which item is an event that can trigger an Actions workflow?
Read the answer and reason

Answer: A pull request being updated. · An event is a trigger; jobs and steps describe execution.

A workflow defines multiple jobs. How is their order determined?
Read the answer and reason

Answer: Dependencies and conditions govern order; steps belong inside each job. · Distinguish job concurrency from the sequence of steps within a job.

How should permissions be chosen for a job that only reads repository source?
Read the answer and reason

Answer: Limit GitHub rights for the task and separate AWS and secret access. · Consider only needed rights such as contents: read, separately from external federation.

What should be avoided when a privileged workflow handles an external PR?
Read the answer and reason

Answer: Checking out and executing unreviewed PR code. · Untrusted code can gain access to secrets, privileged tokens or the runner.

Check, then explain in your own words

  1. Explain each role from event to job and step.
  2. Separate source-reading privileges from deployment privileges.
  3. Distinguish the tested revision from a later artifact.
Check your understanding: Does a successful check of T mean an artifact from M was deployed?

No. Verify the build from integrated M and delivery of that artifact separately.

Completing a defined check of one target does not establish later operations.

Sources and conditions checked

Primary references are collected here with their scope, conditions and corresponding sections. Independent expert review and live-environment validation have not been performed.