Build latest version Docker images #19
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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: | |
- { | |
tag: "rbmi:latest" | |
} | |
# Token permissions | |
permissions: | |
contents: read | |
packages: write | |
# Build steps | |
steps: | |
- name: Check out the repo | |
uses: actions/checkout@v4 | |
- 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 }} | |
- name: Build and push image | |
uses: docker/build-push-action@v3 | |
with: | |
context: . | |
file: ./misc/docker/Dockerfile | |
push: true | |
tags: ${{ env.REGISTRY }}/${{ github.repository_owner }}/${{ matrix.config.tag }} | |
build-args: | | |
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 |