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 c22d615 commit 9f1110b
Showing 1 changed file with 24 additions and 33 deletions.
57 changes: 24 additions & 33 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,55 +28,47 @@ jobs:
- name: Debug environment variables
run: printenv # Вывести все переменные окружения для отладки

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

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

- name: Deploy userService to Server
- name: Copy repository to server
uses: appleboy/scp-action@master
with:
host: ${{ secrets.SERVER_HOST }}
username: ${{ secrets.SERVER_USERNAME }}
key: ${{ secrets.SSH_PRIVATE_KEY }}
source: 'userService/target/userService-0.0.1-SNAPSHOT.jar' # Указать путь к скомпилированному JAR файлу
target: '/home/xyl1gan4eg/myJavaProjects/weatherProject/userService' # Указать целевой путь на сервере
source: '.' # Копируем весь репозиторий
target: '/home/xyl1gan4eg/myJavaProjects/weatherProject' # Указать целевой путь на сервере
port: 22
timeout: 30s
command_timeout: 10m
use_insecure_cipher: false
rm: false
debug: false
strip_components: 0
strip_components: 1
overwrite: true
tar_dereference: false
tar_exec: tar
proxy_port: 22
proxy_timeout: 30s
proxy_use_insecure_cipher: false # Настройки для scp-action, чтобы копировать файл на удаленный сервер

- name: Deploy WeatherApiService to Server
uses: appleboy/scp-action@master
- name: SSH into server and compile userService
uses: appleboy/ssh-action@master
with:
host: ${{ secrets.SERVER_HOST }}
username: ${{ secrets.SERVER_USERNAME }}
key: ${{ secrets.SSH_PRIVATE_KEY }}
source: 'weatherApiService/target/weatherApiService-0.0.1-SNAPSHOT.jar' # Указать путь к скомпилированному JAR файлу
target: '/home/xyl1gan4eg/myJavaProjects/weatherProject/weatherApiService' # Указать целевой путь на сервере
port: 22
timeout: 30s
command_timeout: 10m
use_insecure_cipher: false
rm: false
debug: false
strip_components: 0
overwrite: true
tar_dereference: false
tar_exec: tar
proxy_port: 22
proxy_timeout: 30s
proxy_use_insecure_cipher: false # Настройки для scp-action, чтобы копировать файл на удаленный сервер
script: |
cd /home/xyl1gan4eg/myJavaProjects/weatherProject/userService
mvn clean package
- name: SSH into server and compile weatherApiService
uses: appleboy/ssh-action@master
with:
host: ${{ secrets.SERVER_HOST }}
username: ${{ secrets.SERVER_USERNAME }}
key: ${{ secrets.SSH_PRIVATE_KEY }}
script: |
cd /home/xyl1gan4eg/myJavaProjects/weatherProject/weatherApiService
mvn clean package
- name: SSH into server and restart userService
uses: appleboy/ssh-action@master
Expand All @@ -91,7 +83,7 @@ jobs:
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 cp /home/xyl1gan4eg/myJavaProjects/weatherProject/userService/target/userService-0.0.1-SNAPSHOT.jar /opt/userService/
sudo systemctl start user-service
else
echo "JAR file not found!"
Expand All @@ -108,17 +100,16 @@ jobs:
echo "Checking for JAR file..."
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 user-service; then
sudo systemctl stop user-service
if sudo systemctl is-active --quiet weather-api-service; then
sudo systemctl stop weather-api-service
fi
sudo cp /home/xyl1gan4eg/myJavaProjects/weatherProject/weatherApiService/targer/weatherApiService-0.0.1-SNAPSHOT.jar /opt/weatherApiService/
sudo systemctl start weatherApi-service
sudo cp /home/xyl1gan4eg/myJavaProjects/weatherProject/weatherApiService/target/weatherApiService-0.0.1-SNAPSHOT.jar /opt/weatherApiService/
sudo systemctl start weather-api-service
else
echo "JAR file not found!"
exit 1
fi
- name: List files on server for debug
uses: appleboy/ssh-action@master
with:
Expand Down

0 comments on commit 9f1110b

Please sign in to comment.