Skip to content
Latchkey

CI/CD for Play Framework with GitHub Actions

Test and stage your Play Framework app for a clean deploy.

Play Framework runs on the JVM with sbt as the build tool for Scala projects. The sbt stage task produces a runnable distribution. This recipe runs tests and stages the app for deploy.

What the pipeline does

  • set up the JDK
  • set up sbt with caching
  • run tests with sbt test
  • build a runnable dist with sbt stage
  • deploy the staged output

The workflow

sbt/setup-sbt installs sbt and setup-java with cache: sbt caches the ivy and coursier caches. sbt stage emits target/universal/stage.

.github/workflows/ci.yml
name: CI
on:
  push:
    branches: [main]
  pull_request:
jobs:
  build:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
      - uses: actions/setup-java@v4
        with:
          distribution: temurin
          java-version: 21
          cache: sbt
      - uses: sbt/setup-sbt@v1
      - run: sbt test
      - run: sbt stage
      - uses: actions/upload-artifact@v4
        with:
          name: play-dist
          path: target/universal/stage

Caching and speed

cache: sbt restores the coursier and ivy caches so dependency resolution is fast. Scala compilation is notoriously CPU-heavy, so the compile and test steps dominate; cheaper managed runners such as Latchkey (around 69% cheaper than GitHub-hosted) make a real dent and auto-retry transient resolver failures.

Deploying

sbt stage produces target/universal/stage with a bin/ launch script; run it on a JVM host or copy it into a container. sbt dist builds a zip you can deploy instead. Configure the app with -Dconfig.resource or environment variables per environment.

Key takeaways

  • sbt stage builds a runnable distribution.
  • cache: sbt restores the coursier and ivy caches.
  • Scala compilation benefits most from faster cores.

Related guides

Run this faster and cheaper on Latchkey managed runners. Start free →