Snippets / CI/CD
GitHub Actions: build & test (no push)
Builds the image and runs the test suite inside it on every pull request -- no registry, no secrets.
github-actionscipull-requesttesting
test.yml
name: build-and-test
on:
pull_request:
permissions:
contents: read
jobs:
build:
runs-on: ubuntu-latest
timeout-minutes: 15
steps:
- uses: actions/checkout@v4
- uses: docker/setup-buildx-action@v3
- name: Build the image (load it, don't push it)
uses: docker/build-push-action@v6
with:
# docker/setup-buildx-action creates a docker-container builder,
# which -- unlike the daemon's own default builder -- keeps a
# build's result in its own cache instead of the local image
# store. Without load: true here, the next step's "docker run"
# fails with "Unable to find image" even though the build
# itself succeeded.
load: true
tags: app:ci
cache-from: type=gha
cache-to: type=gha,mode=max
- name: Run the test suite inside the built image
run: docker run --rm app:ci npm test
More ci/cd snippets