Skip to content

Commit

Permalink
Issue #10: DigitalOcean App Platform pre- and post-deploy jobs added.
Browse files Browse the repository at this point in the history
  • Loading branch information
Ambient-Impact committed Oct 2, 2023
1 parent 5bb9f30 commit f3a0090
Show file tree
Hide file tree
Showing 7 changed files with 86 additions and 12 deletions.
32 changes: 32 additions & 0 deletions .do/app.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -153,3 +153,35 @@ workers:
name: background-tasks
run_command: php .do/run-background-tasks.php
source_dir: /

jobs:
- environment_slug: php
github:
branch: 9.x
repo: neurocracy/omnipedia
instance_count: 1
instance_size_slug: professional-xs
kind: PRE_DEPLOY
name: pre-deploy
run_command: .do/jobs/pre-deploy.sh
source_dir: /
- environment_slug: php
github:
branch: 9.x
repo: neurocracy/omnipedia
instance_count: 1
instance_size_slug: professional-xs
kind: POST_DEPLOY
name: post-successful-deploy
run_command: .do/jobs/post-successful-deploy.sh
source_dir: /
- environment_slug: php
github:
branch: 9.x
repo: neurocracy/omnipedia
instance_count: 1
instance_size_slug: professional-xs
kind: FAILED_DEPLOY
name: post-failed-deploy
run_command: .do/jobs/post-failed-deploy.sh
source_dir: /
4 changes: 0 additions & 4 deletions .do/deploy-tasks.sh

This file was deleted.

32 changes: 32 additions & 0 deletions .do/deploy.template.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -155,3 +155,35 @@ spec:
name: background-tasks
run_command: php .do/run-background-tasks.php
source_dir: /

jobs:
- environment_slug: php
github:
branch: 9.x
repo: neurocracy/omnipedia
instance_count: 1
instance_size_slug: professional-xs
kind: PRE_DEPLOY
name: pre-deploy
run_command: .do/jobs/pre-deploy.sh
source_dir: /
- environment_slug: php
github:
branch: 9.x
repo: neurocracy/omnipedia
instance_count: 1
instance_size_slug: professional-xs
kind: POST_DEPLOY
name: post-successful-deploy
run_command: .do/jobs/post-successful-deploy.sh
source_dir: /
- environment_slug: php
github:
branch: 9.x
repo: neurocracy/omnipedia
instance_count: 1
instance_size_slug: professional-xs
kind: FAILED_DEPLOY
name: post-failed-deploy
run_command: .do/jobs/post-failed-deploy.sh
source_dir: /
9 changes: 9 additions & 0 deletions .do/jobs/post-failed-deploy.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#!/bin/bash

# Disable maintenance mode.
#
# The database is shared between all deploys, even failed ones, so we need to
# turn off maintenance mode so that the live copy of the site (not this failed
# deploy) is publicly accessible again.
drush maint:set 0
echo "=> Maintenance mode has been turned off"
5 changes: 5 additions & 0 deletions .do/jobs/post-successful-deploy.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#!/bin/bash

# Disable maintenance mode.
drush maint:set 0
echo "=> Maintenance mode has been turned off"
8 changes: 8 additions & 0 deletions .do/jobs/pre-deploy.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#!/bin/bash

# Enable maintenance mode.
drush maint:set 1
echo "=> Maintenance mode has been turned on"

# Run any necessary database updates.
drush -y updb
8 changes: 0 additions & 8 deletions .do/run-background-tasks.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,6 @@
(new WorkerProcess(__DIR__ . '/run-common.sh'))->start();
});

# Run deploy tasks. Note that this assumes only one background tasks worker.
#
# @todo Rework this to ensure it only runs once on deploy, either as an App
# Platform job or using some form of locking.
$loop->futureTick(function(): void {
(new WorkerProcess(__DIR__ . '/deploy-tasks.sh'))->start();
});

// Run cron every 15 minutes.
$loop->addPeriodicTimer(900, function(): void {
(new WorkerProcess('drush cron'))->start();
Expand Down

0 comments on commit f3a0090

Please sign in to comment.