Skip to content
watch on youtubeThe notes below cover everything in the video. Find it in the playlist on our channel.Open the YouTube channel
Lesson 9 of 109 min video

CI/CD with GitHub Actions and AWS (OIDC)

Build a GitHub Actions pipeline that tests and deploys to AWS on every push, using OIDC and an IAM role instead of access keys.

Video chapters

  1. 00:00Intro
  2. 00:46What CI/CD actually means
  3. 01:59GitHub Actions in five words
  4. 02:55No access keys: how OIDC works
  5. 03:59Step 1: Trust GitHub, in AWS
  6. 05:07Step 2: The deploy workflow
  7. 06:02Step 3: The steps that deploy
  8. 07:00Step 4: Push, watch, and fix
  9. 08:16From deploy script to real pipeline
  10. 09:13git push is now your deploy button

Manual deploys are slow and error-prone. In this episode you build a pipeline: every push to main runs checks and deploys the S3 website from Episode 5, authenticating to AWS through OIDC, so no access keys are stored in GitHub at all.

What you need

  • A GitHub account and a repository with your site folder
  • The S3 bucket from Episode 5 (or create a new one)
  • Your AWS admin user

What CI/CD actually means

First, what does CI/CD actually mean?

Continuous integration means every change is automatically built and tested, as soon as it's pushed. Problems show up within minutes, while the change is still fresh in your mind.

Continuous delivery, or deployment, means every change that passes the tests is ready to go to production, or goes there automatically.

The pipeline is the series of automated steps: get the code, test it, build it, and deploy it.

And a trigger starts the pipeline, like a push, a pull request, a schedule, or a manual button.

The payoff is that deploys become small, frequent, and boring. And boring is exactly what you want from deploys. When each change is small, finding and undoing a bad one is easy.

There are many CI/CD tools: GitLab CI, Jenkins, CircleCI, and AWS's own CodePipeline. We use GitHub Actions because your code probably already lives on GitHub, it's free for public repositories, and it includes a monthly allowance of free minutes for private ones. The ideas, triggers, jobs, steps, and short-lived credentials, are the same in every tool.

Quick reference

  • Continuous Integration: Every change is built and tested automatically
  • Continuous Delivery: Every passing change is ready, or goes, to production
  • Pipeline: The automated steps: checkout → test → build → deploy
  • Trigger: Push, pull request, schedule, or a button
  • Payoff: Small, frequent, boring deploys. Easy rollbacks

GitHub Actions in five words

GitHub Actions has five words to know. A workflow is a YAML file, stored in the dot github slash workflows folder of your repository.

The on section is the trigger. It says when the workflow runs.

A job is a group of steps that run on one machine.

Here's the smallest useful workflow. On every push, one job checks out the code, and runs two commands. Commit this file, push, and open the actions tab in GitHub. You'll see it run, live, with every line of output.

A step is either a shell command, with run, or a reusable action that someone published, with uses. actions slash checkout, for example, downloads your repository onto the machine.

And the runner is the machine that does the work. Ubuntu latest is a fresh Linux virtual machine that GitHub provides, and throws away after each run.

Quick reference

  • Workflow: A YAML file in .github/workflows/
  • Trigger (on): When it runs: push to main, PRs…
  • Job: A group of steps on one machine
  • Step: A command (run) or a reusable action (uses)
  • Runner: The machine GitHub provides: ubuntu-latest

.github/workflows/hello.yml

name: hello
on: push
jobs:
  say-hi:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
      - run: echo "Hello from CI"
      - run: ls -la

No access keys: how OIDC works

Now, how does the pipeline get permission to deploy to AWS? The old way was to create an access key, and paste it into GitHub as a secret. That key never expires, it can be leaked, and it often has far too many permissions. Let's do it the modern way, with OIDC.

When your workflow runs,

GitHub gives it a short-lived, signed token that says, in effect: I am this repository, running on this branch.

The workflow presents that token to AWS's security token service.

AWS checks it against an I A M role that you created, which only trusts tokens from your specific repository and branch.

If everything matches, AWS hands back temporary credentials, valid for about an hour.

And the workflow uses them to deploy to S3. Nothing secret is stored in GitHub, and even if someone copied those credentials, they'd expire soon. This is the same role pattern you used on EC2, now applied to your pipeline.

Quick reference

GitHub Actions → OIDC token → AWS STS → IAM role → Temp credentials → S3 bucket

Step 1 · Trust GitHub, in AWS

Step one: tell AWS to trust GitHub. In I A M, open identity providers, and add an OpenID Connect provider.

The provider U R L is token dot actions dot github user content dot com.

And the audience is s t s dot amazon a w s dot com. You only do this once per AWS account.

Next, create a role. Choose web identity as the trusted entity, and select the provider you just added.

The console then asks for your GitHub organization or user name, the repository, and optionally the branch. Fill in all three.

That creates a trust policy with a condition like this one. It only accepts tokens whose subject is your repository, on the main branch. Without this condition, other people's repositories could use your role, so never skip it.

For permissions, attach a small policy that allows listing, uploading and deleting objects in your one website bucket, and nothing else. Copy the role's A R N. The workflow needs it next.

Quick reference

  1. IAM → Identity providers → Add → OpenID Connect
  2. URL: https://token.actions.githubusercontent.com
  3. Audience: sts.amazonaws.com
  4. IAM → Roles → Web identity → this provider
  5. Limit to: your org/user, repo, branch main
  6. Permissions: s3 sync to ONE bucket only

trust condition · the key line

"StringLike": {
  "token.actions.githubusercontent
   .com:sub":
   "repo:you/acme-site:ref:refs/
    heads/main"
}

Step 2 · The deploy workflow

Step two: the workflow file. First, store the role's A R N in your GitHub repository, under settings, as an actions variable called AWS role A R N.

Now create the deploy workflow file. Here's the top half.

The trigger: only pushes to the main branch. Pushes to other branches won't deploy, and they couldn't anyway, because our role only trusts main.

The permissions section is easy to forget, and without it, OIDC fails. id token write allows the job to request the OIDC token from GitHub. contents read lets it check out the code. Workflows should ask for the fewest permissions they need, just like I A M roles.

Notice we stored the role A R N as a plain variable, not a secret. An A R N isn't sensitive on its own. The security comes from the trust policy, not from hiding the name.

Quick reference

  1. GitHub repo → Settings → Variables: AWS_ROLE_ARN
  2. Trigger: only pushes to main
  3. id-token: write lets the job request the OIDC token
  4. A variable, not a secret: the ARN isn't sensitive

.github/workflows/deploy.yml

name: deploy
on:
  push:
    branches: [main]
permissions:
  id-token: write   # needed for OIDC
  contents: read
jobs:
  deploy:
    runs-on: ubuntu-latest
    steps: ...  (next slide)

Step 3 · The steps that deploy

Step three: the steps. Here's the bottom half of the file.

First, check out the code.

Then, the official AWS action, configure AWS credentials. Give it the role to assume, from our variable, and your region. Behind the scenes, it does the whole OIDC exchange we just discussed. Check the action's page for the latest major version when you set this up.

Next, aws s t s get caller identity. It's the same who am I command from episode three, and it prints the role the pipeline is using. It's a great debugging line to keep.

And finally, the deploy itself: sync only the site folder to the bucket. Dash dash delete removes files from the bucket that no longer exist in the folder, so the bucket matches your repository exactly. Thanks to versioning, which we enabled in episode five, even a bad deploy can be recovered.

Quick reference

  1. Checkout the code
  2. Assume the role via OIDC
  3. Prove who we are (great for debugging)
  4. Sync ./site only, with --delete

deploy.yml · steps

steps:
  - uses: actions/checkout@v4
  - uses: aws-actions/
      configure-aws-credentials@v4
    with:
      role-to-assume:
        ${{ vars.AWS_ROLE_ARN }}
      aws-region: eu-central-1
  - run: aws sts get-caller-identity
  - run: aws s3 sync ./site
      s3://acme-site-2026 --delete

Step 4 · Push, watch, and fix

Step four: push it, and watch. Commit the workflow file, and push to main.

Open the actions tab. You'll see the run, and each step, with its full output.

When it's green, change a line in your index dot html, push again, and refresh your website a minute later. That's continuous deployment. From now on, git push is your deploy button.

The most common error is not authorized to perform assume role with web identity.

It almost always means the trust policy's repository or branch doesn't match exactly, or the id token write permission is missing. Compare them character by character, including upper and lower case.

And rolling back is just Git. Revert the bad commit, and push. The pipeline deploys the previous version. No special tools, no panic.

One more habit. When a pipeline fails, read the logs from the top of the failed step, not just the last red line. The real cause is often a few lines earlier, like a wrong folder name or a missing file. And when you fix it, fix it in the workflow file and push, never by deploying manually just this once. Manual exceptions are how pipelines and reality drift apart.

Quick reference

  1. git add . && git commit -m "ci: deploy" && git push
  2. GitHub → Actions tab → watch each step
  3. Green: change index.html, push again, refresh site
  4. “Not authorized to perform sts:AssumeRoleWithWebIdentity”
  5. → check repo/branch in the trust policy + id-token: write
  6. Rollback: git revert <commit> && git push

From deploy script to real pipeline

What we built is a deploy pipeline. Here's how teams grow it into a real one.

Test before deploying. Add a test job, and make the deploy job depend on it, using needs. If the tests fail, nothing is deployed.

Run checks on pull requests too. Every pull request gets tested before anyone merges it, and only main deploys.

Use environments, like staging and production, each with its own role. GitHub can require a person to approve before the production job runs.

For containers, the same pattern builds a Docker image, pushes it to E C R with the commit's hash as the tag, and updates an E C S service. Everything you learned in episode seven, now automated.

And for Terraform, a very common setup runs plan on every pull request, so reviewers see the changes, and apply only after merging to main.

Quick reference

  • Test before deploy: A test job; deploy only if it passes (needs:)
  • Pull request checks: Run tests on every PR, deploy only from main
  • Environments: staging → production, with manual approval
  • Containers: Build → push to ECR → update the ECS service
  • Terraform: plan on PRs, apply on main

git push is now your deploy button

Let's recap. You learned what CI/CD means, and why small, boring deploys are the goal.

You learned GitHub Actions: workflows, triggers, jobs, steps, and runners.

You connected GitHub to AWS with OIDC, so your pipeline uses short-lived credentials, with no access keys stored anywhere.

You applied least privilege twice: a role that trusts one repository and branch, with permission for one bucket.

And you can roll back with a simple git revert. In the final episode of this course, we make sure everything you deploy stays healthy and affordable, with CloudWatch monitoring, alarms, and cost control. The notes, with the full workflow file and trust policy, are linked in the description.

Quick reference

  • CI/CD: Automated test + deploy on every change
  • GitHub Actions: Workflow, trigger, jobs, steps, runners
  • OIDC: Short-lived credentials, no keys in GitHub
  • Least privilege: Role trusts one repo + branch; one bucket
  • Rollback: git revert, push, done

Practice

  1. Add a job that runs on pull requests and only checks the HTML (no deploy).
  2. Add a CloudFront invalidation step after the sync.
  3. Restrict the role so it only works from the main branch, then try deploying from another branch.

Next episode

Episode 10: monitoring and cost control with CloudWatch and AWS Budgets.

Key takeaways

  • CI builds and tests every change; CD ships passing changes automatically
  • A GitHub Actions workflow is made of triggers, jobs, steps and runners
  • OIDC gives the pipeline short-lived AWS credentials, so no access keys live in GitHub
  • Scope the IAM role to one repo, one branch and only what it deploys