0c14ad7e55
Added ci-cd.yml GitHub Actions workflow to automate CI/CD for Vijaya Core. Triggers on merged PRs to production, builds and deploys linux-x64 self-contained app, manages service lifecycle, and ensures correct permissions and service status.
49 lines
1.6 KiB
YAML
49 lines
1.6 KiB
YAML
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"
|