-
Notifications
You must be signed in to change notification settings - Fork 43
43 lines (38 loc) · 1.73 KB
/
dokku-clean-review-apps.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
name: Delete all Dokku Review-Apps
on:
workflow_dispatch:
jobs:
cleanup:
runs-on: ubuntu-latest
steps:
- name: Add public IP to AWS security group
uses: sohelamin/aws-security-group-add-ip-action@master
with:
aws-access-key-id: ${{ secrets.DOKKU_AWS_ACCESS_KEY_ID }}
aws-secret-access-key: ${{ secrets.DOKKU_AWS_SECRET_ACCESS_KEY }}
aws-region: ${{ secrets.DOKKU_AWS_REGION }}
aws-security-group-id: ${{ secrets.DOKKU_AWS_SECURITY_GROUP_ID }}
port: '22'
to-port: '30'
protocol: 'tcp'
description: 'GitHub Action'
- name: Destroy all review-apps and its associated database & redis services
uses: appleboy/ssh-action@master
with:
host: ${{ secrets.DOKKU_HOST }}
key: ${{ secrets.DOKKU_SSH_PRIVATE_KEY }}
username: ubuntu
script: |
dokku --quiet apps:list | grep -v "violet-rails" | while read APP_NAME;
do {
dokku apps:exists $APP_NAME && dokku --force apps:destroy $APP_NAME;
dokku postgres:exists "${APP_NAME}-db" && dokku postgres:destroy "${APP_NAME}-db" --force;
dokku redis:exists "${APP_NAME}-redis" && dokku redis:destroy "${APP_NAME}-redis" --force;
if [ -d /home/dokku/$APP_NAME ]; then
echo "Folder of ${APP_NAME} still exists.\nDeleting it manually.";
sudo rm -rf /home/dokku/$APP_NAME;
[ -d /home/dokku/$APP_NAME ] && echo "Could not delete ${APP_NAME}." || echo "${APP_NAME} deleted successfully.";
fi
echo "Deletion of ${APP_NAME} app, ${APP_NAME}-db and ${APP_NAME}-redis completed.";
};
done;