Completed prod deploy also

This commit is contained in:
Kim 2023-11-06 16:05:04 +01:00
parent f0c6f42bbf
commit 34b21fa7ae
2 changed files with 31 additions and 60 deletions

View File

@ -8,8 +8,6 @@ jobs:
Build-and-deploy-Production:
runs-on: ubuntu-latest
steps:
- run: echo " The job was automatically triggered by a ${{ gitea.event_name }} event."
- run: echo " The name of your branch is ${{ gitea.ref }} and your repository is ${{ gitea.repository }}."
- name: Check out repository code
uses: actions/checkout@v3
- run: echo " The ${{ gitea.repository }} repository has been cloned to the runner."
@ -21,27 +19,31 @@ jobs:
- run: |
npm --prefix ${{ gitea.workspace }}/typescript/frontend-marios2 install
npm --prefix ${{ gitea.workspace }}/typescript/frontend-marios2 run build
- name: Configure SSH
run: |
mkdir -p ~/.ssh/
echo "$SSH_KEY" > ~/.ssh/production.key
chmod 600 ~/.ssh/production.key
cat >>~/.ssh/config <<END
Host production
HostName $SSH_HOST
User $SSH_USER
IdentityFile ~/.ssh/production.key
StrictHostKeyChecking no
END
env:
SSH_USER: ubuntu
SSH_KEY: ${{ secrets.PRODUCTION_SSH_KEY }}
SSH_HOST: ${{ secrets.PRODUCTION_SSH_HOST }}
- run: |
cd ${{ gitea.workspace }}
scp -r ./csharp/App/Backend/bin/Release/net6.0/linux-x64/publish/ production:~/backend
scp -r ./typescript/frontend-marios2/* production:~/frontend/
ssh production 'sudo systemctl restart backend'
ssh production 'sudo cp -rf ~/frontend/build/* /var/www/html/monitor.innov.energy/html/'
ssh production 'sudo npm install -g serve'
- run: echo " This job's status is ${{ job.status }}."
- name: Copy Backend
uses: appleboy/scp-action@v0.1.4
with:
host: 194.182.190.208
username: ubuntu
key: ${{ secrets.PRODUCTION_SSH_KEY }}
source: "${{ gitea.workspace }}/csharp/App/Backend/bin/Release/net6.0/linux-x64/publish/"
target: "~/backend"
- name: Copy Frontend
uses: appleboy/scp-action@v0.1.4
with:
host: 194.182.190.208
username: ubuntu
key: ${{ secrets.PRODUCTION_SSH_KEY }}
source: "${{ gitea.workspace }}/typescript/frontend-marios2/"
target: "~/frontend"
- name: restart services
uses: appleboy/ssh-action@v0.1.4
with:
host: 194.182.190.208
username: ubuntu
password: ${{ secrets.PRODUCTION_SSH_PASSPHRASE }}
script: |
sudo systemctl restart backend
sudo cp -rf~/frontend/build/* /var/www/html/monitor.innov.energy/html/
sudo npm install -g serve

View File

@ -8,8 +8,6 @@ jobs:
Build-and-deploy-Stage:
runs-on: ubuntu-latest
steps:
- run: echo " The job was automatically triggered by a ${{ gitea.event_name }} event."
- run: echo " The name of your branch is ${{ gitea.ref }} and your repository is ${{ gitea.repository }}."
- name: Check out repository code
uses: actions/checkout@v3
- run: echo " The ${{ gitea.repository }} repository has been cloned to the runner."
@ -47,34 +45,5 @@ jobs:
password: ${{ secrets.STAGE_SSH_PASSPHRASE }}
script: |
sudo systemctl restart backend
sudo cp -rf ~/frontend/build/*
sudo npm install -g serve/var/www/html/monitor.innov.energy/html/
- run: echo " This job's status is ${{ job.status }}."
# - name: Configure SSH
# run: |
# mkdir -p /root/.ssh/
# touch /root/.ssh/config
# echo '$SSH_KEY' > /root/.ssh/id_rsa
# chmod 700 /root/.ssh/id_rsa
#
# cat >> /root/.ssh/config <<END
# Host staging
# HostName $SSH_HOST
# User $SSH_USER
# IdentityFile /root/.ssh/id_rsa
# StrictHostKeyChecking no
# END
# env:
# SSH_USER: ubuntu
# SSH_HOST: 91.92.154.141
# SSS_KEY: ${{ secrets.STAGING_SSH_KEY }}
# - run: scp -vo StrictHostKeyChecking=no -r ${{ gitea.workspace }}/csharp/App/Backend/bin/Release/net6.0/linux-x64/publish/ staging:~/backend
# - run: scp -vo StrictHostKeyChecking=no -r ${{ gitea.workspace }}/typescript/frontend-marios2/* staging:~/frontend/
# - run: ssh -vo StrictHostKeyChecking=no staging 'sudo systemctl restart backend'
# - run: ssh -vo StrictHostKeyChecking=no staging 'sudo cp -rf ~/frontend/build/* /var/www/html/monitor.innov.energy/html/'
# - run: ssh -vo StrictHostKeyChecking=no staging 'sudo npm install -g serve'
# - run: echo " This job's status is ${{ job.status }}."
sudo cp -rf~/frontend/build/* /var/www/html/monitor.innov.energy/html/
sudo npm install -g serve