-
Notifications
You must be signed in to change notification settings - Fork 0
134 lines (111 loc) · 4.06 KB
/
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
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
name: Deploy to OVH Server
on:
push:
branches: [main]
workflow_dispatch:
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Clean install dependencies
run: |
rm -rf node_modules package-lock.json
npm install
- name: Build Astro project
run: npm run build
- name: Upload build artifacts
uses: actions/upload-artifact@v4
with:
name: astro-build
path: dist/
deploy-on-test:
needs: build
runs-on: ubuntu-latest
steps:
- name: Download build artifacts
uses: actions/download-artifact@v4
with:
name: astro-build
path: dist/
- name: Deploy to prod OVH Server
env:
SSH_PRIVATE_KEY: ${{ secrets.SSH_PRIVATE_KEY }}
SERVER_USER: ${{ secrets.SERVER_USER }}
SERVER_IP: ${{ secrets.SERVER_IP }}
SERVER_PATH: "/var/www/test.pcoundia.com/"
run: |
# Vérification des variables
if [[ -z "$SSH_PRIVATE_KEY" || -z "$SERVER_USER" || -z "$SERVER_IP" ]]; then
echo "Error: Missing environment variables!"
exit 1
fi
# Configure SSH for access
mkdir -p ~/.ssh
echo "$SSH_PRIVATE_KEY" | tr -d '\r' | tee ~/.ssh/id_rsa > /dev/null
chmod 600 ~/.ssh/id_rsa
ssh-keyscan -H "$SERVER_IP" >> ~/.ssh/known_hosts
# Test SSH connection
ssh -o StrictHostKeyChecking=no "$SERVER_USER@$SERVER_IP" "echo 'SSH connection successful'"
# Clear target directory on the server (optional but recommended)
ssh "$SERVER_USER@$SERVER_IP" "rm -rf $SERVER_PATH/*"
# Deploy to the production server
rsync -avzL --chown=$SERVER_USER:www-data --chmod=775 --delete dist/ "$SERVER_USER@$SERVER_IP:$SERVER_PATH" -v
selenium-test:
runs-on: ubuntu-latest
needs: deploy-on-test
services:
selenium-hub:
image: selenium/hub:latest
ports:
- 4444:4444
chrome-node:
image: selenium/node-chrome:latest
env:
SE_EVENT_BUS_HOST: selenium-hub
SE_EVENT_BUS_PUBLISH_PORT: 4442
SE_EVENT_BUS_SUBSCRIBE_PORT: 4443
steps:
- name: Checkout Selenium Tests Repository
run: |
git clone https://github.com/coundia/selenium-java-pcoundia.git selenium-tests
- name: Run Selenium Tests
env:
SELENIUM_HUB_URL: "http://localhost:4444/wd/hub"
SERVER_URL: "https://test.pcoundia.com" # Point to your test server URL
run: |
cd selenium-tests
mvn clean test -Dapp.url=$SERVER_URL
deploy-on-prod:
needs: selenium-test
runs-on: ubuntu-latest
steps:
- name: Download build artifacts
uses: actions/download-artifact@v4
with:
name: astro-build
path: dist/
- name: Deploy to prod OVH Server
env:
SSH_PRIVATE_KEY: ${{ secrets.SSH_PRIVATE_KEY }}
SERVER_USER: ${{ secrets.SERVER_USER }}
SERVER_IP: ${{ secrets.SERVER_IP }}
SERVER_PATH: "/var/www/pcoundia.com/"
run: |
# Vérification des variables
if [[ -z "$SSH_PRIVATE_KEY" || -z "$SERVER_USER" || -z "$SERVER_IP" ]]; then
echo "Error: Missing environment variables!"
exit 1
fi
# Configure SSH for access
mkdir -p ~/.ssh
echo "$SSH_PRIVATE_KEY" | tr -d '\r' | tee ~/.ssh/id_rsa > /dev/null
chmod 600 ~/.ssh/id_rsa
ssh-keyscan -H "$SERVER_IP" >> ~/.ssh/known_hosts
# Test SSH connection
ssh -o StrictHostKeyChecking=no "$SERVER_USER@$SERVER_IP" "echo 'SSH connection successful'"
# Clear target directory on the server (optional but recommended)
ssh "$SERVER_USER@$SERVER_IP" "rm -rf $SERVER_PATH/*"
# Deploy to the production server
rsync -avzL --chown=$SERVER_USER:www-data --chmod=775 --delete dist/ "$SERVER_USER@$SERVER_IP:$SERVER_PATH" -v