Skip to content

first commit

first commit #1

Workflow file for this run

name: Build
on:
pull_request:
push:
branches:
- main
schedule:
# every weekday
- cron: '0 0 * * 1-5'
# every sunday (no-cache)
- cron: '0 0 * * 0'
workflow_dispatch:
inputs:
no-cache:
description: 'Skip Docker cache'
type: boolean
default: false
jobs:
setup:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Find Dockerfiles
id: scan
run: echo "dockerfiles=$(find . -name Dockerfile | cut -c3- | jq -R -s -c 'split("\n")[:-1]')" >> "$GITHUB_OUTPUT"
outputs:
dockerfiles: ${{ steps.scan.outputs.dockerfiles }}
build:
runs-on: ubuntu-latest
needs: [setup]
strategy:
fail-fast: false
matrix:
dockerfile: ${{ fromJSON(needs.setup.outputs.dockerfiles) }}
steps:
- uses: actions/checkout@v3
- name: Get image metadata
id: meta
run: |
tags=$(grep "tags=" ${{ matrix.dockerfile }} | cut -d "=" -f 2)
echo "context=$(dirname "${{ matrix.dockerfile }}")" >> "$GITHUB_OUTPUT"
echo "tags=${tags}" >> "$GITHUB_OUTPUT"
echo "cache=$(echo "$tags" | cut -d "," -f 1)" >> "$GITHUB_OUTPUT"
- uses: docker/setup-qemu-action@v2
- uses: docker/setup-buildx-action@v2
- uses: docker/login-action@v2
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- uses: docker/build-push-action@v4
with:
context: ${{ steps.meta.outputs.context }}
pull: ${{ github.event_name != 'pull_request' }}
push: ${{ github.event_name != 'pull_request' }}
tags: ${{ steps.meta.outputs.tags }}
platforms: linux/amd64,linux/arm64/v8
cache-from: type=registry,ref=${{ steps.meta.outputs.cache }}
cache-to: type=inline
no-cache: ${{ github.event.schedule == '0 0 * * 0' || (github.event_name == 'workflow_dispatch' && inputs.no-cache) }}