This commit is contained in:
2026-05-03 08:50:29 +03:00
parent 740f057f9f
commit c263eeadf5
2 changed files with 101 additions and 0 deletions
+59
View File
@@ -0,0 +1,59 @@
# этап 1.
name: build & test
on:
# Указываем ветки которые будут триггерить пайплайн
pull_request:
branches: ["release"]
types: [closed]
# Указываем триггер - опубликованный релиз
release:
types: [published]
workflow_call:
# позволяет запускать пайплайн вручную через вкладку Actions
workflow_dispatch:
# этап 2.
jobs:
build:
# Проверяем, что job запустился или при мерже пулл-реквеста, или на событии релиза, или вручную
if: ${{ github.event_name == 'release' || github.event_name == 'workflow_dispatch' || github.event.pull_request.merged == true }}
runs-on: self-hosted
steps:
- name: Clone repository
uses: actions/checkout@v4
with:
ref: release
- name: Set up Flutter
uses: subosito/flutter-action@v2
with:
channel: stable
run: flutter --version
- name: Install dependencies
run: flutter pub get
- name: Analyze project source
if: success()
run: flutter analyze
- name: Run tests
run: flutter test
- name: Build Flutter Web
if: success()
run: flutter build web
- name: Prepare deployment directory
run: |
mkdir -p ~/opt/development/frontend
cp -r * ~/opt/development/frontend/
- name: Check if Docker is installed
run: |
if ! command -v docker &> /dev/null; then
echo "Docker is not installed"
exit 1
fi
- name: Try to restart container
run: |
if [ -f ~/opt/development/docker/docker-compose.yml ]; then
echo "docker-compose.yml found, restarting container"
docker-compose -f ~/opt/development/docker/docker-compose.yml up -d --build frontend
else
echo "docker-compose.yml not found, skipping docker-compose commands"
fi
+42
View File
@@ -0,0 +1,42 @@
FROM debian:latest AS build
RUN apt-get update && \
apt-get install -y libxi6 libgtk-3-0 libxrender1 libxtst6 libxslt1.1 curl git wget unzip libgconf-2-4 gdb libstdc++6 libglu1-mesa fonts-droid-fallback lib32stdc++6 python3 && \
apt-get clean
RUN git clone https://github.com/flutter/flutter.git /usr/local/flutter
#Set Flutter path
ENV PATH="/usr/local/flutter/bin:/usr/local/flutter/bin/cache/dart-sdk/bin:${PATH}"
RUN flutter doctor -v && \
flutter channel master && \
flutter upgrade && \
flutter config --enable-web
#Create app directory
RUN mkdir /app/
#Copy application files
COPY . /app/
#Set the working directory inside the container
WORKDIR /app/
#Build the Flutter web application
RUN flutter build web --release
#Stage 2: Nginx server
FROM nginx:1.27.2-alpine
#Copy built web application from build stage
COPY --from=build /app/build/web /usr/share/nginx/html
#Copy custom Nginx configuration
COPY nginx.conf /etc/nginx/conf.d/nginx.conf
#Expose port 80
EXPOSE 80
#Start Nginx
CMD ["nginx", "-g", "daemon off;"]