15
15
default : ' Stage'
16
16
17
17
jobs :
18
- secrets -check :
18
+ setup -check :
19
19
runs-on : ubuntu-latest
20
20
environment : ${{ inputs.environment || 'Production' }}
21
21
steps :
22
- - name : Check DEPLOY_HOST
23
- env :
24
- DEPLOY_HOST : ${{ secrets.DEPLOY_HOST }}
25
- run : |
26
- if [ -z "$DEPLOY_HOST" ]; then
27
- echo "DEPLOY_HOST is not set."
28
- exit 1
29
- fi
30
-
31
- - name : Check DEPLOY_USER
32
- env :
33
- DEPLOY_USER : ${{ secrets.DEPLOY_USER }}
34
- run : |
35
- if [ -z "$DEPLOY_USER" ]; then
36
- echo "DEPLOY_USER is not set."
37
- exit 1
38
- fi
39
-
40
- - name : Check DEPLOY_PATH
41
- env :
42
- DEPLOY_PATH : ${{ secrets.DEPLOY_PATH }}
43
- run : |
44
- if [ -z "$DEPLOY_PATH" ]; then
45
- echo "DEPLOY_PATH is not set."
46
- exit 1
47
- fi
22
+ - name : Checkout code
23
+ uses : actions/checkout@v4
48
24
49
- - name : Check DEPLOY_KEY
50
- env :
51
- DEPLOY_KEY : ${{ secrets.DEPLOY_KEY }}
52
- run : |
53
- if [ -z "$DEPLOY_KEY" ]; then
54
- echo "DEPLOY_KEY is not set"
55
- exit 1
56
- fi
25
+ - name : Check environment variables
26
+ uses : ./.github/actions/setup-check
27
+ with :
28
+ deploy_host : ${{ secrets.DEPLOY_HOST }}
29
+ deploy_user : ${{ secrets.DEPLOY_USER }}
30
+ deploy_path : ${{ secrets.DEPLOY_PATH }}
31
+ deploy_key : ${{ secrets.DEPLOY_KEY }}
57
32
58
33
deploy :
59
34
runs-on : ubuntu-latest
60
- needs : secrets -check
35
+ needs : setup -check
61
36
environment : ${{ inputs.environment || 'Production' }}
62
- if : ${{ github.event.workflow_run.conclusion == 'success' ||
63
- github.event_name == 'workflow_dispatch' }}
37
+ if : ${{ github.event.workflow_run.conclusion == 'success' || github.event_name == 'workflow_dispatch' }}
38
+
39
+ permissions :
40
+ id-token : write
41
+ contents : read
64
42
65
43
env :
66
44
DEPLOY_HOST : ${{ secrets.DEPLOY_HOST }}
67
45
DEPLOY_USER : ${{ secrets.DEPLOY_USER }}
68
46
DEPLOY_PATH : ${{ secrets.DEPLOY_PATH }}
47
+ AWS_ENABLED : ${{ secrets.AWS_ACCOUNT != '' && secrets.AWS_REGION != '' && secrets.AWS_SECURITY_GROUP != '' }}
69
48
70
49
steps :
71
50
- name : Checkout code
72
51
uses : actions/checkout@v4
73
52
53
+ - name : Configure AWS credentials
54
+ if : ${{ env.AWS_ENABLED == 'true' }}
55
+ uses : aws-actions/configure-aws-credentials@v4
56
+ with :
57
+ aws-region : ${{ secrets.AWS_REGION }}
58
+ role-to-assume : arn:aws:iam::${{ secrets.AWS_ACCOUNT }}:role/MOT-SSH
59
+
60
+ - name : Get runners public IP address
61
+ if : ${{ env.AWS_ENABLED == 'true' }}
62
+ id : ip
63
+
64
+
65
+ - name : Authorize IP address
66
+ if : ${{ env.AWS_ENABLED == 'true' }}
67
+ id : auth-ip
68
+ uses : ./.github/actions/authorize-ip
69
+ with :
70
+ ip : ${{ steps.ip.outputs.ipv4 }}
71
+ sgid : ${{ secrets.AWS_SECURITY_GROUP }}
72
+
74
73
- name : Start ssh-agent and add key
75
74
uses :
webfactory/[email protected]
76
75
with :
88
87
--exclude 'tests' \
89
88
--exclude 'config' \
90
89
--exclude 'models/' \
90
+ --exclude 'web/sites/*/files' \
91
+ --exclude 'web/libraries' \
91
92
./ $DEPLOY_USER@$DEPLOY_HOST:$DEPLOY_PATH
92
93
93
94
- name : Post-deploy tasks
@@ -99,3 +100,10 @@ jobs:
99
100
./vendor/bin/drush cr
100
101
./vendor/bin/drush updb -y
101
102
EOF
103
+
104
+ - name : Revoke IP address
105
+ if : ${{ steps.auth-ip.outcome == 'success' }}
106
+ uses : ./.github/actions/revoke-ip
107
+ with :
108
+ ip : ${{ steps.ip.outputs.ipv4 }}
109
+ sgid : ${{ secrets.AWS_SECURITY_GROUP }}
0 commit comments