Skip to content

Commit

Permalink
Update deploy.yml
Browse files Browse the repository at this point in the history
  • Loading branch information
XyL1GaN4eG committed Jul 18, 2024
1 parent d53e020 commit e80bd38
Showing 1 changed file with 31 additions and 48 deletions.
79 changes: 31 additions & 48 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,10 @@ jobs:
- name: Debug environment variables
run: printenv # Вывести все переменные окружения для отладки

# Steps for userService
- name: Build userService
run: mvn -e -B package --file userService/pom.xml # Собрать проект Maven, указав путь к pom.xml

- name: List built files for userService
- name: List built files
run: ls -la userService/target # Показать список файлов в целевой папке после сборки

- name: Deploy userService to Server
Expand All @@ -57,44 +56,7 @@ jobs:
proxy_timeout: 30s
proxy_use_insecure_cipher: false # Настройки для scp-action, чтобы копировать файл на удаленный сервер

- name: SSH into server and restart userService
uses: appleboy/ssh-action@master
with:
host: ${{ secrets.SERVER_HOST }}
username: ${{ secrets.SERVER_USERNAME }}
key: ${{ secrets.SSH_PRIVATE_KEY }}
script: |
echo "Checking for JAR file..."
if [ -f /home/xyl1gan4eg/myJavaProjects/weatherProject/userService/userService-0.0.1-SNAPSHOT.jar ]; then
echo "JAR file found. Proceeding with service restart."
if sudo systemctl is-active --quiet user-service; then
sudo systemctl stop user-service
fi
sudo cp /home/xyl1gan4eg/myJavaProjects/weatherProject/userService/userService-0.0.1-SNAPSHOT.jar /opt/userService/
sudo systemctl start user-service
else
echo "JAR file not found!"
exit 1
fi
- name: List files on server for userService debug
uses: appleboy/ssh-action@master
with:
host: ${{ secrets.SERVER_HOST }}
username: ${{ secrets.SERVER_USERNAME }}
key: ${{ secrets.SSH_PRIVATE_KEY }}
script: |
echo "Listing files in /home/xyl1gan4eg/myJavaProjects/weatherProject/userService/"
ls -la /home/xyl1gan4eg/myJavaProjects/weatherProject/userService/ # Показать список файлов в целевой папке для отладки
# Steps for weatherApiService
- name: Build weatherApiService
run: mvn -e -B package --file weatherApiService/pom.xml # Собрать проект Maven, указав путь к pom.xml

- name: List built files for weatherApiService
run: ls -la weatherApiService/target # Показать список файлов в целевой папке после сборки

- name: Deploy weatherApiService to Server
- name: Deploy WeatherApiService to Server
uses: appleboy/scp-action@master
with:
host: ${{ secrets.SERVER_HOST }}
Expand All @@ -116,6 +78,26 @@ jobs:
proxy_timeout: 30s
proxy_use_insecure_cipher: false # Настройки для scp-action, чтобы копировать файл на удаленный сервер

- name: SSH into server and restart userService
uses: appleboy/ssh-action@master
with:
host: ${{ secrets.SERVER_HOST }}
username: ${{ secrets.SERVER_USERNAME }}
key: ${{ secrets.SSH_PRIVATE_KEY }}
script: |
echo "Checking for JAR file..."
if [ -f /home/xyl1gan4eg/myJavaProjects/weatherProject/userService/target/userService-0.0.1-SNAPSHOT.jar ]; then
echo "JAR file found. Proceeding with service restart."
if sudo systemctl is-active --quiet user-service; then
sudo systemctl stop user-service
fi
sudo cp /home/xyl1gan4eg/myJavaProjects/weatherProject/userService/targer/userService-0.0.1-SNAPSHOT.jar /opt/userService/
sudo systemctl start user-service
else
echo "JAR file not found!"
exit 1
fi
- name: SSH into server and restart weatherApiService
uses: appleboy/ssh-action@master
with:
Expand All @@ -124,24 +106,25 @@ jobs:
key: ${{ secrets.SSH_PRIVATE_KEY }}
script: |
echo "Checking for JAR file..."
if [ -f /home/xyl1gan4eg/myJavaProjects/weatherProject/weatherApiService/weatherApiService-0.0.1-SNAPSHOT.jar ]; then
if [ -f /home/xyl1gan4eg/myJavaProjects/weatherProject/weatherApiService/target/weatherApiService-0.0.1-SNAPSHOT.jar ]; then
echo "JAR file found. Proceeding with service restart."
if sudo systemctl is-active --quiet weather-api-service; then
sudo systemctl stop weather-api-service
if sudo systemctl is-active --quiet user-service; then
sudo systemctl stop user-service
fi
sudo cp /home/xyl1gan4eg/myJavaProjects/weatherProject/weatherApiService/weatherApiService-0.0.1-SNAPSHOT.jar /opt/weatherApiService/
sudo systemctl start weather-api-service
sudo cp /home/xyl1gan4eg/myJavaProjects/weatherProject/weatherApiService/targer/weatherApiService-0.0.1-SNAPSHOT.jar /opt/weatherApiService/
sudo systemctl start weatherApi-service
else
echo "JAR file not found!"
exit 1
fi
- name: List files on server for weatherApiService debug
- name: List files on server for debug
uses: appleboy/ssh-action@master
with:
host: ${{ secrets.SERVER_HOST }}
username: ${{ secrets.SERVER_USERNAME }}
key: ${{ secrets.SSH_PRIVATE_KEY }}
script: |
echo "Listing files in /home/xyl1gan4eg/myJavaProjects/weatherProject/weatherApiService/"
ls -la /home/xyl1gan4eg/myJavaProjects/weatherProject/weatherApiService/ # Показать список файлов в целевой папке для отладки
echo "Listing files in /home/xyl1gan4eg/myJavaProjects/weatherProject/"
ls -la /home/xyl1gan4eg/myJavaProjects/weatherProject/ # Показать список файлов в целевой папке для отладки

0 comments on commit e80bd38

Please sign in to comment.