This repository has been archived by the owner on Feb 4, 2024. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 59
160 lines (150 loc) · 4.87 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
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
name: CI
on:
push:
branches: [ master ]
pull_request:
branches: [ master ]
deployment:
workflow_dispatch:
env:
DB_DATABASE: enso
DB_USERNAME: enso
DB_PASSWORD: secret
jobs:
yarn:
runs-on: ubuntu-20.04
env:
NODE_OPTIONS: --max_old_space_size=3072
SENTRY_ORG: ${{ secrets.SENTRY_ORG }}
SENTRY_PROJECT: ${{ secrets.SENTRY_PROJECT }}
SENTRY_URL: ${{ secrets.SENTRY_URL }}
SENTRY_AUTH_TOKEN: ${{ secrets.SENTRY_AUTH_TOKEN }}
steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
with:
node-version: '14'
- uses: borales/actions-yarn@v4
with:
cmd: install
- uses: shivammathur/setup-php@v2
with:
php-version: '8.2'
- name: 'test node'
run: node -v
- name: 'install & build'
run: |
sudo composer install
sed -i 's/GOOGLE_ANALITICS_TOKEN/${{ secrets.GOOGLE_ANALITICS_TOKEN }}/g' resources/views/stubs/production-index.blade.stub
sudo cp -f resources/views/stubs/production-index.blade.stub vendor/laravel-liberu/core/stubs
- name: Archive production artifacts
uses: actions/upload-artifact@v3
with:
name: resources
path: |
public/css/
public/js/
public/images/
resources/views
phpunit:
runs-on: ubuntu-20.04
steps:
- uses: actions/checkout@v3
- uses: shivammathur/setup-php@v2
with:
php-version: '8.2'
- name: 'PhpUnit'
run: |
sudo composer install
sudo php artisan test
phpcpd:
runs-on: ubuntu-20.04
steps:
- uses: actions/checkout@v3
- uses: shivammathur/setup-php@v2
with:
php-version: '8.2'
- name: 'Run Phpcpd'
run: |
sudo composer install
sudo test -f phpcpd.phar || curl -L https://phar.phpunit.de/phpcpd.phar -o phpcpd.phar
sudo php phpcpd.phar app/
php-insights:
runs-on: ubuntu-20.04
steps:
- uses: actions/checkout@v3
- uses: shivammathur/setup-php@v2
with:
php-version: '8.2'
- name: 'Run php-insight'
run: |
sudo composer install
sudo php artisan insights --min-quality=90 --min-complexity=90 --min-architecture=80 --min-style=90 --no-interaction
security:
runs-on: ubuntu-20.04
steps:
- uses: actions/checkout@v3
- uses: shivammathur/setup-php@v2
with:
php-version: '8.2'
- name: 'Run php-insight'
run: |
PHP_SC_VERSION=$(curl -s "https://api.github.com/repos/fabpot/local-php-security-checker/releases/latest" | grep '"tag_name":' | sed -E 's/.*"([^"]+)".*/\1/;s/^v//')
curl -LSs https://github.com/fabpot/local-php-security-checker/releases/download/v${PHP_SC_VERSION}/local-php-security-checker_${PHP_SC_VERSION}_linux_amd64 > ./php-security-checker
chmod +x ./php-security-checker
unset PHP_SC_VERSION
./php-security-checker
migration:
runs-on: ubuntu-20.04
steps:
- uses: actions/checkout@v3
- uses: mirromutth/mysql-action@v1.1
with:
mysql database: ${{env.DB_DATABASE}}
mysql user: ${{env.DB_USERNAME}}
mysql password: ${{env.DB_PASSWORD}}
- uses: shivammathur/setup-php@v2
with:
php-version: '8.2'
- name: 'Run migration'
run: |
sudo composer install
php artisan migrate --force
deploy:
runs-on: ubuntu-20.04
if: ${{ github.event_name == 'deployment' || github.event_name == 'push' }}
needs: [phpunit, phpcpd, migration, yarn, security, php-insights]
steps:
- uses: actions/checkout@v3
- name: 'Trig envoyer'
run: |
curl ${{ secrets.DEPLOY_WEBHOOK }}
docker:
if: github.event_name == 'push'
runs-on: ubuntu-latest
steps:
-
name: Login to Docker Hub
uses: docker/login-action@v2
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
-
name: Extract metadata (tags, labels) for Docker
id: meta
uses: docker/metadata-action@818d4b7b91585d195f67373fd9cb0332e31a7175
with:
images: liberu/genealogy-backend
-
# Setting up Docker Buildx with docker-container driver is required
# at the moment to be able to use a subdirectory with Git context
name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
- name: Build and push Docker image
uses: docker/build-push-action@0565240e2d4ab88bba5387d719585280857ece09
with:
# context: "{{defaultContext}}:.docker/prod/app/"
file: Dockerfile
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}