generated from nystudio107/spin-up-craft
-
Notifications
You must be signed in to change notification settings - Fork 0
60 lines (50 loc) · 1.87 KB
/
deploy-craftcms.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
name: Craft CMS deployments
on:
push:
branches: [master]
jobs:
build-and-deploy:
runs-on: ubuntu-latest
steps:
# Pull repository into the current pipeline
- name: Pull repository
uses: actions/checkout@v2
# Setup container with private SSH Key (used by rsync)
- name: Load private SSH key
uses: webfactory/ssh-agent@v0.4.1
with:
ssh-private-key: ${{ secrets.SSH_KEY }}
# Use a specific version of Node
- name: Setup Node
uses: actions/setup-node@v1
with:
node-version: "12.x"
# Install PHP dependencies
- name: Composer install
run: composer install --no-interaction --no-progress --optimize-autoloader
# Install NPM dependencies
- name: NPM install
run: npm ci
# Build assets using NPM scripts
- name: Build assets
run: npm run build
# RSYNC
# - rsync [options] ~/localdir ssh_user@ssh_host:destination_directory
# - exclude web/uploads is there to avoid deleting user uploaded files w/ --delete-after
# - StrictHostKeyChecking=no will automatically add new host keys to the user known hosts files.
- name: Deploy with rsync
run: |
rsync -azh --delete-after --exclude={"/web/uploads/","/node_modules/","/.git/","/.github/"} -e "ssh -o StrictHostKeyChecking=no" ./ ${{ secrets.SSH_USER }}@${{ secrets.SSH_HOST }}:~/
# execute Craft commands on remote server
- name: Execute SSH commmands on remote server
uses: appleboy/ssh-action@master
with:
host: ${{ secrets.SSH_HOST }}
username: ${{ secrets.SSH_USER }}
key: ${{ secrets.SSH_KEY }}
script: |
chmod a+x craft
php craft backup/db
php craft migrate/all
php craft project-config/apply
php craft clear-caches/all