Skip to content

Build latest version Docker images #34

Build latest version Docker images

Build latest version Docker images #34

name: Build latest version Docker images
env:
REGISTRY: ghcr.io
on:
schedule:
- cron: '0 5 1 * *'
workflow_dispatch:
jobs:
build:
runs-on: ubuntu-latest
name: Build & Deploy Docker Images
strategy:
fail-fast: true
matrix:
config:
- {
src_image: "rocker/r-ver:latest",
cran_url: "https://packagemanager.rstudio.com/cran/latest",
tag: "rbmi:latest",
mmrm_version : "v0.1.5"
}
# Token permissions
permissions:
contents: read
packages: write
# Build steps
steps:
- name: Checkout repository
uses: actions/checkout@v3
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
id: buildx
with:
install: true
- name: Log in to the Container registry
uses: docker/login-action@v2
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Cache Docker layers
uses: actions/cache@v3
with:
path: /tmp/.buildx-cache
key: docker-cache-${{ matrix.config.tag }}
- name: debug
run: |
echo push = ${{ github.event_name == 'push' }}
echo tag = ${{ env.REGISTRY }}/${{ github.repository_owner }}/${{ matrix.config.tag }}
echo IMAGE=${{ matrix.config.src_image }}
echo CRANURL=${{ matrix.config.cran_url }}
- name: Build and push image
uses: docker/build-push-action@v3
with:
context: ./misc/docker
push: true
tags: ${{ env.REGISTRY }}/${{ github.repository_owner }}/${{ matrix.config.tag }}
build-args: |
IMAGE=${{ matrix.config.src_image }}
CRANURL=${{ matrix.config.cran_url }}
MMRM_VERSION=${{ matrix.config.mmrm_version }}
cache-from: type=local,src=/tmp/.buildx-cache
cache-to: type=local,dest=/tmp/.buildx-cache-new
# Fix bug where docker cache just continiously grows as it doesn't purge older layers
# That are no longer in use
# https://github.com/docker/build-push-action/blob/master/docs/advanced/cache.md#local-cache
- name: Move cache
run: |
rm -rf /tmp/.buildx-cache
mv /tmp/.buildx-cache-new /tmp/.buildx-cache