1+ name : CI/CD
2+
3+ on : [push, workflow_dispatch]
4+
5+ jobs :
6+ build :
7+ runs-on : ubuntu-latest
8+ strategy :
9+ matrix :
10+ version : [7.1, 7.2, 7.3, 7.4]
11+ type : ['', '-prod']
12+
13+ steps :
14+ - name : Checkout code
15+ uses : actions/checkout@v2
16+
17+ - name : Set up Docker Buildx
18+ uses : docker/setup-buildx-action@v1
19+
20+ - name : Cache Docker layers
21+ uses : actions/cache@v2
22+ with :
23+ path : /tmp/.buildx-cache
24+ key : docker-buildx-${{ matrix.version }}${{ matrix.type }}-${{ github.sha }}
25+ restore-keys : docker-buildx-${{ matrix.version }}${{ matrix.type }}-
26+
27+ - name : Build
28+ run : |
29+ docker buildx build \
30+ --cache-from type=local,src=/tmp/.buildx-cache/${{ matrix.version }}${{ matrix.type }} \
31+ --cache-to type=local,dest=/tmp/.buildx-cache/${{ matrix.version }}${{ matrix.type }} \
32+ --output type=docker \
33+ --tag kooldev/php:${{ matrix.version }}${{ matrix.type }} \
34+ ${{ matrix.version }}${{ matrix.type }}
35+
36+ docker buildx build \
37+ --cache-from type=local,src=/tmp/.buildx-cache/${{ matrix.version }}-wkhtmltopdf${{ matrix.type }} \
38+ --cache-to type=local,dest=/tmp/.buildx-cache/${{ matrix.version }}-wkhtmltopdf${{ matrix.type }} \
39+ --output type=docker \
40+ --tag kooldev/php:${{ matrix.version }}-wkhtmltopdf${{ matrix.type }} \
41+ ${{ matrix.version }}-wkhtmltopdf${{ matrix.type }}
42+
43+ - name : Build (nginx)
44+ run : |
45+ docker buildx build \
46+ --cache-from type=local,src=/tmp/.buildx-cache/${{ matrix.version }}-nginx${{ matrix.type }} \
47+ --cache-to type=local,dest=/tmp/.buildx-cache/${{ matrix.version }}-nginx${{ matrix.type }} \
48+ --output type=docker \
49+ --tag kooldev/php:${{ matrix.version }}-nginx${{ matrix.type }} \
50+ ${{ matrix.version }}-nginx${{ matrix.type }}
51+
52+ docker buildx build \
53+ --cache-from type=local,src=/tmp/.buildx-cache/${{ matrix.version }}-nginx-wkhtmltopdf${{ matrix.type }} \
54+ --cache-to type=local,dest=/tmp/.buildx-cache/${{ matrix.version }}-nginx-wkhtmltopdf${{ matrix.type }} \
55+ --output type=docker \
56+ --tag kooldev/php:${{ matrix.version }}-nginx-wkhtmltopdf${{ matrix.type }} \
57+ ${{ matrix.version }}-nginx-wkhtmltopdf${{ matrix.type }}
58+
59+ - name : Tests
60+ run : |
61+ for suffix in '' -wkhtmltopdf -nginx -nginx-wkhtmltopdf; do
62+ docker run kooldev/php:${{ matrix.version }}$suffix${{ matrix.type }} php -v
63+ docker run kooldev/php:${{ matrix.version }}$suffix${{ matrix.type }} composer -V
64+ docker run -e ASUSER=1000 kooldev/php:${{ matrix.version }}$suffix${{ matrix.type }} php -v
65+ docker run -e ASUSER=1000 kooldev/php:${{ matrix.version }}$suffix${{ matrix.type }} composer -V
66+ docker run kooldev/php:${{ matrix.version }}$suffix${{ matrix.type }} php -m
67+ docker run -e ENABLE_XDEBUG=true kooldev/php:${{ matrix.version }}$suffix${{ matrix.type }} php -m
68+ done
69+
70+ for suffix in -nginx -nginx-wkhtmltopdf; do
71+ docker run kooldev/php:${{ matrix.version }}$suffix${{ matrix.type }} nginx -v
72+ docker run kooldev/php:${{ matrix.version }}$suffix${{ matrix.type }} supervisord version
73+ done
74+
75+ - name : Login to DockerHub
76+ uses : docker/login-action@v1
77+ if : github.ref == 'refs/heads/master' && github.repository == 'kool-dev/docker-php'
78+ with :
79+ username : ${{ secrets.DOCKER_USERNAME }}
80+ password : ${{ secrets.DOCKER_PASSWORD }}
81+
82+ - name : Push to DockerHub
83+ if : github.ref == 'refs/heads/master' && github.repository == 'kool-dev/docker-php'
84+ run : |
85+ docker push kooldev/php:${{ matrix.version }}${{ matrix.type }}
86+ docker push kooldev/php:${{ matrix.version }}-wkhtmltopdf${{ matrix.type }}
87+
88+ docker push kooldev/php:${{ matrix.version }}-nginx${{ matrix.type }}
89+ docker push kooldev/php:${{ matrix.version }}-nginx-wkhtmltopdf${{ matrix.type }}
90+
91+ - name : Trigger build on kool-dev/docker-wordpress
92+ uses : benc-uk/workflow-dispatch@v1
93+ if : github.ref == 'refs/heads/master' && github.repository == 'kool-dev/docker-php'
94+ with :
95+ workflow : CI
96+ repo : kool-dev/docker-wordpress
97+ token : ${{ secrets.WORKFLOW_TOKEN }}
0 commit comments