-
Notifications
You must be signed in to change notification settings - Fork 0
79 lines (69 loc) · 2.06 KB
/
Copy pathdeploy.yml
File metadata and controls
79 lines (69 loc) · 2.06 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
name: Deploy wbhfm
on:
push:
tags:
- 'v[0-9]+\.[0-9]+\.[0-9]+'
permissions:
contents: read
jobs:
prepare-deployment:
name: Prepare Deployment
runs-on: ubuntu-latest
steps:
- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: '8.4'
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Cache Composer packages
id: composer-cache
uses: actions/cache@v4
with:
path: vendor
key: ${{ runner.os }}-php-${{ hashFiles('**/composer.lock') }}
restore-keys: |
${{ runner.os }}-php-
- name: Install dependencies
run: composer install -q --no-ansi --no-interaction --no-scripts --no-progress --prefer-dist
env:
APP_ENV: dev
- name: Lint Container
run: bin/console lint:container
env:
APP_ENV: dev
deploy:
name: Deploy
needs: prepare-deployment
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Extract tag name
id: extract_tag
run: echo "::set-output name=tag::${GITHUB_REF##*/}"
shell: bash
- name: SSH Actions
uses: appleboy/ssh-action@v0.1.7
with:
host: ${{ secrets.REMOTE_HOST }}
port: 22
username: ${{ secrets.USERNAME }}
key: ${{ secrets.KEY }}
script: |
export VERSION=${{ steps.extract_tag.outputs.tag }}
cd /var/www/whfm
sudo -u www-data git checkout main
sudo -u www-data git pull origin main
sudo -u www-data git fetch --tags
if ! sudo -u www-data git diff-index --quiet HEAD --; then
echo "You have uncommitted changes. Please commit or stash them before switching branches."
exit 1
fi
sudo -u www-data git checkout -f $VERSION
chmod +x ./.deploy/deploy.sh
./.deploy/deploy.sh