Last active
February 3, 2023 00:59
-
-
Save sourovroy/f5a6be868feaff178190f2b5509651eb to your computer and use it in GitHub Desktop.
GitHub Actions for Laravel application
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: Continuous Integration | |
on: | |
push: | |
branches: | |
- master | |
- develop | |
- 'feature/**' | |
defaults: | |
run: | |
shell: bash | |
jobs: | |
laravel-tests: | |
runs-on: ubuntu-18.04 | |
env: | |
DB_CONNECTION: sqlite | |
DB_DATABASE: database/database.sqlite | |
steps: | |
- uses: actions/checkout@v2 | |
- name: Copy .env | |
run: php -r "file_exists('.env') || copy('.env.example', '.env');" | |
- name: Create sqlite database | |
run: touch database/database.sqlite | |
- name: Install dependencies | |
run: composer install -q --no-ansi --no-interaction --no-scripts --no-suggest --no-progress --prefer-dist | |
- name: Generate key | |
run: php artisan key:generate | |
- name: Set directory permissions | |
run: chmod -R 777 storage bootstrap/cache | |
- name: Execute tests (Unit and Feature tests) via PHPUnit | |
run: vendor/bin/phpunit | |
deloy: | |
if: ${{ github.ref == 'refs/heads/master' }} | |
runs-on: ubuntu-18.04 | |
needs: laravel-tests | |
steps: | |
- name: Call server webhook | |
run: | | |
status_code=$(curl -d ${{ secrets.WEBHOOK_DATA }} --silent --show-error --write-out '%{http_code}' --output "/tmp/response.txt" ${{ secrets.WEBHOOK_URL }}) | |
cat /tmp/response.txt | |
if [[ ${status_code} -ne 200 ]]; then exit 1; fi |
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
#!/bin/bash | |
set -e | |
export COMPOSER_HOME="/home/sourov/.composer"; | |
cd /home/sourov/sites/github-actions | |
echo "" | |
echo -e "\e[1m** Pull master branch of git repository\e[0m" | |
git pull origin master | |
echo "" | |
echo -e "\e[1m** Install composer packages\e[0m" | |
composer install --no-dev --no-interaction 2>&1 | |
echo "" | |
echo -e "\e[1m** Run migration\e[0m" | |
php artisan migrate 2>&1 | |
echo "" | |
echo -e "\e[1m** Clear cache\e[0m" | |
php artisan optimize 2>&1 | |
php artisan view:clear 2>&1 | |
echo "" | |
echo -e "\e[1m***** Deploy finished successfuly *****\e[0m" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment