-
Notifications
You must be signed in to change notification settings - Fork 58
77 lines (64 loc) · 2.46 KB
/
dev.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
name: Laravel CI DEV
on:
push:
branches:
- dev
jobs:
run-tests:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v2
- name: Set up PHP
uses: shivammathur/setup-php@v2
with:
php-version: '8.2'
extensions: pgsql, pdo_pgsql, zip, bcmath
- name: Get Composer cache directory
id: composer-cache
run: echo "::set-output name=dir::$(composer config cache-dir)"
- name: Cache Composer dependencies
uses: actions/cache@v3
with:
path: ${{ steps.composer-cache.outputs.dir }}
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }}
restore-keys: |
${{ runner.os }}-composer-
- name: Install PHP dependencies
run: composer install --no-interaction --prefer-dist --optimize-autoloader
- name: Set environment variables for CI
run: |
cp .env.example .env
echo "APP_KEY=${{ secrets.APP_KEY }}" >> .env
echo "DB_CONNECTION=pgsql" >> .env
echo "DB_HOST=${{ secrets.DB_HOST }}" >> .env
echo "DB_PORT=${{ secrets.DB_PORT }}" >> .env
echo "DB_DATABASE=${{ secrets.DB_DATABASE }}" >> .env
echo "DB_USERNAME=${{ secrets.DB_USERNAME }}" >> .env
echo "DB_PASSWORD=${{ secrets.DB_PASSWORD }}" >> .env
# Uncomment the line below if you prefer to set DATABASE_URL instead of individual DB environment variables
# echo "DATABASE_URL=postgres://${{ secrets.DB_USERNAME }}:${{ secrets.DB_PASSWORD }}@${{ secrets.DB_HOST }}:${{ secrets.DB_PORT }}/${{ secrets.DB_DATABASE }}?sslmode=disable" >> .env
- name: Run database migrations
run: php artisan migrate --force
- name: Clear all cache
run: php artisan optimize
- name: Clear configuration cache
run: php artisan config:clear
- name: Run Laravel tests
run: |
php artisan jwt:secret
php artisan test
- name: Deploy to server
uses: appleboy/ssh-action@master
with:
host: ${{ secrets.SSH_HOST }}
username: ${{ secrets.SSH_USER }}
key: ${{ secrets.SSH_KEY }}
script: |
echo "About to Deploy"
cd /var/www/langlearnai-be/deployment
eval $(ssh-agent)
ssh-add ~/.ssh/id_ecdsa
git pull origin dev
composer install
php artisan migrate --force