-
Notifications
You must be signed in to change notification settings - Fork 1
62 lines (50 loc) · 1.54 KB
/
deploy-gcp.yml
File metadata and controls
62 lines (50 loc) · 1.54 KB
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
name: Build and Deploy
# on:
# push:
# branches:
# - main
on:
pull_request:
types: [opened, synchronize, reopened]
concurrency:
group: prod-deploy
cancel-in-progress: true
jobs:
deploy:
runs-on: ubuntu-latest
environment: production
steps:
- name: Checkout repository
uses: actions/checkout@v3
- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: '8.3'
coverage: none
- name: Install dependencies
uses: ramsey/composer-install@v2
- name: Install Node.js
uses: actions/setup-node@v4
with:
node-version-file: .nvmrc
cache: 'npm'
- name: Install npm dependencies
run: npm ci
- name: Build assets
run: npm run build
- name: Zip up the application
run: zip -r application.zip . -x "*.git*" -x "*.github*"
- name: Upload Application Artifact
uses: actions/upload-artifact@v4
with:
name: application
path: application.zip
- name: Place SSH Key
run: echo "${{ secrets.SERVER_SSH_KEY }}" > ./id_rsa && chmod 600 ./id_rsa
- name: Transfer Zip to Server
run: |
TIMESTAMP=$(date +'%Y%m%d%H%M%S')
SERVER="${{ secrets.SERVER_USER }}@${{ secrets.SERVER_HOST }}"
scp -i ./id_rsa application.zip $SERVER:/tmp/application.zip
ssh -i ./id_rsa $SERVER "unzip /tmp/application.zip -d /var/www/choremanager/releases/$TIMESTAMP"
ssh -i ./id_rsa $SERVER "ln -sf /var/www/choremanager/releases/$TIMESTAMP /var/www/choremanager/current"