-
Notifications
You must be signed in to change notification settings - Fork 3
129 lines (114 loc) · 3.8 KB
/
production.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
name: Production
on:
push:
branches: [ master ]
repository_dispatch:
types: [ retry-* ]
workflow_dispatch:
inputs:
deploy_params:
description: 'Deploy params'
default: "-vvv"
type: string
concurrency:
group: ${{ github.ref }}
cancel-in-progress: true
jobs:
laravel-tests-and-deploy:
runs-on: ubuntu-20.04
environment: production
defaults:
run:
working-directory: ./src
steps:
- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: '8.3'
- uses: actions/checkout@v3
- uses: symfonycorp/security-checker-action@v3
with:
lock: src/composer.lock
- name: Copy .env
run: php -r "file_exists('.env') || copy('.env.example', '.env');"
- name: Install composer dependencies
run: composer install --optimize-autoloader --no-dev --quiet
- name: Generate key
run: php artisan key:generate
- name: Directory Permissions
run: chmod -R 777 storage bootstrap/cache
- name: Install NPM dependencies
run: npm install
- name: Minify CSS and JS files
env:
SENTRY_AUTH_TOKEN: ${{ secrets.SENTRY_FRONT_AUTH_TOKEN }}
run: npm run production
- name: Remove node_modules folder
run: rm -R node_modules
# !!! need mysql
# - name: Execute tests (Unit and Feature tests) via PHPUnit
# env:
# DB_CONNECTION: sqlite
# DB_DATABASE: database/database.sqlite
# run: |
# mkdir -p database
# touch database/database.sqlite
# php artisan migrate --force
# php artisan job:dispatch SxGeoUpdateJob
# php artisan test
- name: Deploy
env:
DEPLOY_HOST: ${{ secrets.DEPLOY_HOST }}
DEPLOY_USER: ${{ secrets.DEPLOY_USER }}
DEPLOY_PORT: ${{ secrets.DEPLOY_PORT }}
DEPLOY_PATH: ${{ secrets.DEPLOY_PATH }}
run: |
mkdir -p ~/.ssh
touch ~/.ssh/deploy
(echo ${{ secrets.DEPLOY_SSH_KEY }} | base64 --decode -i > ~/.ssh/deploy)
chmod 700 ~/.ssh/deploy
php ./vendor/bin/dep deploy ${{ inputs.deploy_params }}
- name: Create Sentry release
uses: getsentry/action-release@v1
env:
SENTRY_AUTH_TOKEN: ${{ secrets.SENTRY_AUTH_TOKEN }}
SENTRY_ORG: ${{ secrets.SENTRY_ORG }}
SENTRY_PROJECT: ${{ secrets.SENTRY_PROJECT }}
with:
environment: production
- name: Send success status
uses: appleboy/telegram-action@master
with:
to: ${{ secrets.TELEGRAM_TO }}
token: ${{ secrets.TELEGRAM_TOKEN }}
message: Success deploying ✅
##################################
### Run when a schedule failed ###
##################################
# restart_when_failed:
# name: Restarts workflow if failed
# runs-on: ubuntu-latest
# if: failure() && github.event.client_payload.attempt < 5
# needs: laravel-tests-and-deploy
# steps:
# - name: Sleep for 1m 36s
# uses: jakejarvis/wait-action@master
# with:
# time: '96s'
# - name: set attempt
# run: |
# ATTEMPT=${{ github.event.client_payload.attempt }}
# ATTEMPT=$([ -n "$ATTEMPT" ] && echo $((++ATTEMPT)) || echo 1)
# echo "attempt=$ATTEMPT" >> $GITHUB_ENV
# - name: Send retry status
# uses: appleboy/telegram-action@master
# with:
# to: ${{ secrets.TELEGRAM_TO }}
# token: ${{ secrets.TELEGRAM_TOKEN }}
# message: Failure deploy (${{ env.attempt }}) ❌ Rerun 🔄
# - name: Retry the workflow
# uses: peter-evans/repository-dispatch@v1
# with:
# token: ${{ secrets.API_WORKFLOW_KEY }}
# event-type: retry-${{ env.attempt }}
# client-payload: '{"ref": "${{ github.ref }}", "attempt": "${{ env.attempt }}"}'