-
Notifications
You must be signed in to change notification settings - Fork 0
77 lines (67 loc) · 2.31 KB
/
docker.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: Docker
on:
schedule:
- cron: '0 10 * * *'
push:
branches:
- '**'
tags:
- 'v*.*.*'
pull_request:
branches:
- 'main'
jobs:
docker:
runs-on: ubuntu-latest
steps:
-
name: Checkout
uses: actions/checkout@v3
with:
fetch-depth: 0
-
name: Set up QEMU
uses: docker/setup-qemu-action@v2
-
name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
-
name: Login to DockerHub
uses: docker/login-action@v2
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
-
name: Build and push the images
run: |
for versionFilePath in $(git diff-tree --no-commit-id --name-only -r ${{ github.sha }} ${{ github.event.before }} | grep "Dockerfile");
do
if [[ "${versionFilePath}" != "Dockerfile.template" && "${versionFilePath}" != "Dockerfile" ]]; then
folder=${versionFilePath%"/Dockerfile"}
IFS='/' read -r -a image_path <<<"$folder"
versionFolder="${image_path[0]}"
versionName="${image_path[1]}"
IMAGE_ID="dphadatare/phpexcel"
echo $IMAGE_ID
echo $versionName
if [ -f .versions.json ]; then
versionsHelper="$(<.versions.json)"
elif [ -f versions.json ]; then
versionsHelper="$(<versions.json)"
else
echo "versions.json file not found!"
exit 1
fi
folderAliases=$(echo $versionsHelper | jq -r '.["'"${versionFolder}"'"].aliases')
versionAliases=$(echo $folderAliases | jq -r '.["'"${versionName}"'"]')
tags=""
if [ "${versionAliases}" != null ]; then
versionAliases="$(echo "${versionAliases}" | jq -r 'map(@sh) | join(" ")')"
eval "versionAliases=( $versionAliases )"
for aliase in "${variants[@]}"; do
tags="${tags} -t $IMAGE_ID:$aliase "
done
fi
docker buildx build --platform linux/amd64,linux/arm64 -t $IMAGE_ID:$versionName $tags --push $folder --file $folder/Dockerfile
fi
done;