From 81ebe98f8fd02d7afde2246f956001684b0585de Mon Sep 17 00:00:00 2001 From: Kim Date: Mon, 23 Oct 2023 14:16:27 +0200 Subject: [PATCH] added gitea workflows --- .gitea/workflows/prod-deploy.yaml | 34 ++++++++++++++++++++++++++++++ .gitea/workflows/stage-deploy.yaml | 32 ++++++++++++++++++++++++++++ 2 files changed, 66 insertions(+) create mode 100644 .gitea/workflows/prod-deploy.yaml create mode 100644 .gitea/workflows/stage-deploy.yaml diff --git a/.gitea/workflows/prod-deploy.yaml b/.gitea/workflows/prod-deploy.yaml new file mode 100644 index 000000000..5d26d6e56 --- /dev/null +++ b/.gitea/workflows/prod-deploy.yaml @@ -0,0 +1,34 @@ +name: Production-Deploy +on: + push: + branches: + - 'main' + 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 + uses: actions/checkout@v3 + - run: echo " The ${{ gitea.repository }} repository has been cloned to the runner." + - name: Install build requirements + run: | + apt install dotnet + - name: Build backend + run: | + dotnet publish ${{ gitea.workspace }}/csharp/App/Backend/Backend.csproj -c Release -r linux-x64 --self-contained true -p:PublishTrimmed=false + - name: Build frontend + run: | + npm run build + - name: copy everything to Production + run: | + rsync -av ${{ gitea.workspace }}/csharp/App/Backend/bin/Release/net6.0/linux-x64/publish/ ubuntu@194.182.190.208:~/backend + ssh ubuntu@194.182.190.208'sudo systemctl restart backend' + rsync -rv .* ubuntu@194.182.190.208:~/frontend/ + ssh ubuntu@194.182.190.208 'sudo cp -rf ~/frontend/build/* /var/www/html/monitor.innov.energy/html/' + ssh ubuntu@194.182.190.208 'sudo npm install -g serve' + - run: echo " This job's status is ${{ job.status }}." \ No newline at end of file diff --git a/.gitea/workflows/stage-deploy.yaml b/.gitea/workflows/stage-deploy.yaml new file mode 100644 index 000000000..81cb2a7eb --- /dev/null +++ b/.gitea/workflows/stage-deploy.yaml @@ -0,0 +1,32 @@ +name: Stage-Deploy +on: + push: + branches: + - 'main' + +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." + - name: Install build requirements + run: | + apt install dotnet + - name: Build backend + run: | + dotnet publish ${{ gitea.workspace }}/csharp/App/Backend/Backend.csproj -c Release -r linux-x64 --self-contained true -p:PublishTrimmed=false + - name: Build frontend + run: | + npm run build + - name: copy everything to Stage + run: | + rsync -av ${{ gitea.workspace }}/csharp/App/Backend/bin/Release/net6.0/linux-x64/publish/ ubuntu@91.92.154.141:~/backend + ssh ubuntu@91.92.154.141'sudo systemctl restart backend' + rsync -rv .* ubuntu@91.92.154.141:~/frontend/ + ssh ubuntu@91.92.154.141 'sudo cp -rf ~/frontend/build/* /var/www/html/monitor.innov.energy/html/' + ssh ubuntu@91.92.154.141 'sudo npm install -g serve' + - run: echo " This job's status is ${{ job.status }}." \ No newline at end of file