AWS + GITHUB
HOW A WEB GAME SHIPS ITSELF

GitHub holds the code and runs GitHub Actions. On every push to master a workflow signs in to AWS, syncs the static game to an S3 bucket and clears the CloudFront cache, so players get the new build in minutes. Here is the exact setup behind Super Soldier Battle.

✓ FREE Level 2 · Intermediate GitHub ActionsS3 + CloudFrontOIDC

By Shane Brumback · Updated November 2, 2026 · Published June 11, 2023 · about 12 minute read

See it live

LIVE DEMO

The 3D pipeline on the right of this page is a live Three.js scene: each glowing packet is a commit travelling from GitHub through Actions into S3 and out through CloudFront to players. Launch it full screen to drag to orbit and scroll to zoom. Launch asks for a free Google sign-in first. Press Esc or Exit to return.

Free Google sign-in · Orbit: drag · Zoom: scroll · Esc to exit

How do AWS and GitHub work together? (Quick Answer)

GitHub holds the code and runs GitHub Actions. On every push to master a workflow signs in to AWS (with an OIDC role or stored secrets), syncs the static site to an S3 bucket, and invalidates CloudFront so players get the new build in minutes. A second workflow tests and deploys Lambda functions with AWS SAM, only when backend folders change. Real-time features run on API Gateway WebSockets, Lambda and DynamoDB, with an always-on relay server on EC2 for fast multiplayer traffic.

Introduction

The 2023 version of this article listed ten generic advantages of using AWS with GitHub. True, but not very useful. This rewrite shows a working pipeline instead: the one that deploys this site, Super Soldier Battle and games like Tommy Gun FPS and Zombie Attack every day.

The idea is simple. GitHub is the single source of truth, and nobody uploads files by hand. Every change is a commit, every commit to master is a deploy, and every deploy can be rolled back with git revert.

If you build Three.js games, start with developing online 3D browser games, then come back here when it is time to ship.

Key Concepts

  • GitHub Actions — YAML workflows in .github/workflows that run on GitHub servers when you push, on a schedule or by hand.
  • S3 + CloudFront — S3 stores the static files (HTML, JS, textures). CloudFront is the CDN that serves them fast and over HTTPS worldwide.
  • Cache invalidation — CloudFront keeps copies at the edge. A deploy ends with create-invalidation so players do not get yesterday's JavaScript.
  • AWS SAM — a template.yaml that describes Lambda functions, API routes and DynamoDB tables. sam deploy creates or updates them as one CloudFormation stack.
  • Path filters — paths: in a workflow means the Lambda deploy only runs when backend folders change, so a CSS fix never touches the payment code.
  • OIDC vs access keys — OIDC lets a workflow assume an IAM role with short-lived credentials. Access keys in repository secrets also work but must be rotated and kept least-privilege.
  • WebSocket API + relay — API Gateway WebSockets with Lambda handle connect, disconnect and messages serverlessly. A small EC2 relay keeps one always-on socket server for low-latency game state.

The Super Soldier Battle Stack, Piece by Piece

PieceAWS serviceHow GitHub ships it
Game pages, Three.js code, texturesS3 + CloudFrontdeploy.yml on every push to master
3D models (GLB)S3Uploaded only when the file size changes, so big models are not re-sent every deploy
Sign-in, membership, premium code, AI assistantLambda + API Gateway + DynamoDBDeploy Membership workflow: tests, then sam deploy
Player profiles and leaderboardsGamePlayerProfile Lambda + DynamoDB (us-west-2)Code lives in the repo (websocket-api/src); shared by SSB, Space WOW and Tic-Tac-Toe
Lobby and game messagesAPI Gateway WebSocket + Lambdaconnect, disconnect and sendMessage handlers in the repo
Fast multiplayer stateEC2 relay (relay.supersoldierbattle.com)An always-on WebSocket relay; the game connects to it over wss://

Workflow 1: Ship the Game Site

This is the workflow that runs every time something is pushed to master. The full file is further down. The important choices: --delete keeps S3 identical to the repo, the exclude list keeps server code and huge binaries out of the public bucket, and listing files get a 60 second cache so new tutorials appear quickly.

Workflow 2: Ship the Backend Only When It Changes

Lambda code needs tests and a careful deploy. A separate workflow with a paths: filter runs only when the membership folder changes. It runs the unit tests first, and if any fail, nothing deploys.

deploy-membership.yml
# .github/workflows/deploy-membership.yml (trimmed)
on:
  push:
    branches: [master]
    paths: ['membership/**', 'premium-content/**']   # only when backend code changes
  workflow_dispatch:

jobs:
  deploy:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
      - uses: actions/setup-node@v4
        with: { node-version: '22' }
      - uses: aws-actions/configure-aws-credentials@v4
        with: { aws-region: us-east-1, role-to-assume: ${{ vars.DEPLOY_ROLE }} }
      - uses: aws-actions/setup-sam@v2
      - name: Test, then deploy the Lambda stack
        working-directory: membership
        run: |
          (cd lambda && npm ci && node --test test/*.test.js)
          sam build
          sam deploy --stack-name site-membership --no-confirm-changeset \
            --no-fail-on-empty-changeset --capabilities CAPABILITY_IAM --resolve-s3

Secret values such as payment keys are never in the repo or the workflow. SAM reuses the stack's existing parameter values, so the workflow never needs to see them.

Multiplayer: Serverless Sockets Plus an EC2 Relay

Turn-based and lobby traffic fits API Gateway WebSockets well: you pay per message, and Lambda handlers store connections in DynamoDB. Shooter movement is different. Players send many small updates per second, and a single always-on relay process on EC2 forwards them with less latency and cost than one Lambda call per message. Super Soldier Battle uses both, plus the shared GamePlayerProfile Lambda for scores.

game-client.js
// Browser side: a game talks to API Gateway WebSocket and the profile Lambda.
const ws = new WebSocket('wss://YOUR_API_ID.execute-api.us-west-2.amazonaws.com/production');
ws.onopen = () => ws.send(JSON.stringify({ action: 'sendMessage', type: 'join', name: 'Player1' }));
ws.onmessage = (e) => handleGameEvent(JSON.parse(e.data));

// Leaderboard from the shared GamePlayerProfile Lambda (HTTP API + DynamoDB)
const top = await fetch('https://YOUR_PROFILE_API/profile?leaderboard=true&game=ssb')
  .then(r => r.json());

Security Checklist

  • Give the deploy identity only what it needs: s3:PutObject/DeleteObject/ListBucket on one bucket and cloudfront:CreateInvalidation on one distribution.
  • Prefer OIDC roles to stored access keys. If you use keys, rotate them and never echo them in logs.
  • Keep backend folders, .py scripts and templates out of the public bucket with --exclude.
  • Protect master with required checks so a broken test blocks the deploy.
  • Use concurrency groups so two pushes never deploy over each other.

Step-by-Step Code Breakdown

Each excerpt below is copied exactly from the full deploy.yml workflow further down.

1. Run on every push to master

In plain words: the "on:" block is the trigger. Any push to the master branch starts the workflow, and workflow_dispatch adds a "Run workflow" button in GitHub so you can redeploy by hand.

on:
  push:
    branches: [master]
  workflow_dispatch:

2. Ask for short-lived AWS credentials

In plain words: id-token: write lets GitHub prove to AWS who it is (OIDC). AWS then hands the job a temporary key that expires in about an hour, so there is no permanent password sitting in your repository. contents: read keeps the job from changing your code.

permissions:
  contents: read
  id-token: write          # lets GitHub get short-lived AWS credentials (OIDC)

3. Deploy one at a time

In plain words: concurrency puts deploys in a queue. If you push twice quickly, the second deploy waits for the first instead of both writing to the bucket at once.

concurrency:
  group: deploy-site
  cancel-in-progress: false

4. Sign in to AWS

In plain words: the job checks out your code, then the official configure-aws-credentials action assumes the IAM role you created. Option B shows the older way with access keys stored as repository secrets.

    steps:
      - uses: actions/checkout@v4

      # Option A (recommended): OIDC role, no long-lived keys stored in GitHub.
      - uses: aws-actions/configure-aws-credentials@v4
        with:
          role-to-assume: arn:aws:iam::123456789012:role/github-deploy-site
          aws-region: us-east-1
      # Option B: access keys saved as repository secrets.
      #   aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
      #   aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}

5. Sync the site to S3

In plain words: aws s3 sync uploads only files that changed. --delete removes files you deleted from the repo, so the bucket always matches GitHub. The exclude list keeps server code, videos and huge 3D models out of the public bucket.

      - name: Sync the site to S3 (big binaries and server code stay out)
        run: |
          aws s3 sync ./ s3://YOUR-GAME-BUCKET --delete \
            --exclude ".git/*" --exclude ".github/*" \
            --exclude "*.glb" --exclude "*.mp4" --exclude "*.zip" \
            --exclude "membership/*" --exclude "websocket-api/*" \
            --exclude "*.py" --exclude "template.yaml"

6. Upload big 3D models only when they change

In plain words: a GLB model can be many megabytes. This step compares the file size on disk with the size in S3 and uploads only when they differ, which keeps deploys fast and cheap.

      - name: Upload a changed 3D model only when its size differs
        run: |
          f=models/glb/tommy_gun.glb
          [ -f "$f" ] || exit 0
          local=$(stat -c %s "$f")
          remote=$(aws s3api head-object --bucket YOUR-GAME-BUCKET --key "$f" \
                   --query ContentLength --output text 2>/dev/null || echo 0)
          [ "$local" = "$remote" ] || aws s3 cp "$f" "s3://YOUR-GAME-BUCKET/$f" \
                   --content-type model/gltf-binary

7. Short cache for listing files

In plain words: the sitemap gets a 60 second cache so search engines and players see new pages almost immediately, while everything else keeps a long cache.

      - name: Short cache for listing files so new pages show fast
        run: |
          aws s3 cp sitemap.xml s3://YOUR-GAME-BUCKET/sitemap.xml \
            --cache-control "max-age=60, must-revalidate" --content-type application/xml

8. Clear the CloudFront cache

In plain words: CloudFront keeps copies of your files on servers around the world. create-invalidation tells every edge server to fetch fresh copies, so players get the new build within minutes instead of hours.

      - name: Invalidate CloudFront
        run: aws cloudfront create-invalidation --distribution-id YOUR_DISTRIBUTION_ID --paths "/*"

The Full Workflow (deploy.yml)

Replace YOUR-GAME-BUCKET, the role ARN and YOUR_DISTRIBUTION_ID, then save as .github/workflows/deploy.yml. Every step above is an exact excerpt of this file.

# .github/workflows/deploy.yml
# Push to master -> sync the static game site to S3 -> refresh CloudFront.
# Same shape as the workflow that ships shanebrumback.com and Super Soldier Battle.
name: Upload Website

on:
  push:
    branches: [master]
  workflow_dispatch:

permissions:
  contents: read
  id-token: write          # lets GitHub get short-lived AWS credentials (OIDC)

concurrency:
  group: deploy-site
  cancel-in-progress: false

jobs:
  deploy:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4

      # Option A (recommended): OIDC role, no long-lived keys stored in GitHub.
      - uses: aws-actions/configure-aws-credentials@v4
        with:
          role-to-assume: arn:aws:iam::123456789012:role/github-deploy-site
          aws-region: us-east-1
      # Option B: access keys saved as repository secrets.
      #   aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
      #   aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}

      - name: Sync the site to S3 (big binaries and server code stay out)
        run: |
          aws s3 sync ./ s3://YOUR-GAME-BUCKET --delete \
            --exclude ".git/*" --exclude ".github/*" \
            --exclude "*.glb" --exclude "*.mp4" --exclude "*.zip" \
            --exclude "membership/*" --exclude "websocket-api/*" \
            --exclude "*.py" --exclude "template.yaml"

      - name: Upload a changed 3D model only when its size differs
        run: |
          f=models/glb/tommy_gun.glb
          [ -f "$f" ] || exit 0
          local=$(stat -c %s "$f")
          remote=$(aws s3api head-object --bucket YOUR-GAME-BUCKET --key "$f" \
                   --query ContentLength --output text 2>/dev/null || echo 0)
          [ "$local" = "$remote" ] || aws s3 cp "$f" "s3://YOUR-GAME-BUCKET/$f" \
                   --content-type model/gltf-binary

      - name: Short cache for listing files so new pages show fast
        run: |
          aws s3 cp sitemap.xml s3://YOUR-GAME-BUCKET/sitemap.xml \
            --cache-control "max-age=60, must-revalidate" --content-type application/xml

      - name: Invalidate CloudFront
        run: aws cloudfront create-invalidation --distribution-id YOUR_DISTRIBUTION_ID --paths "/*"

Live Scene: The Full Code

Paste this into a file named index.html. This is the Three.js code for the 3D pipeline scene at the top of the page. It needs no files, so it runs from anywhere. Launch Full Code opens this exact code as a standalone page in a new window.

<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width, initial-scale=1">
  <title>Three.js AWS + GitHub Deploy Pipeline</title>
  <style>
    body { margin: 0; overflow: hidden; background: #000; font-family: system-ui, sans-serif; }
  </style>
  <script type="importmap">
  {
    "imports": {
      "three": "https://unpkg.com/three@0.160.0/build/three.module.js",
      "three/addons/": "https://unpkg.com/three@0.160.0/examples/jsm/"
    }
  }
  </script>
</head>
<body>
<script type="module">
import * as THREE from 'three';
import { OrbitControls } from 'three/addons/controls/OrbitControls.js';

// --- Scene, camera, renderer ---
const scene = new THREE.Scene();
scene.background = new THREE.Color(0x070b14);
scene.fog = new THREE.Fog(0x070b14, 18, 40);
const camera = new THREE.PerspectiveCamera(45, innerWidth / innerHeight, 0.1, 100);
camera.position.set(0, 5, 15);
const renderer = new THREE.WebGLRenderer({ antialias: true });
renderer.setPixelRatio(Math.min(devicePixelRatio, 2));
renderer.setSize(innerWidth, innerHeight);
renderer.toneMapping = THREE.ACESFilmicToneMapping;
document.body.appendChild(renderer.domElement);

// Orbit controls: drag (mouse or touch) to orbit. Zoom is off on the page so
// vertical swipes still scroll on phones; the full-screen demo turns zoom on.
const controls = new OrbitControls(camera, renderer.domElement);
controls.target.set(0, 0.5, 0);
controls.enableDamping = true;
controls.enableZoom = false;
controls.enablePan = false;
controls.autoRotate = true;
controls.autoRotateSpeed = 0.5;
renderer.domElement.style.touchAction = 'pan-y';

scene.add(new THREE.HemisphereLight(0xbfd8ff, 0x101020, 1.2));
const key = new THREE.DirectionalLight(0xffffff, 2);
key.position.set(4, 8, 6);
scene.add(key);
const grid = new THREE.GridHelper(30, 30, 0x2ad1d6, 0x1a2436);
grid.material.transparent = true; grid.material.opacity = 0.3;
grid.position.y = -1.2;
scene.add(grid);

// --- A text label drawn on a canvas, shown as a sprite that always faces you ---
function label(text, color) {
  const c = document.createElement('canvas'); c.width = 512; c.height = 128;
  const g = c.getContext('2d');
  g.font = 'bold 64px system-ui, sans-serif'; g.textAlign = 'center'; g.textBaseline = 'middle';
  g.fillStyle = color; g.fillText(text, 256, 64);
  const tex = new THREE.CanvasTexture(c); tex.colorSpace = THREE.SRGBColorSpace;
  const s = new THREE.Sprite(new THREE.SpriteMaterial({ map: tex, transparent: true }));
  s.scale.set(3, 0.75, 1);
  return s;
}

// --- The four stations of the pipeline: push -> build -> store -> serve ---
const stations = [
  { name: 'GitHub',     color: 0xe6edf3, mesh: new THREE.Mesh(new THREE.BoxGeometry(1.4, 1.4, 1.4), new THREE.MeshStandardMaterial({ color: 0x24292f, roughness: 0.4 })) },
  { name: 'Actions',    color: 0x2ad1d6, mesh: new THREE.Mesh(new THREE.TorusGeometry(0.75, 0.25, 16, 8), new THREE.MeshStandardMaterial({ color: 0x2ad1d6, metalness: 0.6, roughness: 0.3 })) },
  { name: 'S3',         color: 0xff9900, mesh: new THREE.Mesh(new THREE.CylinderGeometry(0.8, 0.6, 1.5, 32), new THREE.MeshStandardMaterial({ color: 0xff9900, roughness: 0.5 })) },
  { name: 'CloudFront', color: 0xb68cff, mesh: new THREE.Mesh(new THREE.IcosahedronGeometry(0.9, 1), new THREE.MeshStandardMaterial({ color: 0x8c4fff, wireframe: true })) }
];
stations.forEach((st, i) => {
  st.mesh.position.set(-6 + i * 4, 0, 0);
  scene.add(st.mesh);
  const tag = label(st.name, '#' + st.color.toString(16).padStart(6, '0'));
  tag.position.set(st.mesh.position.x, 1.6, 0);
  scene.add(tag);
});

// --- Players around the CDN: small glowing dots on a ring ---
const players = new THREE.Group();
for (let i = 0; i < 14; i++) {
  const a = (i / 14) * Math.PI * 2;
  const p = new THREE.Mesh(new THREE.SphereGeometry(0.12, 12, 8), new THREE.MeshBasicMaterial({ color: 0x39ff14 }));
  p.position.set(6 + Math.cos(a) * 2.2, Math.sin(a * 3) * 0.4, Math.sin(a) * 2.2);
  players.add(p);
}
scene.add(players);

// --- Packets (commits) that travel along a curve through every station ---
const path = new THREE.CatmullRomCurve3([
  new THREE.Vector3(-6, 0, 0), new THREE.Vector3(-4, 1.2, 0.6), new THREE.Vector3(-2, 0, 0),
  new THREE.Vector3(0, -0.8, -0.6), new THREE.Vector3(2, 0, 0), new THREE.Vector3(4, 1, 0.6), new THREE.Vector3(6, 0, 0)
]);
scene.add(new THREE.Line(new THREE.BufferGeometry().setFromPoints(path.getPoints(120)),
  new THREE.LineBasicMaterial({ color: 0x2ad1d6, transparent: true, opacity: 0.35 })));
const packets = [];
for (let i = 0; i < 6; i++) {
  const m = new THREE.Mesh(new THREE.BoxGeometry(0.25, 0.25, 0.25), new THREE.MeshBasicMaterial({ color: 0x7ff7ff }));
  m.userData.t = i / 6;              // spread them out along the path
  scene.add(m); packets.push(m);
}

// --- Animate ---
const clock = new THREE.Clock();
function animate() {
  requestAnimationFrame(animate);
  const dt = Math.min(clock.getDelta(), 0.05), t = clock.elapsedTime;
  for (const m of packets) {
    m.userData.t = (m.userData.t + dt * 0.08) % 1;   // 0 = GitHub, 1 = CloudFront
    m.position.copy(path.getPointAt(m.userData.t));
    m.rotation.x += dt * 2; m.rotation.y += dt * 3;
  }
  stations[1].mesh.rotation.z -= dt * 1.5;          // the Actions gear turns
  stations[3].mesh.rotation.y += dt * 0.4;          // the CDN globe spins
  players.rotation.y += dt * 0.2;
  stations[2].mesh.position.y = Math.sin(t * 1.5) * 0.08;
  controls.update();
  renderer.render(scene, camera);
}
animate();

addEventListener('resize', () => {
  camera.aspect = innerWidth / innerHeight;
  camera.updateProjectionMatrix();
  renderer.setSize(innerWidth, innerHeight);
});
</script>
</body>
</html>

What To Try Next

Frequently Asked Questions

How do I deploy a website from GitHub to AWS S3?

Create a GitHub Actions workflow that runs on push, configures AWS credentials with aws-actions/configure-aws-credentials, runs aws s3 sync ./ s3://your-bucket --delete, then invalidates CloudFront.

Should I use OIDC or access keys in GitHub Actions?

OIDC is safer because GitHub gets short-lived credentials by assuming an IAM role, and no long-lived key is stored. Access keys in repository secrets work but must be least-privilege and rotated.

Why do players still see the old version after a deploy?

CloudFront is serving cached files. Run aws cloudfront create-invalidation with the paths you changed, or /* , and give HTML and listing files a short Cache-Control max-age.

How do I deploy AWS Lambda functions with GitHub Actions?

Describe them in an AWS SAM template, then in a workflow run your tests, sam build and sam deploy --no-confirm-changeset. Add a paths filter so it only runs when backend code changes.

Can I host a Three.js game on S3?

Yes. A Three.js game is static HTML, JavaScript, textures and models, which S3 and CloudFront serve well. Add CORS headers if other sites load your models or textures.

Do I need servers for browser game multiplayer?

Not always. API Gateway WebSockets with Lambda and DynamoDB handle lobbies, chat and turn-based games serverlessly. Fast action games often add a small always-on relay, such as an EC2 instance, for movement updates.

Is GitHub Actions free for this?

Public repositories get free minutes on standard runners and private repositories get a monthly free allowance. A static site deploy usually takes one to two minutes.

Is this AWS and GitHub article free?

Yes. The whole article, the deploy.yml workflow and the live 3D pipeline scene code are free. Copy them with no sign-in; only the full-screen live demo asks for a free Google sign-in.