forked from UnlockedLabs/UnlockEdv2
-
Notifications
You must be signed in to change notification settings - Fork 0
91 lines (81 loc) · 2.71 KB
/
ci.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
name: Build and Test Laravel Project
on:
push:
branches: ["main", "demo"]
pull_request:
branches: ["main"]
jobs:
phpunit:
runs-on: ubuntu-latest
container:
image: kirschbaumdevelopment/laravel-test-runner:8.2
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
token: ${{ secrets.GITHUB_TOKEN }}
fetch-depth: 1
- name: create test sqlite database
run: |
touch database/database.sqlite
- name: create permissions
run: |
chown -R $(id -u):$(id -g) .
- name: Install front-end dependencies
run: |
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.34.0/install.sh | bash
export NVM_DIR="$HOME/.nvm"
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh"
nvm install v21.6.2
nvm use v21.6.2
npm install
npm run build
env:
USER: root
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
CI: true
- name: Install composer dependencies
run: |
composer update
composer install
- name: Prepare Laravel Application
run: |
cp .env.testing .env
php artisan migrate:fresh --env=testing
- name: Generate Key
run: php artisan key:generate --env=testing
- name: Run Testsuite
env:
CANVAS_API_KEY: ${{ secrets.CANVAS_API_KEY }}
CI: true
run: php artisan test
deploy_to_demo:
name: Deploy to Demo Instance
runs-on: ubuntu-latest
needs: [phpunit]
if: github.ref == 'refs/heads/demo' && github.event_name == 'push' && github.repository == 'UnlockedLabs/UnlockEdv2'
steps:
- uses: actions/checkout@v4
- name: Build & Deploy
env:
PRIVATE_KEY: ${{ secrets.DEPLOY_KEY }}
HOSTNAME: ${{ secrets.SSH_HOST_DEMO }}
USER_NAME: ${{ secrets.USER_NAME }}
run: |
echo "$PRIVATE_KEY" > private_key && chmod 600 private_key
ssh -o StrictHostKeyChecking=no -i private_key ${USER_NAME}@${HOSTNAME} '~/deploy.sh'
deploy:
name: Deploy to Staging instance
runs-on: ubuntu-latest
needs: [phpunit]
if: github.ref == 'refs/heads/main' && github.event_name == 'push' && github.repository == 'UnlockedLabs/UnlockEdv2'
steps:
- uses: actions/checkout@v4
- name: Build & Deploy
env:
PRIVATE_KEY: ${{ secrets.DEPLOY_KEY }}
HOSTNAME: ${{ secrets.SSH_HOST }}
USER_NAME: ${{ secrets.USER_NAME }}
run: |
echo "$PRIVATE_KEY" > private_key && chmod 600 private_key
ssh -o StrictHostKeyChecking=no -i private_key ${USER_NAME}@${HOSTNAME} '~/deploy.sh'