-
Notifications
You must be signed in to change notification settings - Fork 5
109 lines (104 loc) · 4.55 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
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
on:
push:
paths-ignore:
- "**/*.md"
concurrency:
group: ${{ github.sha }}
cancel-in-progress: true
jobs:
build-caddy-image:
runs-on: ubuntu-latest
if: github.ref == 'refs/heads/develop' # Running this job only for develop branch
steps:
- name: Cancel Previous Run preventing duplicate pipelines
uses: styfle/[email protected]
with:
access_token: ${{ github.token }}
- name: Checkout code
uses: actions/checkout@v3 # Checking out the repo
- name: Check for changes
uses: dorny/paths-filter@v2
id: changes
with:
filters: |
php:
- 'docker/caddy/**'
- name: Build and Publish head caddy image
# run only if some file in 'src' folder was changed
if: steps.changes.outputs.php == 'true'
uses: VaultVulp/[email protected]
with:
github-token: ${{ secrets.GITHUB_TOKEN }} # Provide GITHUB_TOKEN to login into the GitHub Packages
image-name: caddy # Provide Docker image name
dockerfile: ./docker/caddy/Dockerfile
build-context: ./docker/caddy/
image-tag: head # Provide Docker image tag
pull-image: true # Raise the flag to try to pull image
build-composer-image:
runs-on: ubuntu-latest
if: github.ref == 'refs/heads/develop' # Running this job only for develop branch
steps:
- name: Cancel Previous Run preventing duplicate pipelines
uses: styfle/[email protected]
with:
access_token: ${{ github.token }}
- name: Checkout code
uses: actions/checkout@v3 # Checking out the repo
- name: Check for changes
uses: dorny/paths-filter@v2
id: changes
with:
filters: |
php:
- 'docker/composer/**'
- name: Build and Publish head composer image
# run only if some file in 'src' folder was changed
if: steps.changes.outputs.php == 'true'
uses: VaultVulp/[email protected]
with:
github-token: ${{ secrets.GITHUB_TOKEN }} # Provide GITHUB_TOKEN to login into the GitHub Packages
image-name: composer # Provide Docker image name
dockerfile: ./docker/composer/Dockerfile
build-context: ./docker/composer/
image-tag: head # Provide Docker image tag
pull-image: true # Raise the flag to try to pull image
phpunit:
runs-on: ubuntu-20.04
needs:
- build-caddy-image
- build-composer-image
if: ${{ github.event_name == 'push' && (needs.build-composer-image.result == 'success' || needs.build-composer-image.result == 'skipped') && !cancelled() }}
steps:
- name: Cancel Previous Run preventing duplicate pipelines
uses: styfle/[email protected]
with:
access_token: ${{ github.token }}
- name: Checkout code
uses: actions/checkout@v3 # Checking out the repo
- name: Login to github registry
uses: docker/login-action@v1
with:
registry: docker.pkg.github.com
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: PHPUnit
run: |
docker network create -d bridge caddy-network
docker run --entrypoint caddy --name caddy -d --network="caddy-network" --hostname=caddy -v "$(pwd)/docker/caddy/autosave.json:/config/caddy/autosave.json" -v "$(pwd)/docker/caddy/files:/var/files" -p 80:80 -p 2019:2019 docker.pkg.github.com/mattvb91/caddy-php/caddy:head run --resume
docker run -v $(pwd):/app docker.pkg.github.com/mattvb91/${{ env.REPO_NAME }}/composer:head composer install
docker run -v $(pwd):/app docker.pkg.github.com/mattvb91/${{ env.REPO_NAME }}/composer:head composer phpstan
docker run -v $(pwd):/app docker.pkg.github.com/mattvb91/${{ env.REPO_NAME }}/composer:head composer codesniffer
docker run -v $(pwd):/app docker.pkg.github.com/mattvb91/${{ env.REPO_NAME }}/composer:head composer rector
docker run --network="caddy-network" -e XDEBUG_MODE=coverage -v $(pwd):/app docker.pkg.github.com/mattvb91/${{ env.REPO_NAME }}/composer:head composer phpunit
env:
REPO_NAME: ${{ github.event.repository.name }}
- uses: codecov/[email protected]
with:
fail_ci_if_error: false
directory: ./src
files: ./coverage.xml
env:
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
- name: "output logs if fail"
if: failure()
run: docker logs caddy