diff --git a/.github/workflows/continuous-deployment.yml b/.github/workflows/continuous-deployment.yml new file mode 100644 index 00000000..a8ec7dc0 --- /dev/null +++ b/.github/workflows/continuous-deployment.yml @@ -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 }} diff --git a/.github/workflows/continuous-integration.yml b/.github/workflows/continuous-integration.yml index d05e55d5..bbcd8481 100644 --- a/.github/workflows/continuous-integration.yml +++ b/.github/workflows/continuous-integration.yml @@ -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 }} diff --git a/.github/workflows/deployment.yml b/.github/workflows/deployment.yml index a8c529d7..2330a3cb 100644 --- a/.github/workflows/deployment.yml +++ b/.github/workflows/deployment.yml @@ -1,4 +1,4 @@ -name: Deployment Template +name: Deployment on: workflow_call: diff --git a/.mage.yml b/.mage.yml index 7bfb1db4..2f545534 100644 --- a/.mage.yml +++ b/.mage.yml @@ -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: @@ -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: