-
Notifications
You must be signed in to change notification settings - Fork 2
115 lines (108 loc) · 4.15 KB
/
api.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
name: API
on:
push:
branches: [main, develop/production, develop/stg]
pull_request:
paths:
- "api/**"
- "!**.md"
- "!.editorconfig"
- "!.gitignore"
- "!.gitattributes"
- "!_ide_helper.php"
- "!_ide_helper_models.php"
jobs:
laravel-tests:
runs-on: ubuntu-latest
steps:
- name: "checkoutする"
uses: actions/checkout@v4
- name: init
run: |
docker compose build
docker compose up -d
- name: composer install
run: docker compose exec -T app composer install
- name: init link and cache
run: docker compose exec -T app php -r "copy('.env.example', '.env');"
- name: Generate key
run: docker compose exec -T app php artisan key:generate
- name: Directory Permissions
run: |
docker compose exec -T app php artisan storage:link
docker compose exec -T app chmod -R 777 storage
docker compose exec -T app chmod -R 777 bootstrap/cache
docker compose exec -T app php artisan config:cache
- name: Check Format
run: docker compose exec -T app php artisan check:all
- name: check
run: |
sh -c 'docker compose logs -f db | { sed "/\[Entrypoint\]: MySQL init process done\. Ready for start up\./ q" && kill $$ ;}' >/dev/null 2>&1 || :
sh -c 'docker compose logs -f dbtest | { sed "/\[Entrypoint\]: MySQL init process done\. Ready for start up\./ q" && kill $$ ;}' >/dev/null 2>&1 || :
- name: migrate
run: |
docker compose up -d
docker compose exec -T app php artisan migrate:fresh
- name: re migrate
run: docker compose exec -T app php artisan migrate:refresh --seed
- name: Execute tests
run: docker compose exec -T app composer test
- name: artisan コマンドが正しく実行されるか
run: |
docker compose exec -T app php artisan cache:clear
docker compose exec -T app php artisan config:clear
docker compose exec -T app php artisan view:clear
docker compose exec -T app php artisan route:cache
docker compose exec -T app php artisan view:cache
- name: Check Laravel logs
if: ${{ always() }}
run: |
docker compose exec -T app ls storage/logs
docker compose exec -T app /bin/bash -c "cd storage/logs && find . -type f | xargs cat"
deploy-stg:
if: github.ref == 'refs/heads/develop/stg'
needs: [laravel-tests]
runs-on: ubuntu-latest
steps:
- name: Deploy
uses: appleboy/ssh-action@v0.1.6
with:
host: ${{ secrets.XSERVER_HOST_NAME }}
username: ${{ secrets.XSERVER_USER_NAME }}
key: ${{ secrets.XSERVER_SSH_KEY }}
port: 10022
script: |
whoami
pwd
ls -la
deploy:
if: github.ref == 'refs/heads/develop/production'
needs: [laravel-tests]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Deploy
env:
PRIVATE_KEY: ${{ secrets.XSERVER_SSH_KEY }}
USER_NAME: ${{ secrets.XSERVER_USER_NAME }}
HOST_NAME: ${{ secrets.XSERVER_HOST_NAME }}
run: |
echo "$PRIVATE_KEY" > private_key && chmod 600 private_key
ssh -vvv -p 10022 -o StrictHostKeyChecking=no -i private_key ${USER_NAME}@${HOST_NAME} '
cd ~/uu-circles.com/work/api && \
mkdir ${{ github.run_number }} && \
cd ${{ github.run_number }} && \
git clone https://github.com/UU-PlatHome/uu-circles.git && \
cd uu-circles/api && \
git reset --hard origin/develop/production && \
cp ../../../.env .env && \
cp ../../../credentials.json credentials.json && \
composer install && \
php artisan migrate --force && \
php artisan cache:clear && \
php artisan config:cache && \
php artisan route:cache && \
php artisan view:cache
cd ~/uu-circles.com && \
ln -nfs ~/uu-circles.com/work/api/${{ github.run_number }} ~/uu-circles.com/work/api/current
'