How to Migrate CI Service Containers to GitHub Actions
GitLab services, CircleCI secondary docker images, and Bitbucket services all map to the GitHub Actions services block with health checks.
A backing service (Postgres, Redis) launched alongside your job maps to the services: block. Add health-check options: so steps wait for readiness, and connect on the mapped localhost port.
Concept mapping
| Source | GitHub Actions |
|---|---|
GitLab services: | services: |
CircleCI extra docker: image | services: |
Bitbucket services: | services: |
| readiness wait | health-check options: |
After
.github/workflows/ci.yml
jobs:
test:
runs-on: ubuntu-latest
services:
postgres:
image: postgres:16
env:
POSTGRES_PASSWORD: test
ports: ['5432:5432']
options: >-
--health-cmd "pg_isready" --health-interval 10s --health-retries 5
steps:
- uses: actions/checkout@v4
- run: DATABASE_URL=postgres://postgres:test@localhost:5432/postgres npm testWhat does not map cleanly
- Without health checks, steps may start before the service is ready; other tools sometimes wait implicitly.
- When the job itself runs in a container, connect to the service by its name, not localhost.
- GitLab lets you alias services; in Actions the service key is the hostname within a container job.
Related guides
How to Migrate From Bitbucket Pipelines to GitHub ActionsConvert a bitbucket-pipelines.yml to GitHub Actions, mapping pipelines and steps to jobs, image to container,…
How to Migrate Cache Config to GitHub ActionsTranslate cache keys and paths from Travis, CircleCI, GitLab, or Bitbucket into GitHub Actions using actions/…