Try adding a build cache that uses githubs package repo as a cache

Inspired by https://dev.to/dtinth/caching-docker-builds-in-github-actions-which-approach-is-the-fastest-a-research-18ei
This commit is contained in:
Chris Vest 2020-11-20 14:33:06 +01:00
parent 023bb64a25
commit 72eb5d3bcb
2 changed files with 12 additions and 1 deletions

View File

@ -24,7 +24,18 @@ jobs:
steps:
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
- uses: actions/checkout@v2
- name: Prepare docker build cache
run:
echo ${{ secrets.GITHUB_TOKEN }} | docker login docker.pkg.github.com -u $GITHUB_ACTOR --password-stdin
docker pull docker.pkg.github.com/$GITHUB_REPOSITORY/build-cache || true
export DOCKER_BUILD_OPTS="--cache-from=docker.pkg.github.com/$GITHUB_REPOSITORY/build-cache"
# Run the make script
- name: Make build
run: make build
# Cache build outputs
- name: Save docker build cache
run:
docker tag netty-incubator-buffer:build docker.pkg.github.com/$GITHUB_REPOSITORY/build-cache
docker push docker.pkg.github.com/$GITHUB_REPOSITORY/build-cache || true

View File

@ -2,7 +2,7 @@
.DEFAULT_GOAL := build
image:
docker build --tag netty-incubator-buffer:build .
docker build $(DOCKER_BUILD_OPTS) --tag netty-incubator-buffer:build .
test: image
docker run --rm --name build-container netty-incubator-buffer:build