-
Notifications
You must be signed in to change notification settings - Fork 0
194 lines (153 loc) · 5.83 KB
/
deploy.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
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
name: Testing & Deployment
on: [ push ]
jobs:
test:
runs-on: ubuntu-22.04
env:
DB_DATABASE: testing
DB_USER: root
DB_PASSWORD: root
steps:
- uses: actions/checkout@v4
- name: Set up MySQL
run: |
sudo /etc/init.d/mysql start
mysql -e 'CREATE DATABASE ${{ env.DB_DATABASE }};' -u${{ env.DB_USER }} -p${{ env.DB_PASSWORD }}
- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: '8.2'
extensions: zip, sqlite3
coverage: none
- name: Install composer dependencies
run: composer install --no-cache --no-ansi --no-interaction --no-progress
- name: Install node dependencies
run: npm ci
- name: Setup node
uses: actions/setup-node@v4
with:
node-version: 20
- name: Copy standard .env
run: php -r "file_exists('.env') || copy('.env.example', '.env');"
- name: Generate key
run: php artisan key:generate
- name: Build frontend
run: |
npm run build
- name: Execute tests
env:
DB_USERNAME: root
DB_PASSWORD: root
run: ./vendor/bin/phpunit
build-deploy-seth-environment:
needs: test
if: github.ref == 'refs/heads/main'
runs-on: ubuntu-22.04
environment:
name: seth-production
url: https://www.sethsharpportfolio.com
steps:
- uses: actions/checkout@v4
- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: '8.2'
extensions: zip, sqlite3
coverage: none
- name: Install composer dependencies
run: composer install --no-cache --no-ansi --no-interaction --no-progress
- name: Copy production .env
run: php -r "file_exists('.env') || copy('.env.seth.production', '.env');"
- name: Generate key
run: php artisan key:generate
- name: Install node dependencies
run: npm ci
- name: Setup node
uses: actions/setup-node@v4
with:
node-version: 20
- name: Build frontend
run: |
npm run build
- name: Echo information to .env
if: github.ref == 'refs/heads/main'
run: |
echo "DB_HOST=${{ secrets.DB_HOST}}" >> .env
echo "DB_DATABASE=${{ secrets.DB_DATABASE}}" >> .env
echo "DB_USERNAME=${{ secrets.DB_USERNAME}}" >> .env
echo "DB_PASSWORD=${{ secrets.DB_PASSWORD}}" >> .env
echo "AWS_ACCESS_KEY_ID=${{ secrets.AWS_ACCESS_KEY_ID}}" >> .env
echo "AWS_SECRET_ACCESS_KEY=${{ secrets.AWS_SECRET_ACCESS_KEY}}" >> .env
echo "SLACK_BOT_USER_OAUTH_TOKEN=${{ secrets.SLACK_BOT_USER_OAUTH_TOKEN }}" >> .env
echo "SLACK_WEBHOOK=${{ secrets.SLACK_WEBHOOK }}" >> .env
- name: Build ZIP Deployment Package
if: github.ref == 'refs/heads/main'
run: zip -r deploy.zip ./ -x "node_modules/*" -x "vendor/*" -x "tests/*"
- name: Deploy to Seth Production EB Environment
if: github.ref == 'refs/heads/main'
uses: einaregilsson/beanstalk-deploy@v22
with:
aws_access_key: ${{ secrets.AWS_ACCESS_KEY }}
aws_secret_key: ${{ secrets.AWS_SECRET_KEY }}
application_name: portfolio-production
environment_name: Portfolio-production-env
existing_bucket_name: elasticbeanstalk-ap-southeast-2-290427685328
region: ap-southeast-2
version_label: ${{ github.sha }}
deployment_package: deploy.zip
build-deploy-beth-environment:
needs: test
if: github.ref == 'refs/heads/main'
runs-on: ubuntu-22.04
environment:
name: beth-production
url: https://www.bethanyfrankisportfolio.com
steps:
- uses: actions/checkout@v4
- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: '8.2'
extensions: zip, sqlite3
coverage: none
- name: Install composer dependencies
run: composer install --no-cache --no-ansi --no-interaction --no-progress
- name: Copy production .env
run: php -r "file_exists('.env') || copy('.env.beth.production', '.env');"
- name: Generate key
run: php artisan key:generate
- name: Install node dependencies
run: npm ci
- name: Setup node
uses: actions/setup-node@v4
with:
node-version: 20
- name: Build frontend
run: |
npm run build
- name: Echo information to .env
if: github.ref == 'refs/heads/main'
run: |
echo "DB_HOST=${{ secrets.DB_HOST}}" >> .env
echo "DB_DATABASE=${{ secrets.DB_DATABASE}}" >> .env
echo "DB_USERNAME=${{ secrets.DB_USERNAME}}" >> .env
echo "DB_PASSWORD=${{ secrets.DB_PASSWORD}}" >> .env
echo "AWS_ACCESS_KEY_ID=${{ secrets.AWS_ACCESS_KEY_ID}}" >> .env
echo "AWS_SECRET_ACCESS_KEY=${{ secrets.AWS_SECRET_ACCESS_KEY}}" >> .env
echo "SLACK_BOT_USER_OAUTH_TOKEN=${{ secrets.SLACK_BOT_USER_OAUTH_TOKEN }}" >> .env
echo "SLACK_WEBHOOK=${{ secrets.SLACK_WEBHOOK }}" >> .env
- name: Build ZIP Deployment Package
if: github.ref == 'refs/heads/main'
run: zip -r deploy.zip ./ -x "node_modules/*" -x "vendor/*" -x "tests/*"
- name: Deploy to Beth Production EB Environment
if: github.ref == 'refs/heads/main'
uses: einaregilsson/beanstalk-deploy@v22
with:
aws_access_key: ${{ secrets.AWS_ACCESS_KEY }}
aws_secret_key: ${{ secrets.AWS_SECRET_KEY }}
application_name: Portfolio
environment_name: portfolio-production
existing_bucket_name: elasticbeanstalk-ap-southeast-2-533267327531
region: ap-southeast-2
version_label: ${{ github.sha }}
deployment_package: deploy.zip