-
Notifications
You must be signed in to change notification settings - Fork 0
68 lines (68 loc) · 2.42 KB
/
ssh_deploy.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
# Based on this tutorial: https://github.com/marketplace/actions/ssh-deploy
name: SSH Deploy
on:
workflow_dispatch:
jobs:
build:
runs-on: ubuntu-22.04
steps:
- name: Checkout
uses: actions/checkout@v1
# Install PHP
- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: '8.2'
coverage: none
tools: composer:v2
extensions: mbstring, xml, ctype, iconv, intl, pdo_sqlite, dom, filter, gd, iconv, json, mbstring, pdo
env:
update: true
- name: Check PHP Version
run: php -v
# Install backend dependencies (Composer)
- name: Validate composer.json and composer.lock
run: composer validate
working-directory: ./app
- name: Get composer cache directory
id: composer-cache
run: echo "::set-output name=dir::$(composer config cache-files-dir)"
- name: Cache composer dependencies
uses: actions/cache@v1
with:
path: ${{ steps.composer-cache.outputs.dir }}
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }}
restore-keys: ${{ runner.os }}-composer-
- name: Install Composer dependencies
run: composer install
working-directory: ./app
# Prepare .env file for production
- name: Make production envfile
uses: SpicyPizza/create-envfile@v1
with:
envkey_APP_ENV: prod
envkey_APP_DEBUG: false
envkey_APP_SECRET: ${{ secrets.APP_SECRET }}
file_name: .env
# Copying files and artifacts via SSH
- name: Copying files to server
uses: appleboy/scp-action@master
with:
host: ${{ secrets.REMOTE_HOST }}
username: ${{ secrets.REMOTE_USER }}
key: ${{ secrets.SERVER_SSH_KEY }}
passphrase: ''
rm: true
source: "./"
target: ${{ secrets.REMOTE_TARGET }}
# Run commands on production
- name: Executing remote ssh commands
uses: appleboy/ssh-action@master
with:
host: ${{ secrets.REMOTE_HOST }}
username: ${{ secrets.REMOTE_USER }}
key: ${{ secrets.SERVER_SSH_KEY }}
passphrase: ''
script: |
rsync -a --exclude={'var','temp'} --delete ${{ secrets.REMOTE_TARGET }} ${{ secrets.REMOTE_TARGET_DEPLOY }}
cd ${{ secrets.REMOTE_TARGET }} && php8.2 bin/console cache:clear