-
Notifications
You must be signed in to change notification settings - Fork 0
147 lines (126 loc) · 4.17 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
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
name: Build Docker Images
env:
DOCKERHUB_TAG: "foorschtbar/php-webserver"
DOCKERHUB_SHORT_DESCRIPTION: "This is an usefull extension of the official php:*-apache Docker image."
DOCKERHUB_README_FILE: "README.md"
on:
push:
schedule:
- cron: "0 5 * * 5"
defaults:
run:
shell: "bash -Eeuo pipefail -x {0}"
jobs:
main:
name: Build & Push Docker Images
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
php: ["8.3"]
python: ["python", "no-python"]
include:
- php: "8.3"
python: "no-python"
tag_with_latest: true
tag_with_develop: true
- php: "8.3"
python: "python"
tag_with_python: true
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Login to Docker Hub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKER_HUB_USERNAME }}
password: ${{ secrets.DOCKER_HUB_PASSWORD }}
- name: Set cache buster
id: cache_buster
run: |
if [ '${{ github.event_name }}' == 'schedule' ]
then
echo "Scheduled run. Disable cache."
echo "::set-output name=suffix::-no-cache"
else
echo "Non-scheduled run. Enable cache."
echo "::set-output name=suffix::"
fi
- name: Get branche name
uses: nelonoel/[email protected]
- name: Set Docker Tags
id: docker_tags
run: |
TAGS=()
TAG_DEVELOP=""
TAG_PYTHON=""
# Add tag develop if needed
if [ ${BRANCH_NAME} == 'develop' ]
then
TAG_DEVELOP="-develop"
# Tag with "develop"
if [ '${{ matrix.tag_with_develop}}' == 'true' ]
then
TAGS+=(${{ env.DOCKERHUB_TAG }}:develop)
fi
else
# Tag with "latest"
if [ '${{ matrix.tag_with_latest }}' == 'true' ]
then
TAGS+=(${{ env.DOCKERHUB_TAG }}:latest)
fi
fi
# Add tag python if needed
if [ '${{ matrix.python }}' == 'python' ]
then
TAG_PYTHON="-python"
fi
# Build "long" tag
TAGS+=(${{ env.DOCKERHUB_TAG }}:${{ matrix.php }}$TAG_PYTHON$TAG_DEVELOP)
# Tag with "python"
if [ '${{ matrix.tag_with_python }}' == 'true' ]
then
TAGS+=(${{ env.DOCKERHUB_TAG }}:python)
fi
TAG_LIST=$(IFS=,; printf '%s' "${TAGS[*]}")
echo "Image tags:"
printf -- '- %s\n' "${TAGS[@]}"
echo "::set-output name=tags::$TAG_LIST"
- name: Build and push
id: docker_build
uses: docker/build-push-action@v6
with:
build-args: |
FROM_TAG=${{ matrix.php }}-apache
PYTHON=${{ matrix.python }}
push: true
tags: ${{ steps.docker_tags.outputs.tags }}
platforms: linux/386,linux/amd64,linux/arm/v7,linux/arm64
cache-from: type=registry,ref=${{ env.DOCKERHUB_TAG }}:${{ matrix.php }}${{ steps.cache_buster.outputs.suffix }}
cache-to: type=inline
- name: Image digests
run: |
echo PHP version: ${{ matrix.php }}; \
echo Python: ${{ matrix.python }}; \
echo Branche: ${BRANCH_NAME}; \
echo Digests: ${{ steps.docker_build.outputs.digest }}
pushreadme:
runs-on: ubuntu-latest
name: Push README to Docker Hub
steps:
- name: git checkout
uses: actions/checkout@v4
- name: push README to Dockerhub
uses: christian-korneck/update-container-description-action@v1
env:
DOCKER_USER: ${{ secrets.DOCKER_HUB_USERNAME }}
DOCKER_PASS: ${{ secrets.DOCKER_HUB_PASSWORD }}
with:
destination_container_repo: ${{ env.DOCKERHUB_TAG }}
provider: dockerhub
short_description: ${{ env.DOCKERHUB_SHORT_DESCRIPTION }}
readme_file: ${{ env.DOCKERHUB_README_FILE }}