This repository has been archived by the owner on Apr 18, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
140 lines (119 loc) · 4.41 KB
/
main.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
name: CICD
on:
push:
branches:
- main
- develop
workflow_dispatch:
jobs:
build:
runs-on: ubuntu-latest
name: Build
steps:
- uses: actions/checkout@v3
- uses: shivammathur/setup-php@v2
with:
php-version: 8.1
coverage: xdebug
env:
update: true
- uses: actions/setup-node@v3
with:
node-version: 18
- name: Install dependencies
run: |
composer self-update
composer install --no-interaction --no-progress
yarn install --non-interactive
- name: Execute lint
run: yarn lint
- name: Build JS
run: yarn build
- name: Execute tests
run: vendor/bin/phpunit -c phpunit.xml.dist
- name: Prepare SonarCloud Scan
run: sed -i 's@'$GITHUB_WORKSPACE'@/github/workspace/@g' .coverage/clover.xml
- name: SonarCloud Scan
uses: SonarSource/sonarcloud-github-action@v1.6
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
- name: Set up QEMU
uses: docker/setup-qemu-action@v1
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v1
- name: Login to DockerHub
uses: docker/login-action@v1
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Production - Build and push PHP FPM
id: docker_build_php
uses: docker/build-push-action@v2
if: github.ref == 'refs/heads/main'
with:
file: ./docker/production/Dockerfile-phpfpmalpine
build-args: MIX_GOOGLE_ANALYTICS_ID=${{ secrets.MIX_GOOGLE_ANALYTICS_ID }}
push: true
tags: paulthebaud/phpunitgen-phpfpm:latest
- name: Production - Build and push Nginx
id: docker_build_nginx
uses: docker/build-push-action@v2
if: github.ref == 'refs/heads/main'
with:
file: ./docker/production/Dockerfile-nginxalpine
build-args: MIX_GOOGLE_ANALYTICS_ID=${{ secrets.MIX_GOOGLE_ANALYTICS_ID }}
push: true
tags: paulthebaud/phpunitgen-nginx:latest
- name: Staging - Build and push PHP FPM
id: docker_build_php_staging
uses: docker/build-push-action@v2
if: github.ref == 'refs/heads/develop'
with:
file: ./docker/staging/Dockerfile-phpfpmalpine
push: true
tags: paulthebaud/phpunitgen-phpfpm:staging
- name: Staging - Build and push Nginx
id: docker_build_nginx_staging
uses: docker/build-push-action@v2
if: github.ref == 'refs/heads/develop'
with:
file: ./docker/staging/Dockerfile-nginxalpine
push: true
tags: paulthebaud/phpunitgen-nginx:staging
- name: Production - Update deployment
uses: steebchen/kubectl@v2.0.0
if: github.ref == 'refs/heads/main'
with:
config: ${{ secrets.KUBE_CONFIG }}
command: apply -k kubernetes/production/
- name: Staging - Update deployment
uses: steebchen/kubectl@v2.0.0
if: github.ref == 'refs/heads/develop'
with:
config: ${{ secrets.KUBE_CONFIG }}
command: apply -k kubernetes/staging/
- name: Production - Restart deployment PHP FPM
uses: steebchen/kubectl@v2.0.0
if: github.ref == 'refs/heads/main'
with:
config: ${{ secrets.KUBE_CONFIG }}
command: rollout restart deployment/phpunitgen-phpfpm --namespace=phpunitgen
- name: Staging - Restart deployment PHP FPM
uses: steebchen/kubectl@v2.0.0
if: github.ref == 'refs/heads/develop'
with:
config: ${{ secrets.KUBE_CONFIG }}
command: rollout restart deployment/phpunitgen-phpfpm-staging --namespace=phpunitgen-staging
- name: Production - Restart deployment Nginx
uses: steebchen/kubectl@v2.0.0
if: github.ref == 'refs/heads/main'
with:
config: ${{ secrets.KUBE_CONFIG }}
command: rollout restart deployment/phpunitgen-nginx --namespace=phpunitgen
- name: Staging - Restart deployment Nginx
uses: steebchen/kubectl@v2.0.0
if: github.ref == 'refs/heads/develop'
with:
config: ${{ secrets.KUBE_CONFIG }}
command: rollout restart deployment/phpunitgen-nginx-staging --namespace=phpunitgen-staging