-
Notifications
You must be signed in to change notification settings - Fork 0
89 lines (84 loc) · 3.21 KB
/
build.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
name: FreeChampionRotationsV2
on:
push:
branches: [ "main", "develop" ]
jobs:
laravel-tests:
runs-on: ubuntu-latest
strategy:
matrix:
php-versions: [ '8.1' ]
name: PHP ${{ matrix.php-versions }}
steps:
- uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php-versions }}
- uses: actions/checkout@v3
- name: Copy .env
run: php -r "file_exists('.env') || copy('.env.example', '.env');"
- name: Install Dependencies
run: composer install --no-ansi --no-interaction --no-scripts --no-progress --prefer-dist
- name: Generate key
run: php artisan key:generate
- name: Directory Permissions
run: chmod -R 777 storage bootstrap/cache
- name: Create Database
run: |
mkdir -p database
touch database/database.sqlite
- name: Execute tests via PHPUnit
env:
DB_CONNECTION: sqlite
DB_DATABASE: database/database.sqlite
run: vendor/bin/phpunit
laravel-build:
needs: laravel-tests
runs-on: self-hosted
defaults:
run:
working-directory: ${{ github.sha }}-${{ github.run_id }}
container:
image: kirschbaumdevelopment/laravel-test-runner:8.1
steps:
- uses: actions/checkout@v3
with:
path: ${{ github.sha }}-${{ github.run_id }}
- name: copy production env
run: php -r "file_exists('.env') || copy('.env.production', '.env');"
- name: Install Dependencies
run: composer install -q --no-ansi --no-interaction --no-scripts --no-progress --prefer-dist --optimize-autoloader --no-dev
- name: Generate key
run: php artisan key:generate
- name: Directory Permissions
run: chmod -R 777 storage bootstrap/cache
- name: set secret variables
env:
DB_PASSWORD: ${{ secrets.DB_PASSWORD }}
RGAPI: ${{ secrets.RGAPI }}
run: echo $RGAPI >> .env && echo $DB_PASSWORD >> .env
- name: Setup Node
uses: actions/setup-node@v2
with:
node-version: '16'
- name: Cache dependencies
uses: actions/cache@v2
with:
path: ~/.npm
key: npm-${{ hashFiles('package-lock.json') }}
restore-keys: npm-
- name: Install dependencies
run: npm ci && npm run build
- name: clear cache then cache config and views
run: php artisan optimize:clear && php artisan view:cache
laravel-deploy:
needs: laravel-build
runs-on: self-hosted
steps:
- name: Check if records exist else executes call to fetch data
run: docker exec -w /var/www/${{ github.sha }}-${{ github.run_id }} freechampionsrotationsv2_php_1 php artisan FCRCheck:record
- name: change nginx document root
run: docker exec freechampionsrotationsv2_nginx_1 sed -i -e "s|root /var/www/[A-za-z0-9]\+-[0-9]\+/public;|root /var/www/${{ github.sha }}-${{ github.run_id }}/public;|g" /etc/nginx/conf.d/nginx.conf
- name: reload nginx
run: docker exec freechampionsrotationsv2_nginx_1 nginx -s reload
- name: echo newest version to file
run: echo "${{ github.sha }}-${{ github.run_id }}" > ${{ github.workspace }}/mostrecent