🚀 Deployment #74
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: 🚀 Deployment | |
# Only trigger, when the build workflow is done | |
on: | |
workflow_run: | |
workflows: [ "🧪 Build test" ] | |
types: | |
- completed | |
jobs: | |
run: | |
# Run job only on success of the build test workflow, and if the event was a push to the master branch | |
if: ${{ github.event.workflow_run.conclusion == 'success' && github.event.workflow_run.head_branch == 'master' }} | |
runs-on: ubuntu-latest | |
name: Deploy PHP application | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v3 | |
with: | |
fetch-depth: 0 | |
- name: Setup PHP | |
uses: shivammathur/setup-php@v2 | |
with: | |
php-version: 8.2 | |
# extensions: mbstring, pdo, pdo_mysql, intl, zip | |
coverage: none | |
- name: Cache Composer packages | |
id: composer-cache | |
uses: actions/cache@v2 | |
with: | |
path: vendor | |
key: ${{ runner.os }}-php-${{ hashFiles('**/composer.lock') }} | |
restore-keys: | | |
${{ runner.os }}-php- | |
- name: Validate composer.json and composer.lock | |
run: composer validate | |
- name: Install dependencies | |
run: composer install --prefer-dist --no-progress | |
- name: 📂 Sync files | |
uses: SamKirkland/[email protected] | |
with: | |
server: ${{ secrets.FTP_HOST }} | |
username: ${{ secrets.FTP_USERNAME }} | |
password: ${{ secrets.FTP_PASSWORD }} | |
server-dir: / | |
exclude: | | |
.git*/** | |
docs/** | |
tests/** | |
- name: Executing database migrations | |
uses: appleboy/[email protected] | |
with: | |
host: ${{ secrets.SSH_HOST }} | |
username: ${{ secrets.SSH_USERNAME }} | |
key: ${{ secrets.SSH_KEY }} | |
passphrase: ${{ secrets.SSH_KEY_PASSPHRASE }} | |
port: ${{ secrets.SSH_PORT }} | |
script: | | |
cd ${{ secrets.DEMO_PROJECT_ROOT }} | |
chmod +x vendor/bin/phinx | |
composer migrate:prod | |
- name: ♥️ Sync files with care-point | |
uses: SamKirkland/[email protected] | |
with: | |
server: ${{ secrets.CARE_POINT_FTP_HOST }} | |
username: ${{ secrets.CARE_POINT_FTP_USERNAME }} | |
password: ${{ secrets.CARE_POINT_FTP_PASSWORD }} | |
server-dir: / | |
exclude: | | |
.git*/** | |
docs/** | |
tests/** | |
config/env/env.prod.php | |
public/favicon.ico | |
- name: Executing care-point database migrations | |
uses: appleboy/[email protected] | |
with: | |
host: ${{ secrets.CARE_POINT_SSH_HOST }} | |
username: ${{ secrets.CARE_POINT_SSH_USERNAME }} | |
key: ${{ secrets.CARE_POINT_SSH_KEY }} | |
passphrase: ${{ secrets.CARE_POINT_SSH_KEY_PASSPHRASE }} | |
port: ${{ secrets.CARE_POINT_SSH_PORT }} | |
script: | | |
cd ${{ secrets.CARE_POINT_PROJECT_ROOT }} | |
chmod +x vendor/bin/phinx | |
composer migrate:prod |