Skip to content

Merge pull request #183 from Oneami/master #522

Merge pull request #183 from Oneami/master

Merge pull request #183 from Oneami/master #522

Workflow file for this run

name: Production
on:
push:
branches: [ master ]
repository_dispatch:
types: [ retry-* ]
workflow_dispatch:
inputs:
verbosity:
description: 'Verbosity level'
default: "-vvv"
type: string
concurrency:
group: ${{ github.ref }}
cancel-in-progress: true
jobs:
laravel-tests-and-deploy:
runs-on: ubuntu-20.04
environment: production
defaults:
run:
working-directory: ./src
steps:
- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: '8.1'
- uses: actions/checkout@v3
- uses: symfonycorp/security-checker-action@v3
with:
lock: src/composer.lock
- name: Copy .env
run: php -r "file_exists('.env') || copy('.env.example', '.env');"
- name: Install composer dependencies
run: composer install --optimize-autoloader --no-dev --quiet
- name: Generate key
run: php artisan key:generate
- name: Directory Permissions
run: chmod -R 777 storage bootstrap/cache
- name: Install NPM dependencies
run: npm install
- name: Minify CSS and JS files
run: npm run production
- name: Remove node_modules folder
run: rm -R node_modules
# !!! need mysql
# - name: Execute tests (Unit and Feature tests) via PHPUnit
# env:
# DB_CONNECTION: sqlite
# DB_DATABASE: database/database.sqlite
# run: |
# mkdir -p database
# touch database/database.sqlite
# php artisan migrate --force
# php artisan job:dispatch SxGeoUpdateJob
# php artisan test
- name: Deploy
env:
DEPLOY_HOST: ${{ secrets.DEPLOY_HOST }}
DEPLOY_USER: ${{ secrets.DEPLOY_USER }}
DEPLOY_PORT: ${{ secrets.DEPLOY_PORT }}
DEPLOY_PATH: ${{ secrets.DEPLOY_PATH }}
run: |
mkdir -p ~/.ssh
touch ~/.ssh/deploy
(echo ${{ secrets.DEPLOY_SSH_KEY }} | base64 --decode -i > ~/.ssh/deploy)
chmod 700 ~/.ssh/deploy
php ./vendor/bin/dep deploy ${{ inputs.verbosity }}
- name: Send success status
uses: appleboy/telegram-action@master
with:
to: ${{ secrets.TELEGRAM_TO }}
token: ${{ secrets.TELEGRAM_TOKEN }}
message: Success deploying ✅
##################################
### Run when a schedule failed ###
##################################
# restart_when_failed:
# name: Restarts workflow if failed
# runs-on: ubuntu-latest
# if: failure() && github.event.client_payload.attempt < 5
# needs: laravel-tests-and-deploy
# steps:
# - name: Sleep for 1m 36s
# uses: jakejarvis/wait-action@master
# with:
# time: '96s'
# - name: set attempt
# run: |
# ATTEMPT=${{ github.event.client_payload.attempt }}
# ATTEMPT=$([ -n "$ATTEMPT" ] && echo $((++ATTEMPT)) || echo 1)
# echo "attempt=$ATTEMPT" >> $GITHUB_ENV
# - name: Send retry status
# uses: appleboy/telegram-action@master
# with:
# to: ${{ secrets.TELEGRAM_TO }}
# token: ${{ secrets.TELEGRAM_TOKEN }}
# message: Failure deploy (${{ env.attempt }}) ❌ Rerun 🔄
# - name: Retry the workflow
# uses: peter-evans/repository-dispatch@v1
# with:
# token: ${{ secrets.API_WORKFLOW_KEY }}
# event-type: retry-${{ env.attempt }}
# client-payload: '{"ref": "${{ github.ref }}", "attempt": "${{ env.attempt }}"}'