-
Notifications
You must be signed in to change notification settings - Fork 0
65 lines (63 loc) · 2.08 KB
/
build.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
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@v5
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) }}
notify:
runs-on: ubuntu-latest
needs: build
if: github.event_name != 'pull_request'
steps:
- run: curl ${{ secrets.DMS_URL }}