-
Notifications
You must be signed in to change notification settings - Fork 0
93 lines (83 loc) · 3.02 KB
/
test.yml
File metadata and controls
93 lines (83 loc) · 3.02 KB
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
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
name: Discover Dockerfiles and Build Matrix [draft, by copilot & me ;-)]
on:
workflow_dispatch:
workflow_call:
jobs:
discover-dockerfiles:
#runs-on: ubuntu-latest
runs-on: [self-hosted]
outputs:
matrix: ${{ steps.set-matrix.outputs.matrix }}
repo-lower: ${{ steps.set-matrix.outputs.repo-lower }}
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Find Dockerfiles and build paired matrix
id: set-matrix
run: |
files=$(find . -maxdepth 2 -type f -name 'Dockerfile*' | sort)
includes=""
while IFS= read -r file; do
dir=$(dirname "$file" | sed 's|^\./||')
dockerfile=$(basename "$file")
if [[ $dockerfile == 'Dockerfile' ]]; then
version='latest'
else
version=$(basename "$file"|sed 's/Dockerfile\.\?//')
fi
# Evita la root vuota come directory
if [[ "$dir" == "." ]]; then
dir=""
fi
includes="${includes}{\"directory\":\"$dir\",\"tag\":\"$version\"},"
done <<< "$files"
# Rimuove la virgola finale e crea array include
includes="[${includes%,}]"
echo "matrix={\"include\":$includes}" >> $GITHUB_OUTPUT
echo "repo-lower=$(echo "${GITHUB_REPOSITORY}" | tr '[:upper:]' '[:lower:]')" >> $GITHUB_OUTPUT
- name: Show discovered matrix
run: |
echo "${{ steps.set-matrix.outputs.matrix }}"
#use-matrix:
# needs: discover-dockerfiles
# runs-on: [self-hosted]
# strategy:
# matrix:
# include: ${{ fromJson(needs.discover-dockerfiles.outputs.matrix).include }}
# steps:
# - name: Print matrix info
# run: |
# echo "Directory: ${{ matrix.directory }}"
# echo "Dockerfile: ${{ matrix.tag }}"
# echo "Tag: ${{ matrix.tag }}"
print-results:
needs: discover-dockerfiles
runs-on: [self-hosted]
steps:
- name: Print matrix info
run: |
echo "matrix: ${{ needs.discover-dockerfiles.outputs.matrix }}"
echo "repo-lower: ${{ needs.discover-dockerfiles.outputs.repo-lower }}"
update-images:
needs: discover-dockerfiles
uses: Neomediatech/gh-workflows/.github/workflows/check-and-build-docker-images.yml@main
permissions:
contents: write
packages: write
secrets: inherit
strategy:
matrix:
include: ${{ fromJson(needs.discover-dockerfiles.outputs.matrix).include }}
max-parallel: 1
with:
base-image: php
derived-image-prefix: ghcr.io/${{ needs.discover-dockerfiles.outputs.repo-lower }}
#versions: '["8.4", "8.3", "8.2", "8.1", "7.4"]'
#type: '["apache", "fpm"]'
versions: '["${{ matrix.tag }}"]'
type: '["${{ matrix.directory }}"]'
derived-image-repo: ${{ needs.discover-dockerfiles.outputs.repo-lower }}
derived-image-repo-ref: ${{ github.ref_name }}
update-image: "true"
build-test-image: "false"
force-build: "true"