-
Notifications
You must be signed in to change notification settings - Fork 1
85 lines (75 loc) · 2.75 KB
/
Copy pathci-cd.yml
File metadata and controls
85 lines (75 loc) · 2.75 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
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
name: CI/CD
on:
push:
branches:
- main
jobs:
build:
runs-on: "ubuntu-22.04"
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Install PHP
run: bash .github/scripts/install-php84.sh
- name: Use Composer dependencies cache
uses: actions/cache@v4
with:
path: ~/.cache/composer
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }}
restore-keys: ${{ runner.os }}-composer-
- name: Use npm dependencies cache
uses: actions/cache@v4
with:
path: ~/.npm
key: ${{ runner.os }}-npm-${{ hashFiles('**/package-lock.json') }}
restore-keys: ${{ runner.os }}-npm-
- name: Install dependencies
run: |
composer install --no-interaction --no-progress --optimize-autoloader --no-dev
npm ci
npm run build
- name: Prepare Client
run: |
mv client watchtower
rm watchtower/.gitignore
mv watchtower/scripts/install.sh public/install.sh
tar --create --gzip --file=public/watchtower-client.tar.gz watchtower/
- name: Compress deployment artifacts
run: |
tar --create --gzip \
--exclude="bootstrap/cache/*" \
--exclude="node_modules" \
--exclude="public/storage" \
--exclude="storage" \
--exclude="tests" \
--file ~/artifacts.tar.gz * .github
- name: Upload deployment artifacts
uses: actions/upload-artifact@v4
with:
name: deployment-artifacts
path: ~/artifacts.tar.gz
retention-days: 1
deploy-main:
needs: build
if: github.event_name == 'push' && github.ref == 'refs/heads/main'
runs-on: "ubuntu-22.04"
steps:
- name: Download deployment artifacts
uses: actions/download-artifact@v4
with:
name: deployment-artifacts
- name: Deploy
env:
base_directory: "~/www/watchtower"
ssh_user: "sjorso"
ssh_host: "167.235.26.246"
ssh_port: 22
private_ssh_key: "${{ secrets.PRIVATE_SSH_KEY }}"
ssh_known_hosts: "${{ secrets.SSH_KNOWN_HOSTS }}"
php_executable: "php8.4"
run: tar -xf artifacts.tar.gz .github/deployment/prepare.sh -O | bash -se -- "$base_directory" "$ssh_user" "$ssh_host" "$ssh_port" "$private_ssh_key" "$ssh_known_hosts" "$php_executable"
- name: Deploy to Platform
env:
private_ssh_key: "${{ secrets.PLATFORM_PRIVATE_SSH_KEY }}"
ssh_known_hosts: "${{ secrets.PLATFORM_SSH_KNOWN_HOSTS }}"
run: tar -xf artifacts.tar.gz .github/bundle-to-platform/prepare.sh -O | bash -se -- "$private_ssh_key" "$ssh_known_hosts"