feat: CI/CD to user production server

This commit is contained in:
sBubshait 2025-07-27 09:44:13 +03:00
parent 5eb191e93e
commit d8e9ea9c6e
3 changed files with 90 additions and 56 deletions

34
.github/workflows/deploy-prod.yml vendored Normal file
View File

@ -0,0 +1,34 @@
name: Deploy to Production
on:
push:
branches:
- main
- master
jobs:
deploy:
name: Deploy to Production
needs: build_and_push
runs-on: ubuntu-latest
if: github.ref == 'refs/heads/main' || github.ref == 'refs/heads/master'
environment: production
steps:
- name: Deploy to Server
uses: appleboy/ssh-action@v0.1.5
with:
host: ${{ secrets.SERVER_HOST }}
username: ${{ secrets.SERVER_USERNAME }}
key: ${{ secrets.SERVER_SSH_KEY }}
port: ${{ secrets.SERVER_PORT }}
script: |
whoami
cd /home/wesal
git pull origin main
docker compose down
docker compose up -d --build
docker image prune -f

View File

@ -1,40 +1,40 @@
# This file was auto-generated by the Firebase CLI
# https://github.com/firebase/firebase-tools
# # This file was auto-generated by the Firebase CLI
# # https://github.com/firebase/firebase-tools
name: Deploy to Firebase Hosting on merge
on:
push:
branches:
- main
jobs:
build_and_deploy:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v3
# name: Deploy to Firebase Hosting on merge
# on:
# push:
# branches:
# - main
# jobs:
# build_and_deploy:
# runs-on: ubuntu-latest
# steps:
# - name: Checkout code
# uses: actions/checkout@v3
- name: Set up Flutter
uses: subosito/flutter-action@v2
with:
flutter-version: '3.32.6'
channel: stable
# - name: Set up Flutter
# uses: subosito/flutter-action@v2
# with:
# flutter-version: '3.32.6'
# channel: stable
- name: Install dependencies
working-directory: frontend
run: flutter pub get
# - name: Install dependencies
# working-directory: frontend
# run: flutter pub get
# - name: Run tests
# run: flutter test
# # - name: Run tests
# # run: flutter test
- name: Build Flutter Web
working-directory: frontend
run: flutter build web --release
# - name: Build Flutter Web
# working-directory: frontend
# run: flutter build web --release
- name: Deploy to Firebase Hosting
uses: FirebaseExtended/action-hosting-deploy@v0
with:
repoToken: ${{ secrets.GITHUB_TOKEN }}
firebaseServiceAccount: ${{ secrets.FIREBASE_SERVICE_ACCOUNT_WESALAPP_BC676 }}
channelId: live
projectId: wesalapp-bc676
entryPoint: frontend
# - name: Deploy to Firebase Hosting
# uses: FirebaseExtended/action-hosting-deploy@v0
# with:
# repoToken: ${{ secrets.GITHUB_TOKEN }}
# firebaseServiceAccount: ${{ secrets.FIREBASE_SERVICE_ACCOUNT_WESALAPP_BC676 }}
# channelId: live
# projectId: wesalapp-bc676
# entryPoint: frontend

View File

@ -1,23 +1,23 @@
# This file was auto-generated by the Firebase CLI
# https://github.com/firebase/firebase-tools
# # This file was auto-generated by the Firebase CLI
# # https://github.com/firebase/firebase-tools
name: Deploy to Firebase Hosting on PR
on: pull_request
permissions:
checks: write
contents: read
pull-requests: write
jobs:
build_and_preview:
if: ${{ github.event.pull_request.head.repo.full_name == github.repository }}
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- run: flutter build web
working-directory: frontend
- uses: FirebaseExtended/action-hosting-deploy@v0
with:
repoToken: ${{ secrets.GITHUB_TOKEN }}
firebaseServiceAccount: ${{ secrets.FIREBASE_SERVICE_ACCOUNT_WESALAPP_BC676 }}
projectId: wesalapp-bc676
entryPoint: frontend
# name: Deploy to Firebase Hosting on PR
# on: pull_request
# permissions:
# checks: write
# contents: read
# pull-requests: write
# jobs:
# build_and_preview:
# if: ${{ github.event.pull_request.head.repo.full_name == github.repository }}
# runs-on: ubuntu-latest
# steps:
# - uses: actions/checkout@v4
# - run: flutter build web
# working-directory: frontend
# - uses: FirebaseExtended/action-hosting-deploy@v0
# with:
# repoToken: ${{ secrets.GITHUB_TOKEN }}
# firebaseServiceAccount: ${{ secrets.FIREBASE_SERVICE_ACCOUNT_WESALAPP_BC676 }}
# projectId: wesalapp-bc676
# entryPoint: frontend