-
Notifications
You must be signed in to change notification settings - Fork 14
113 lines (105 loc) · 3.61 KB
/
tasks.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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
# Run database migration commands inside the Docker container running
# the Elastic Beanstalk application
name: Tasks
on:
workflow_dispatch:
inputs:
Task:
type: choice
description: "The task to perform"
required: true
options:
- 'db current revision'
- 'db upgrade to head'
- 'db upgrade to next'
- 'db downgrade to previous'
Environment:
type: choice
description: "The environment to target"
required: true
default: 'qa'
options:
- 'qa'
- 'prod'
Timeout:
type: string
description: "The timeout in seconds"
default: '900'
Region:
type: choice
description: "The AWS region to target"
required: true
default: 'all'
options:
- 'all'
- 'ca-central-1'
- 'us-west-1'
Destructive:
description: Check to confirm you are happy to proceed with a destructive operation
type: boolean
required: false
default: false
jobs:
preflight:
runs-on: ubuntu-latest
steps:
- name: catch unauthorised destructive operations
run: |
if [[ "${{ inputs.Task }}" = 'db upgrade to head' ]] &&
[[ "${{ github.event.inputs.Destructive }}" = 'false' ]] ||
[[ "${{ inputs.Task }}" = 'db upgrade to next' ]] &&
[[ "${{ github.event.inputs.Destructive }}" = 'false' ]] ||
[[ "${{ inputs.Task }}" = 'db downgrade to previous' ]] &&
[[ "${{ github.event.inputs.Destructive }}" = 'false' ]] ; then
echo "::error::'${{ inputs.Task }}' needs destructive option"
exit 1
else
echo "::notice::Preparing '${{ inputs.Task }}' update in ${{ inputs.Environment }}"
echo "::notice::Targeting regions - '${{ inputs.region }}'"
echo "::notice::Timeout - '${{ inputs.Timeout }}'"
exit 0
fi
current:
if: inputs.Task == 'db current revision'
needs: preflight
uses: hypothesis/workflows/.github/workflows/eb-task.yml@main
with:
App: ${{ github.event.repository.name }}
Env: ${{ inputs.Environment }}
Timeout: ${{ inputs.Timeout }}
Region: ${{ inputs.Region }}
Command: 'alembic -c conf/alembic.ini current'
secrets: inherit
head:
if: inputs.Task == 'db upgrade to head' && github.event.inputs.Destructive == 'true'
needs: preflight
uses: hypothesis/workflows/.github/workflows/eb-task.yml@main
with:
App: ${{ github.event.repository.name }}
Env: ${{ inputs.Environment }}
Timeout: ${{ inputs.Timeout }}
Region: ${{ inputs.Region }}
Command: 'alembic -c conf/alembic.ini upgrade head'
secrets: inherit
next:
if: inputs.Task == 'db upgrade to next' && github.event.inputs.Destructive == 'true'
needs: preflight
uses: hypothesis/workflows/.github/workflows/eb-task.yml@main
with:
App: ${{ github.event.repository.name }}
Env: ${{ inputs.Environment }}
Timeout: ${{ inputs.Timeout }}
Region: ${{ inputs.Region }}
Command: 'alembic -c conf/alembic.ini upgrade +1'
secrets: inherit
downgrade:
if: inputs.Task == 'db downgrade to previous' && github.event.inputs.Destructive == 'true'
needs: preflight
uses: hypothesis/workflows/.github/workflows/eb-task.yml@main
with:
App: ${{ github.event.repository.name }}
Env: ${{ inputs.Environment }}
Timeout: ${{ inputs.Timeout }}
Region: ${{ inputs.Region }}
Command: 'alembic -c conf/alembic.ini downgrade -1'
secrets: inherit