Merge pull request 'Add CI/CD workflow for automated production deployment' (#1) from production into dev
Reviewed-on: #1
This commit was merged in pull request #1.
This commit is contained in:
@@ -0,0 +1,48 @@
|
|||||||
|
name: CI/CD - Vijaya Core
|
||||||
|
on:
|
||||||
|
pull_request:
|
||||||
|
branches:
|
||||||
|
- production
|
||||||
|
types:
|
||||||
|
- closed
|
||||||
|
jobs:
|
||||||
|
build-and-deploy:
|
||||||
|
name: Build & Deploy
|
||||||
|
runs-on: linux
|
||||||
|
if: github.event.pull_request.merged == true
|
||||||
|
steps:
|
||||||
|
- name: Checkout code
|
||||||
|
run: |
|
||||||
|
git clone \
|
||||||
|
--depth 1 \
|
||||||
|
--branch production \
|
||||||
|
https://oauth2:${{ secrets.VIJAYA }}@gitea.hexdive.com/Vijaya_Gym/Core_Be.git \
|
||||||
|
.
|
||||||
|
- name: Restore
|
||||||
|
run: dotnet restore Fitness-core-BE.sln
|
||||||
|
- name: Publish
|
||||||
|
run: |
|
||||||
|
rm -rf /tmp/vijayacore-deploy
|
||||||
|
mkdir -p /tmp/vijayacore-deploy
|
||||||
|
dotnet publish Fitness_core_BE.csproj \
|
||||||
|
-c Release \
|
||||||
|
-r linux-x64 \
|
||||||
|
--self-contained true \
|
||||||
|
-o /tmp/vijayacore-deploy
|
||||||
|
- name: Stop service
|
||||||
|
run: systemctl stop vijayacore.service
|
||||||
|
- name: Copy to deploy folder
|
||||||
|
run: |
|
||||||
|
rm -rf /home/vijayasport/core/publish/*
|
||||||
|
cp -r /tmp/vijayacore-deploy/* /home/vijayasport/core/publish/
|
||||||
|
- name: Fix ownership and permissions
|
||||||
|
run: |
|
||||||
|
chown -R vijayasportuser:vijayasportuser /home/vijayasport/core/publish
|
||||||
|
find /home/vijayasport/core/publish -type d -exec chmod 755 {} +
|
||||||
|
find /home/vijayasport/core/publish -type f -exec chmod 644 {} +
|
||||||
|
chmod +x /home/vijayasport/core/publish/Fitness_core_BE
|
||||||
|
- name: Restart service
|
||||||
|
run: systemctl restart vijayacore.service
|
||||||
|
- name: Verify
|
||||||
|
run: |
|
||||||
|
systemctl is-active vijayacore.service && echo "✅ Service running" || echo "❌ Service failed"
|
||||||
Reference in New Issue
Block a user