26
26
name : astro-build
27
27
path : dist/
28
28
29
- deploy :
29
+ deploy-on-test :
30
30
needs : build
31
31
runs-on : ubuntu-latest
32
32
steps :
36
36
name : astro-build
37
37
path : dist/
38
38
39
- - name : Deploy to OVH Server
39
+ - name : Deploy to test OVH Server
40
+ env :
41
+ SSH_PRIVATE_KEY : ${{ secrets.SSH_PRIVATE_KEY }}
42
+ SERVER_USER : ${{ secrets.SERVER_USER }}
43
+ SERVER_IP : ${{ secrets.SERVER_IP }}
44
+ SERVER_PATH : " /var/www/test.pcoundia.com/"
45
+ run : |
46
+ # Vérification des variables
47
+ if [[ -z "$SSH_PRIVATE_KEY" || -z "$SERVER_USER" || -z "$SERVER_IP" ]]; then
48
+ echo "Error: Missing environment variables!"
49
+ exit 1
50
+ fi
51
+
52
+ # Configure SSH for access
53
+ mkdir -p ~/.ssh
54
+ echo "$SSH_PRIVATE_KEY" | tr -d '\r' | tee ~/.ssh/id_rsa > /dev/null
55
+ chmod 600 ~/.ssh/id_rsa
56
+ ssh-keyscan -H "$SERVER_IP" >> ~/.ssh/known_hosts
57
+
58
+ # Test SSH connection
59
+ ssh -o StrictHostKeyChecking=no "$SERVER_USER@$SERVER_IP" "echo 'SSH connection successful'"
60
+
61
+ # Deploy to the test server
62
+ rsync -avz --chown=$SERVER_USER:www-data --chmod=775 --delete dist/ "$SERVER_USER@$SERVER_IP:$SERVER_PATH"
63
+
64
+ test :
65
+ runs-on : ubuntu-latest
66
+ needs : deploy-on-test
67
+ steps :
68
+ - name : Checkout Selenium Tests Repository
69
+ run : |
70
+ git clone https://github.com/coundia/selenium-java-pcoundia.git selenium-tests
71
+
72
+ - name : Run Selenium Tests
73
+ env :
74
+ SERVER_URL : " https://test.pcoundia.com" # Point to your test server URL
75
+ run : |
76
+ cd selenium-tests
77
+ mvn clean test -Dapp.url=$SERVER_URL
78
+
79
+ deploy-on-prod :
80
+ needs : test
81
+ runs-on : ubuntu-latest
82
+ steps :
83
+ - name : Download build artifacts
84
+ uses : actions/download-artifact@v4
85
+ with :
86
+ name : astro-build
87
+ path : dist/
88
+
89
+ - name : Deploy to prod OVH Server
40
90
env :
41
91
SSH_PRIVATE_KEY : ${{ secrets.SSH_PRIVATE_KEY }}
42
92
SERVER_USER : ${{ secrets.SERVER_USER }}
@@ -49,14 +99,14 @@ jobs:
49
99
exit 1
50
100
fi
51
101
52
- # Configuration of SSH
102
+ # Configure SSH for access
53
103
mkdir -p ~/.ssh
54
104
echo "$SSH_PRIVATE_KEY" | tr -d '\r' | tee ~/.ssh/id_rsa > /dev/null
55
105
chmod 600 ~/.ssh/id_rsa
56
106
ssh-keyscan -H "$SERVER_IP" >> ~/.ssh/known_hosts
57
107
58
- # Test SSH
108
+ # Test SSH connection
59
109
ssh -o StrictHostKeyChecking=no "$SERVER_USER@$SERVER_IP" "echo 'SSH connection successful'"
60
-
110
+
111
+ # Deploy to the production server
61
112
rsync -avz --chown=$SERVER_USER:www-data --chmod=775 --delete dist/ "$SERVER_USER@$SERVER_IP:$SERVER_PATH"
62
-
0 commit comments