2023-10-23 12:16:27 +00:00
|
|
|
name: Production-Deploy
|
|
|
|
on:
|
|
|
|
push:
|
|
|
|
tags:
|
|
|
|
- v1.**
|
|
|
|
|
|
|
|
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
|
2023-10-23 12:27:23 +00:00
|
|
|
uses: actions/checkout@v3
|
2023-10-23 12:16:27 +00:00
|
|
|
- run: echo " The ${{ gitea.repository }} repository has been cloned to the runner."
|
2023-10-23 13:32:53 +00:00
|
|
|
- uses: actions/setup-dotnet@v3
|
|
|
|
with:
|
|
|
|
dotnet-version: '7.0.x'
|
|
|
|
- run: dotnet publish ${{ gitea.workspace }}/csharp/App/Backend/Backend.csproj -c Release -r linux-x64 --self-contained true -p:PublishTrimmed=false
|
|
|
|
- uses: actions/setup-node@v3
|
2023-10-23 12:28:13 +00:00
|
|
|
- run: |
|
2023-10-23 13:32:53 +00:00
|
|
|
npm --prefix ${{ gitea.workspace }}/typescript/frontend-marios2 install
|
|
|
|
npm --prefix ${{ gitea.workspace }}/typescript/frontend-marios2 run build
|
2023-10-23 14:04:30 +00:00
|
|
|
- uses: burnett01/rsync-deployments@6.0.0
|
|
|
|
- run: |
|
2023-10-23 13:43:27 +00:00
|
|
|
cd ${{ gitea.workspace }}
|
2023-10-23 14:04:30 +00:00
|
|
|
rsync -av ./csharp/App/Backend/bin/Release/net6.0/linux-x64/publish/ ubuntu@${{ secrets.PRODUCTION_SSH_HOST }}:~/backend
|
|
|
|
rsync -av ./typescript/frontend-marios2/* ubuntu@${{ secrets.PRODUCTION_SSH_HOST }}:~/frontend/
|
|
|
|
- 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 }}
|
2023-10-23 14:06:11 +00:00
|
|
|
- run: |
|
|
|
|
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'
|
2023-10-23 12:16:27 +00:00
|
|
|
- run: echo " This job's status is ${{ job.status }}."
|