-
-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
149 additions
and
0 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,86 @@ | ||
name: Tomato CI/CD | ||
on: | ||
pull_request: | ||
branches: | ||
- master | ||
push: | ||
branches: | ||
- master | ||
jobs: | ||
laravel: | ||
name: Laravel (PHP ${{ matrix.php-versions }}) | ||
runs-on: ubuntu-latest | ||
env: | ||
DB_DATABASE: laravel | ||
DB_USERNAME: root | ||
DB_PASSWORD: password | ||
services: | ||
mysql: | ||
image: mysql:latest | ||
env: | ||
MYSQL_ALLOW_EMPTY_PASSWORD: false | ||
MYSQL_ROOT_PASSWORD: password | ||
MYSQL_DATABASE: laravel | ||
ports: | ||
- 3306/tcp | ||
options: --health-cmd="mysqladmin ping" --health-interval=10s --health-timeout=5s --health-retries=3 | ||
|
||
redis: | ||
image: redis | ||
ports: | ||
- 6379/tcp | ||
options: --health-cmd="redis-cli ping" --health-interval=10s --health-timeout=5s --health-retries=3 | ||
strategy: | ||
fail-fast: false | ||
matrix: | ||
php-versions: ['8.2'] | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v4 | ||
|
||
- name: Setup PHP | ||
uses: shivammathur/setup-php@v2 | ||
with: | ||
php-version: ${{ matrix.php-versions }} | ||
extensions: sqlite, pdo_sqlite, pcntl, zip, intl, exif, mbstring, dom, fileinfo, mysql | ||
coverage: xdebug | ||
|
||
- name: Copy .env Before Install Composer | ||
run: php -r "file_exists('.env') || copy('.env.example', '.env'); echo file_get_contents('.env');" | ||
|
||
- name: Start MySQL Service | ||
run: sudo /etc/init.d/mysql start | ||
|
||
- name: Get composer cache directory | ||
id: composer-cache | ||
run: echo "dir=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT | ||
|
||
- name: Cache composer dependencies | ||
uses: actions/cache@v3 | ||
with: | ||
path: ${{ steps.composer-cache.outputs.dir }} | ||
# Use composer.json for key, if composer.lock is not committed. | ||
# key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.json') }} | ||
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }} | ||
restore-keys: ${{ runner.os }}-composer- | ||
|
||
- name: Install Composer dependencies | ||
run: composer install --no-progress --prefer-dist --optimize-autoloader | ||
|
||
- name: Generate Applications Key | ||
run: php artisan key:generate | ||
|
||
- name: Clear Config | ||
run: php artisan config:clear | ||
|
||
- name: Run Migration | ||
run: php artisan migrate -v | ||
env: | ||
DB_PORT: ${{ job.services.mysql.ports['3306'] }} | ||
REDIS_PORT: ${{ job.services.redis.ports['6379'] }} | ||
|
||
- name: Install Yarn dependencies | ||
run: yarn | ||
|
||
- name: Compile assets | ||
run: yarn build |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
#!/bin/bash | ||
set -e | ||
|
||
echo "Deployment started ..." | ||
|
||
# Enter maintenance mode or return true | ||
# if already is in maintenance mode | ||
(php artisan down) || true | ||
|
||
# Pull the latest version of the app | ||
git reset --hard | ||
git pull origin master | ||
|
||
# Install composer dependencies | ||
composer install | ||
|
||
# Clear the old cache | ||
php8.2 artisan clear-compiled | ||
|
||
# Recreate cache | ||
php8.2 artisan optimize | ||
|
||
# Compile npm assets | ||
yarn | ||
yarn build | ||
|
||
# Run database migrations | ||
php8.2 artisan migrate --force | ||
|
||
# Exit maintenance mode | ||
php8.2 artisan up | ||
|
||
echo "Deployment finished!" |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
#!/bin/bash | ||
sudo add-apt-repository ppa:ondrej/php | ||
sudo apt-get update | ||
sudo apt-get -y install curl git network-manager libnss3-tools jq xsel software-properties-common php8.2-fpm php8.2-cli php8.2-bcmath php8.2-common php8.2-curl php8.2-mbstring php8.2-opcache php8.2-readline php8.2-xml php8.2-zip php8.2-mysql php8.2-gd mysql-server supervisor | ||
sudo mysql -e "create database bing;" | ||
sudo mysql -e "ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY '12345678';" | ||
sudo mysql -e "FLUSH PRIVILEGES;" | ||
curl -sS https://getcomposer.org/installer | sudo php -- --install-dir=/usr/local/bin --filename=composer | ||
composer --version | ||
composer global require genesisweb/valet-linux-plus | ||
export PATH="$PATH:$HOME/.config/composer/vendor/bin" | ||
valet install | ||
cd ~/Sites/bing | ||
composer install | ||
cp .env.example .env | ||
php artisan key:generate | ||
php artisan config:cache | ||
valet link | ||
valet secure | ||
php artisan migrate | ||
php artisan config:cache | ||
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.3/install.sh | bash | ||
export NVM_DIR="$HOME/.nvm" | ||
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh" | ||
nvm install 18 | ||
nvm use 18 | ||
npm -g i yarn | ||
yarn | ||
yarn build | ||
valet open |