Skip to content

Commit

Permalink
[TASK] Optimize deployment (#315)
Browse files Browse the repository at this point in the history
  • Loading branch information
gilbertsoft authored Apr 5, 2022
1 parent 26b3811 commit 63f911c
Show file tree
Hide file tree
Showing 4 changed files with 40 additions and 21 deletions.
29 changes: 29 additions & 0 deletions .github/workflows/continuous-deployment.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
name: Continuous Deployment (CD)

on:
workflow_run:
workflows: [Continuous Integration (CI)]
types: [completed]
branches:
- develop
- production
- stage

jobs:
print_context:
runs-on: ubuntu-latest
steps:
- env:
GH_CONTEXT: ${{ toJSON(github) }}
EVENT_CONTEXT: ${{ toJSON(github.event) }}
run: |
echo $GH_CONTEXT
echo $EVENT_CONTEXT
deployment:
name: Deployment
if: ${{ github.event_name == 'push' }} && ${{ github.event.workflow_run.conclusion == 'success' }}
uses: ./.github/workflows/deployment.yml
secrets:
SSH_PRIVATE_KEY: ${{ secrets.SSH_PRIVATE_KEY }}
SSH_PASSPHRASE: ${{ secrets.SSH_PASSPHRASE }}
10 changes: 0 additions & 10 deletions .github/workflows/continuous-integration.yml
Original file line number Diff line number Diff line change
Expand Up @@ -539,13 +539,3 @@ jobs:
name: logs-${{ matrix.php-version }}-${{ matrix.dependencies }}
path: var/log
retention-days: 7

deployment:
name: Deployment
needs:
- tests
if: ${{ github.event_name == 'push' }}
uses: ./.github/workflows/deployment.yml
secrets:
SSH_PRIVATE_KEY: ${{ secrets.SSH_PRIVATE_KEY }}
SSH_PASSPHRASE: ${{ secrets.SSH_PASSPHRASE }}
2 changes: 1 addition & 1 deletion .github/workflows/deployment.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Deployment Template
name: Deployment

on:
workflow_call:
Expand Down
20 changes: 10 additions & 10 deletions .mage.yml
Original file line number Diff line number Diff line change
Expand Up @@ -48,15 +48,15 @@ magephp:
- fs/link: { from: "../../../../shared/public/packages.json", to: "public/packages.json" }
- fs/link: { from: "../../../../shared/public/satis.html", to: "public/satis.html" }
- exec: { cmd: "sqlite3 ~/site/mage/current/var/gettr.db '.backup var/gettr.db'", desc: "Copy DB" }
on-release:
post-release:
- fs/copy: { from: 'cnf/nginx.conf', to: '../../../../cnf/nginx.conf' }
- exec: { cmd: "nginx-reload", desc: "Reload Nginx Configuration" }
- exec: { cmd: "php-restart", desc: "Restart PHP and reset OPcache" }
- exec: { cmd: "php ./bin/console doctrine:migrations:sync-metadata-storage --no-interaction", desc: "Synchronize DB Migrations" }
- exec: { cmd: "php ./bin/console doctrine:migrations:migrate --no-interaction", desc: "Apply DB Migrations" }
- exec: { cmd: "php ./bin/console cache:warmup --env=prod", desc: "Cache Warmup", timeout: 600 }
on-release:
- fs/copy: { from: 'cnf/nginx.conf', to: '../../../../cnf/nginx.conf' }
- exec: { cmd: "nginx-reload", desc: "Reload Nginx Configuration" }
post-release:
- exec: { cmd: "php-restart", desc: "Restart PHP and reset OPcache again" }
- exec: { cmd: "php ./bin/console cache:warmup --env=prod", desc: "Cache Warmup", timeout: 600 }
- exec: { cmd: "crontab cnf/crontab-dev", desc: "Install crontab" }
post-deploy:
production:
Expand All @@ -77,15 +77,15 @@ magephp:
- fs/link: { from: "../../../../shared/public/packages.json", to: "public/packages.json" }
- fs/link: { from: "../../../../shared/public/satis.html", to: "public/satis.html" }
- exec: { cmd: "sqlite3 ~/site/mage/current/var/gettr.db '.backup var/gettr.db'", desc: "Copy DB" }
on-release:
post-release:
- fs/copy: { from: 'cnf/nginx.conf', to: '../../../../cnf/nginx.conf' }
- exec: { cmd: "nginx-reload", desc: "Reload Nginx Configuration" }
- exec: { cmd: "php-restart", desc: "Restart PHP and reset OPcache" }
- exec: { cmd: "php ./bin/console doctrine:migrations:sync-metadata-storage --no-interaction", desc: "Synchronize DB Migrations" }
- exec: { cmd: "php ./bin/console doctrine:migrations:migrate --no-interaction", desc: "Apply DB Migrations" }
- exec: { cmd: "php ./bin/console cache:warmup --env=prod", desc: "Cache Warmup", timeout: 600 }
on-release:
- fs/copy: { from: 'cnf/nginx.conf', to: '../../../../cnf/nginx.conf' }
- exec: { cmd: "nginx-reload", desc: "Reload Nginx Configuration" }
post-release:
- exec: { cmd: "php-restart", desc: "Restart PHP and reset OPcache again" }
- exec: { cmd: "php ./bin/console cache:warmup --env=prod", desc: "Cache Warmup", timeout: 600 }
- exec: { cmd: "crontab cnf/crontab", desc: "Install crontab" }
post-deploy:
stage:
Expand Down

0 comments on commit 63f911c

Please sign in to comment.