131 lines
4.3 KiB
YAML
131 lines
4.3 KiB
YAML
name: 'Build Frontend'
|
|
on:
|
|
workflow_dispatch:
|
|
inputs:
|
|
repo_path:
|
|
description: 'Репозиторий'
|
|
required: true
|
|
type: choice
|
|
options:
|
|
- devspc/devspace-selfkit-ui
|
|
default: devspc/devspace-selfkit-ui
|
|
branch:
|
|
description: 'Ветка'
|
|
required: true
|
|
type: string
|
|
default: 'feature/DEVX-182-ApiRegistry-overhaul-p2-ApiCardEdit'
|
|
version:
|
|
default: latest
|
|
description: 'Версия образа'
|
|
required: true
|
|
type: string
|
|
jobs:
|
|
deploy-dev:
|
|
name: 'Deploy to dev'
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- name: Cloning2
|
|
uses: https://git.binom.pw/otp/devops/clone@main
|
|
with:
|
|
ssh-private-key: ${{ secrets.SSH_PRIVATE_KEY }}
|
|
repository: ${{ github.event.inputs.repo_path }}
|
|
branch: ${{ github.event.inputs.branch }}
|
|
- name: Set up Node.js ${{ matrix.node-version }}
|
|
uses: actions/setup-node@v4 # Use the setup-node action
|
|
with:
|
|
node-version: 24
|
|
cache: 'npm'
|
|
- name: Building
|
|
run: |
|
|
npm install
|
|
npm run build
|
|
cat > entrypoint.sh <<EOF
|
|
#!/bin/sh
|
|
set -e
|
|
exec nginx -g "daemon off;"
|
|
EOF
|
|
|
|
cat > default.conf << EOF
|
|
server {
|
|
listen 80;
|
|
server_name localhost;
|
|
|
|
location / {
|
|
root /usr/share/nginx/html;
|
|
try_files \$uri \$uri/ /index.html;
|
|
}
|
|
|
|
# Health check (всегда 200)
|
|
location /health {
|
|
access_log off;
|
|
return 200 "OK\n";
|
|
add_header Content-Type text/plain;
|
|
}
|
|
}
|
|
EOF
|
|
cat > Dockerfile << EOF
|
|
FROM nginx:stable-alpine
|
|
|
|
# Установка gettext для envsubst (уже есть в alpine, но для ясности)
|
|
RUN apk add --no-cache gettext
|
|
|
|
# Удаляем дефолтный конфиг
|
|
RUN rm /etc/nginx/conf.d/default.conf
|
|
|
|
# Создаём папку для шаблонов
|
|
WORKDIR /etc/nginx/templates
|
|
|
|
# Копируем шаблон конфигурации
|
|
COPY default.conf /etc/nginx/conf.d/default.conf
|
|
|
|
# Копируем entrypoint-скрипт
|
|
COPY entrypoint.sh /entrypoint.sh
|
|
RUN chmod +x /entrypoint.sh
|
|
|
|
# Копируем статические файлы
|
|
COPY ./dist /usr/share/nginx/html
|
|
|
|
EXPOSE 80
|
|
|
|
ENTRYPOINT ["/entrypoint.sh"]
|
|
CMD ["nginx", "-g", "daemon off;"]
|
|
EOF
|
|
echo 'entrypoint.sh:'
|
|
cat entrypoint.sh
|
|
- name: Build Docker Image
|
|
uses: https://git.binom.pw/subochev/devops/build-docker@main
|
|
with:
|
|
image_name: "otp/${{ github.event.inputs.repo_path }}"
|
|
tags: latest ${{ github.event.inputs.version }}
|
|
- name: Kuebrnetus config
|
|
run: |
|
|
echo '${{ secrets.KUBE_CONFIG }}' > ./ku.yaml
|
|
- name: "Install Helm"
|
|
uses: azure/setup-helm@v4.3.0
|
|
- name: 'Clone Helms'
|
|
uses: https://github.com/actions/checkout@v4
|
|
with:
|
|
repository: otp/devex
|
|
path: 'helms'
|
|
- name: Deploy
|
|
run: |
|
|
pathToHelm='./helms/${{ github.event.inputs.repo_path }}'
|
|
releaseName=$(basename "$pathToHelm")
|
|
echo "Release Name: $releaseName"
|
|
helm upgrade --install "$releaseName" "$pathToHelm" \
|
|
--namespace devx \
|
|
--kubeconfig ./ku.yaml \
|
|
--create-namespace \
|
|
--set-string 'image.version=${{ github.event.inputs.version }}' \
|
|
--set-string 'image.name=images.binom.pw/otp/${{ github.event.inputs.repo_path }}' \
|
|
--set-string 'repository.name=${{ github.event.inputs.repo_path }}' \
|
|
--set-string 'repository.branch=${{ github.event.inputs.branch }}' \
|
|
--set "imagePullSecrets[0].name=regcred" \
|
|
--wait
|
|
- name: 'Cleanup'
|
|
if: always()
|
|
shell: bash
|
|
run: |
|
|
echo 'Cleaning...'
|
|
rm -rf ~/.ssh/config
|
|
rm -rf ~/.ssh/my_key |