Merge pull request #1 from php-piaui/develop #24
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: Pipeline | |
on: | |
push: | |
branches: | |
- main | |
jobs: | |
ci: | |
name: Laravel (PHP ${{ matrix.php-versions }} on ${{ matrix.operating-system }}) | |
runs-on: ${{ matrix.operating-system }} | |
strategy: | |
fail-fast: false | |
matrix: | |
operating-system: [ubuntu-latest, windows-latest, macos-latest] | |
php-versions: ["8.1", "8.2", "8.3"] | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
- name: Setup PHP | |
uses: shivammathur/setup-php@v2 | |
with: | |
php-version: ${{ matrix.php-versions }} | |
extensions: mbstring, dom, fileinfo, pdo_sqlite | |
- name: Install Composer dependencies | |
run: composer update --no-progress --prefer-dist --optimize-autoloader | |
- name: Prepare the application | |
run: | | |
php -r "file_exists('.env') || copy('.env.example', '.env');" | |
php artisan key:generate | |
- name: Directory Permissions | |
run: chmod -R 777 storage bootstrap/cache | |
- name: Clear Config | |
run: php artisan config:clear | |
- name: Create Database | |
run: touch database/database.sqlite | |
- name: Migrate Database | |
env: | |
DB_CONNECTION: sqlite | |
DB_DATABASE: database/database.sqlite | |
run: php artisan migrate | |
- name: Test with phpunit | |
run: vendor/bin/phpunit --testdox | |
deploy-test: | |
name: Deploy to TEST Enviroment | |
runs-on: ubuntu-latest | |
needs: ci | |
environment: | |
name: test | |
url: http://pipelinedevelop.phppiaui.com.br | |
steps: | |
- name: Deploy | |
run: echo "Deploying to TEST environment" | |
- name: Print Enviroment variable | |
run: ${{ vars.SERVER_DIR }} | |
- name: Anything else | |
run: echo "run any bash comand you want" | |
deploy-develop: | |
name: Deploy to dev Enviroment | |
runs-on: ubuntu-latest | |
needs: deploy-test | |
environment: | |
name: develop | |
url: http://pipelinedevelop.phppiaui.com.br | |
steps: | |
- name: Deploy | |
run: echo "Deploying to develop environment" | |
- name: Checkout | |
uses: actions/checkout@v4 | |
- name: Deploy to ${{ vars.SERVER_DIR }} | |
uses: SamKirkland/FTP-Deploy-Action@master | |
with: | |
server: ${{ secrets.FTP_HOST }} | |
username: ${{ secrets.FTP_USER }} | |
password: ${{ secrets.FTP_PASSWORD }} | |
server-dir: ${{ vars.SERVER_DIR }} | |
- name: Executing remote ssh commands using password | |
uses: appleboy/ssh-action@master | |
with: | |
host: ${{ secrets.FTP_HOST }} | |
username: ${{ secrets.FTP_USER }} | |
password: ${{ secrets.FTP_PASSWORD }} | |
port: ${{ secrets.PORT }} | |
script: | | |
cd ${{ vars.SERVER_DIR }} | |
chmod +x script.sh && ./script.sh | |
deploy-homologacao: | |
name: Deploy to hmg Enviroment | |
runs-on: ubuntu-latest | |
needs: deploy-develop | |
environment: | |
name: homologacao | |
url: http://pipelinehomologacao.phppiaui.com.br | |
steps: | |
- name: Deploy | |
run: echo "Deploying to homologacao environment" | |
- name: Checkout | |
uses: actions/checkout@v4 | |
- name: Deploy to ${{ vars.SERVER_DIR }} | |
uses: SamKirkland/FTP-Deploy-Action@master | |
with: | |
server: ${{ secrets.FTP_HOST }} | |
username: ${{ secrets.FTP_USER }} | |
password: ${{ secrets.FTP_PASSWORD }} | |
server-dir: ${{ vars.SERVER_DIR }} | |
- name: Executing remote ssh commands using password | |
uses: appleboy/ssh-action@master | |
with: | |
host: ${{ secrets.FTP_HOST }} | |
username: ${{ secrets.FTP_USER }} | |
password: ${{ secrets.FTP_PASSWORD }} | |
port: ${{ secrets.PORT }} | |
script: | | |
cd ${{ vars.SERVER_DIR }} | |
chmod +x script.sh && ./script.sh | |
deploy-producao: | |
name: Deploy to prod Enviroment | |
runs-on: ubuntu-latest | |
needs: deploy-homologacao | |
environment: | |
name: production | |
url: http://pipeline.phppiaui.com.br | |
steps: | |
- name: Deploy | |
run: echo "Deploying to production environment" | |
- name: Checkout | |
uses: actions/checkout@v4 | |
- name: Deploy to ${{ vars.SERVER_DIR }} | |
uses: SamKirkland/FTP-Deploy-Action@master | |
with: | |
server: ${{ secrets.FTP_HOST }} | |
username: ${{ secrets.FTP_USER }} | |
password: ${{ secrets.FTP_PASSWORD }} | |
server-dir: ${{ vars.SERVER_DIR }} | |
- name: Executing remote ssh commands using password | |
uses: appleboy/ssh-action@master | |
with: | |
host: ${{ secrets.FTP_HOST }} | |
username: ${{ secrets.FTP_USER }} | |
password: ${{ secrets.FTP_PASSWORD }} | |
port: ${{ secrets.PORT }} | |
script: | | |
cd ${{ vars.SERVER_DIR }} | |
chmod +x script.sh && ./script.sh |