Skip to content

Build

Build #1193

Workflow file for this run

name: Build
on:
pull_request:
push:
branches:
- main
schedule:
- cron: '0 0 * * 1-6'
- cron: '0 0 * * 0' # runs with no-cache
workflow_dispatch:
inputs:
no-cache:
description: 'Skip Docker cache'
type: boolean
default: false
jobs:
setup:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- 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@v4
- 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@v3
- uses: docker/setup-buildx-action@v3
- uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- uses: docker/build-push-action@v6
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) }}
dockerhub:
runs-on: ubuntu-latest
needs: build
if: github.event_name != 'pull_request'
steps:
- uses: actions/checkout@v4
- uses: peter-evans/dockerhub-description@e98e4d1628a5f3be2be7c231e50981aee98723ae # pin@v4
with:
repository: articulate/node
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
short-description: ${{ github.event.repository.description }}
notify:
runs-on: ubuntu-latest
needs: build
if: github.event_name != 'pull_request'
steps:
- run: curl ${{ secrets.DMS_URL }}