add empty line #84
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |