-
Notifications
You must be signed in to change notification settings - Fork 3
47 lines (38 loc) · 1.45 KB
/
ci-cd.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
name: CI/CD
on: [push, workflow_dispatch]
jobs:
build:
runs-on: ubuntu-latest
strategy:
matrix:
version: [php, proxy, static]
steps:
- name: Checkout code
uses: actions/checkout@v3.3.0
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2.5.0
- name: Cache Docker layers
uses: actions/cache@v3.3.0
with:
path: /tmp/.buildx-cache
key: docker-buildx-${{ matrix.version }}-${{ github.sha }}
restore-keys: docker-buildx-${{ matrix.version }}-
- name: Build
run: |
docker buildx build \
--cache-from type=local,src=/tmp/.buildx-cache/${{ matrix.version }} \
--cache-to type=local,dest=/tmp/.buildx-cache/${{ matrix.version }} \
--output type=docker \
--tag kooldev/nginx:${{ matrix.version }} \
${{ matrix.version }}
- name: Tests
run: docker run kooldev/nginx:${{ matrix.version }} nginx -v
- name: Login to DockerHub
uses: docker/login-action@v2.1.0
if: github.ref == 'refs/heads/master' && github.repository == 'kool-dev/docker-nginx'
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}
- name: Push to DockerHub
if: github.ref == 'refs/heads/master' && github.repository == 'kool-dev/docker-nginx'
run: docker push kooldev/nginx:${{ matrix.version }}