-
Notifications
You must be signed in to change notification settings - Fork 2
92 lines (72 loc) · 2.63 KB
/
build-and-delpoy.yaml
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
name: CI/CD Pipeline
on:
push:
branches:
- main
pull_request:
branches:
- main
jobs:
test:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Set up PHP
uses: shivammathur/setup-php@v2
with:
php-version: '8.3'
extensions: mbstring, intl, pdo_mysql
ini-values: post_max_size=256M, upload_max_filesize=256M, memory_limit=2G
coverage: none
- name: Install dependencies
run: composer install --prefer-dist --no-progress --no-suggest
- name: create test database
run: php bin/console doctrine:schema:create --env=test
- name: Run tests
run: vendor/bin/phpunit
deploy:
runs-on: ubuntu-latest
needs: test
if: github.ref == 'refs/heads/main'
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Set up PHP
uses: shivammathur/setup-php@v2
with:
php-version: '8.3'
extensions: mbstring, intl, pdo_mysql
ini-values: post_max_size=256M, upload_max_filesize=256M, memory_limit=2G
coverage: none
- name: Install dependencies
run: ./bin/composer install --no-dev --optimize-autoloader --no-scripts
- name: Set up environment
run: cp .env.prod .env
- name: Deploy via SSH
uses: appleboy/[email protected]
with:
host: ${{ secrets.SERVER_HOST }}
username: ${{ secrets.SERVER_USER }}
key: ${{ secrets.SERVER_SSH_KEY }}
script: |
# Set the project directory
PROJECT_DIR="${{ secrets.PROJECT_DIR }}/linksink"
# Check if the directory exists, if not, clone the repository
if [ ! -d "$PROJECT_DIR" ]; then
echo "Project not found. Cloning repository..."
git clone https://github.com/freifunk/linksink.git $PROJECT_DIR
fi
# Navigate to the project directory
cd $PROJECT_DIR
# Ensure the repository is up-to-date
git fetch --all
git reset --hard origin/main
# Install dependencies and clear the cache
cp .env.prod .env
echo "DATABASE_URL=${{ secrets.DATABASE_PROD_URL }}" >> .env
echo "APP_SECRET=${{ secrets.APP_SECRET }}" >> .env
./bin/composer install --no-dev --optimize-autoloader
php bin/console cache:clear
php bin/console asset-map:compile
php bin/console assets:install --no-debug