Skip to content

Instantly share code, notes, and snippets.

@mec
Created October 17, 2024 09:12
Show Gist options
  • Save mec/398c12805c77ce4c5d4949887497beb3 to your computer and use it in GitHub Desktop.
Save mec/398c12805c77ce4c5d4949887497beb3 to your computer and use it in GitHub Desktop.
Basic build and cache CI job
name: CI Checks
on:
pull_request:
push:
branches:
- main
jobs:
build-and-cache:
name: Build and cache image
runs-on: ubuntu-latest
steps:
-
name: Checkout
uses: actions/checkout@v4
-
name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
-
name: Build and cache
uses: docker/build-push-action@v6
with:
context: .
file: ./Dockerfile
build-args: RAILS_ENV=test
push: false
tags: app:latest
cache-from: type=gha
cache-to: type=gha,mode=min
@mec
Copy link
Author

mec commented Oct 17, 2024

push is set to false because a later job pushes the image but the built image remains in context for subsequent builds which will happen very quickly.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment