-
Notifications
You must be signed in to change notification settings - Fork 0
77 lines (75 loc) · 2.54 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
66
67
68
69
70
71
72
73
74
75
76
77
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@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) }}
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/elixir
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 }}