github action + gitlab ci/cd
name: Prod
# Controls when the workflow will run
on:
push:
branches: [ main ]
# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Set up JDK 17
uses: actions/setup-java@v2
with:
java-version: '17'
distribution: 'adopt'
- name: Build with Maven
run: mvn clean install
- name: Install SSH key
uses: shimataro/ssh-key-action@v2
with:
key: ${{ secrets.SSH_PRIVATE_KEY }}
known_hosts: unnecessary
if_key_exists: replace
- name: Disable HostKeyChecking
run: echo -e "Host *\n\tStrictHostKeyChecking no\n\n" > ~/.ssh/config
- name: mkdir folder nginx cert
run: ssh -T ${{ secrets.SERVER_USER }}@${{ secrets.SERVER_IP_3 }} "mkdir -p /etc/nginx/cert/"
- name: Copy cert uptool
run: scp deploy/uptool/uptool_org.key ${{ secrets.SERVER_USER }}@${{ secrets.SERVER_IP_3 }}:/etc/nginx/cert/
- name: Copy cert uptool
run: scp deploy/uptool/uptool_org.crt ${{ secrets.SERVER_USER }}@${{ secrets.SERVER_IP_3 }}:/etc/nginx/cert/
- name: Copy nginx service uptool
run: scp deploy/uptool.conf ${{ secrets.SERVER_USER }}@${{ secrets.SERVER_IP_3 }}:/etc/nginx/conf.d/
- name: Copy cert json2csv
run: scp deploy/json2csv/conf/www_json2csv_me.key ${{ secrets.SERVER_USER }}@${{ secrets.SERVER_IP_3 }}:/etc/nginx/cert/
- name: Copy cert json2csv
run: scp deploy/json2csv/conf/www_json2csv_me.crt ${{ secrets.SERVER_USER }}@${{ secrets.SERVER_IP_3 }}:/etc/nginx/cert/
- name: Copy nginx service json2csv
run: scp deploy/json2csv/conf/json2csv.conf ${{ secrets.SERVER_USER }}@${{ secrets.SERVER_IP_3 }}:/etc/nginx/conf.d/
- name: Copy cert jsons
run: scp deploy/jsons/www_jsons_live.key ${{ secrets.SERVER_USER }}@${{ secrets.SERVER_IP_3 }}:/etc/nginx/cert/
- name: Copy cert jsons
run: scp deploy/jsons/www_jsons_live.crt ${{ secrets.SERVER_USER }}@${{ secrets.SERVER_IP_3 }}:/etc/nginx/cert/
- name: Copy nginx service jsons
run: scp deploy/jsons/jsons.conf ${{ secrets.SERVER_USER }}@${{ secrets.SERVER_IP_3 }}:/etc/nginx/conf.d/
- name: Restart nginx service
run: ssh -T ${{ secrets.SERVER_USER }}@${{ secrets.SERVER_IP_3 }} "sudo systemctl restart nginx.service && sudo systemctl enable nginx.service"
- name: Copy jar file and service 3
run: ssh -T ${{ secrets.SERVER_USER }}@${{ secrets.SERVER_IP_3 }} "mkdir -p /home/tom/"
- name: Copy system service
run: scp deploy/uptool.service ${{ secrets.SERVER_USER }}@${{ secrets.SERVER_IP_3 }}:/etc/systemd/system/
- name: Copy jar file
run: scp target/uptool-0.0.1-SNAPSHOT.jar ${{ secrets.SERVER_USER }}@${{ secrets.SERVER_IP_3 }}:/home/tom/
- name: Restart jar file service
run: ssh -T ${{ secrets.SERVER_USER }}@${{ secrets.SERVER_IP_3 }} "sudo systemctl restart uptool.service && sudo systemctl enable uptool.service"
- name: Copy jar file and service 2
run: ssh -T ${{ secrets.SERVER_USER }}@${{ secrets.SERVER_IP_2 }} "mkdir -p /home/tom/"
- name: Copy system service
run: scp deploy/uptool2.service ${{ secrets.SERVER_USER }}@${{ secrets.SERVER_IP_2 }}:/etc/systemd/system/
- name: Copy jar file
run: scp target/uptool-0.0.1-SNAPSHOT.jar ${{ secrets.SERVER_USER }}@${{ secrets.SERVER_IP_2 }}:/home/tom/
- name: Restart jar file service
run: ssh -T ${{ secrets.SERVER_USER }}@${{ secrets.SERVER_IP_2 }} "sudo systemctl restart uptool2.service && sudo systemctl enable uptool2.service"
- name: Copy jar file and service 1
run: ssh -T ${{ secrets.SERVER_USER }}@${{ secrets.SERVER_IP_1 }} "mkdir -p /home/tom/"
- name: Copy system service
run: scp deploy/uptool2.service ${{ secrets.SERVER_USER }}@${{ secrets.SERVER_IP_1 }}:/etc/systemd/system/
- name: Copy jar file
run: scp target/uptool-0.0.1-SNAPSHOT.jar ${{ secrets.SERVER_USER }}@${{ secrets.SERVER_IP_1 }}:/home/tom/
- name: Restart jar file service
run: ssh -T ${{ secrets.SERVER_USER }}@${{ secrets.SERVER_IP_1 }} "sudo systemctl restart uptool2.service && sudo systemctl enable uptool2.service"
- name: Send telegram
run: curl -X POST "https://api.telegram.org/bot$TELEGRAM_BOT/sendMessage" -d "chat_id=-700731908&text=$GIT_AUTHOR%3A $GIT_MESSAGE%0Ahttps://uptool.org deployed"
env:
TELEGRAM_BOT: ${{ secrets.TELEGRAM_BOT }}
GIT_MESSAGE: ${{ github.event.head_commit.message }}
GIT_AUTHOR: ${{ github.event.pusher.name }}
Last updated
Was this helpful?