CD7: CI pipelines with GitHub Actions

Lesson 4 of 5 · reading 15–25 minutes; practice and project time is on the module page

Secrets, environments and cloud access

🎯You'll be able to

Store secrets for workflows, protect production with a GitHub environment that needs approval, and reach a cloud with OIDC instead of a key.

🏠The everyday picture

A bank locker needs two keys: yours and the bank officer's. The officer checks your identity each visit; you don't get a permanent copy of their key to take home.

📘What it really is

📝A worked example

Input: compare two deploy setups for RouteRani: (a) AWS_ACCESS_KEY_ID and AWS_SECRET_ACCESS_KEY as repository secrets with no environment; (b) an OIDC role trusted for the production environment, which requires one reviewer and only allows main.

Expected output: in (a), any workflow on any branch can read the keys, and a leaked key works until someone deletes it. In (b), a deploy needs a person's approval, only main can deploy, the job's credentials expire after about an hour, and nothing long-lived is stored. (b) also shows who approved each production deploy.

🌍Where it's used

📝Case scenario

An intern's experimental branch at a logistics company included a workflow that deployed to production, because the production cloud keys were repository secrets available to every branch. A typo in the branch's Terraform removed a queue. Afterwards, production keys moved to an environment that allowed only main and needed approval, and then to OIDC, so no keys were stored at all.

🖱️Try it

In GitHub, open a repository's Settings, then Environments, and read the options for a new environment (you don't have to save it). Success: you can name where required reviewers, deployment branches and environment secrets are set.

⚠️Common mistakes

🛠️For your project

Project 2 test 4 checks the deploy job uses an environment. In your capstone write-up, describe the reviewers and OIDC trust you'd set for RouteRani's production.

✅Quick check

What does a GitHub environment add to a job?

Show the answer

Rules such as required reviewers, allowed branches and environment-only secrets.

What permission does a job need to use OIDC?

Show the answer

id-token: write.

← PreviousKeeping workflows secure
ProLearners Assist