-
Notifications
You must be signed in to change notification settings - Fork 7
executable file
·116 lines (115 loc) · 3.82 KB
/
main.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
on:
release:
types: [released]
workflow_dispatch:
name: Deploy master branch
jobs:
deploy_master:
name: Deploy Master
runs-on: ubuntu-latest
services:
mysql:
image: mariadb:10.3
env:
MYSQL_DATABASE: test_database
MYSQL_HOST: 127.0.0.1
MYSQL_USER: admin
MYSQL_PASSWORD: rootpass
MYSQL_ROOT_PASSWORD: rootpass
ports:
- 3306:3306
options: --health-cmd="mysqladmin ping" --health-interval=10s --health-timeout=5s --health-retries=3
steps:
- uses: actions/checkout@v2
with:
token: ${{ secrets.GH_CHECKOUT_TOKEN }}
submodules: 'recursive'
- uses: actions/cache@v3
id: cache-npm
with:
path: |
./node_modules/
key: ${{ runner.os }}-${{ hashFiles('**/package-lock.json') }}
- uses: actions/cache@v3
id: cache-assets
with:
path: |
./public
key: ${{ runner.os }}-${{ hashFiles('**/resources') }}
- uses: actions/cache@v3
id: cache-composer
with:
path: |
./vendor/
key: ${{ runner.os }}-${{ hashFiles('**/composer.lock') }}
- uses: actions/cache@v3
id: cache-env
with:
path: |
./.env
key: ${{ runner.os }}-${{ hashFiles('**/.env.github') }}
- uses: actions/setup-node@v2
with:
node-version: '20'
- uses: "shivammathur/setup-php@v2"
with:
php-version: "8.1"
- uses: "ramsey/composer-install@v2"
- name: Create env file
run: |
php -r "file_exists('.env') || copy('.env.github', '.env');"
- name: Create env file
run: |
cat > .env << EOF
APP_ENV=production
EOF
- name: Generate app_key
run: php artisan key:generate
# - name: Run unit tests
# run: php artisan test
- name: Actions Status Discord
if: ${{ failure() }}
uses: sarisia/[email protected]
with:
webhook: ${{ secrets.DISCORD_FC_BETA_WEBHOOK }}
description: 'Unit tests failed'
username: "Github"
avatar_url: "https://beta.fantasy-calendar.com//resources/header_logo.png"
title: "Deploy failure"
color: 0xdc2626
nodetail: true
- uses: "ramsey/composer-install@v2"
with:
composer-options: "--prefer-dist --optimize-autoloader --no-dev --ignore-platform-reqs"
- name: Configure AWS Credentials
uses: aws-actions/configure-aws-credentials@v1
with:
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
aws-region: us-east-1
- name: Install NPM dependencies
run: npm install --legacy-peer-deps
- name: Build production assets
run: npm run production
- name: Copy assets into S3
run: |
aws s3 sync ./public s3://fantasy-calendar-prod/
- name: Deploy to prod
run: npx serverless@3 deploy --stage prod
- name: Actions Status Discord
uses: sarisia/[email protected]
with:
webhook: ${{ secrets.DISCORD_FC_BETA_WEBHOOK }}
description: "A new version of Fantasy Calendar has been deployed"
username: "Github"
avatar_url: "https://beta.fantasy-calendar.com//resources/header_logo.png"
title: "Deploy success"
nodetail: true
- name: Discord release notification
if: "!github.event.release.prerelease"
env:
DISCORD_WEBHOOK: ${{ secrets.RELEASE_WEBHOOK }}
DISCORD_USERNAME: ${{github.event.release.name}}
uses: Ilshidur/action-discord@master
with:
args: "${{github.event.release.body}}"