Initial commit
CI / Сборка (push) Canceled after 0s
CI / Деплой на стейджинг (push) Canceled after 0s
CI / Проверка кода (push) Canceled after 0s
CI / Сборка (pull_request) Successful in 1m33s
Стенд master
CI / Деплой на стейджинг (pull_request) Successful in 8s
CI / Проверка кода (pull_request) Successful in 1m32s
CI / Сборка (push) Canceled after 0s
CI / Деплой на стейджинг (push) Canceled after 0s
CI / Проверка кода (push) Canceled after 0s
CI / Сборка (pull_request) Successful in 1m33s
Стенд master
CI / Деплой на стейджинг (pull_request) Successful in 8s
CI / Проверка кода (pull_request) Successful in 1m32s
This commit is contained in:
commit
1420aad1ae
92 files changed
+19114
No files matched your search
@@ -0,0 +1,156 @@
|
||||
name: CI
|
||||
|
||||
on:
|
||||
push:
|
||||
branches:
|
||||
- master
|
||||
pull_request:
|
||||
types: [opened, reopened, synchronize]
|
||||
|
||||
concurrency:
|
||||
group: ${{ github.workflow }}-${{ github.head_ref || github.ref_name }}
|
||||
cancel-in-progress: true
|
||||
|
||||
jobs:
|
||||
build:
|
||||
name: Сборка
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v4
|
||||
|
||||
- name: Login to Gitea Registry
|
||||
uses: docker/login-action@v3
|
||||
with:
|
||||
registry: git.jt4d.ru
|
||||
username: ${{ vars.REGISTRY_USER }}
|
||||
password: ${{ secrets.REGISTRY_PASSWORD }}
|
||||
|
||||
- name: Install dependencies
|
||||
run: yarn install --frozen-lockfile
|
||||
|
||||
- name: Check branch name
|
||||
run: yarn lint:branch-name
|
||||
|
||||
- name: Check migrations list
|
||||
run: yarn ts-node tools/buildDataSource.ts --check
|
||||
|
||||
- name: Compute version
|
||||
id: version
|
||||
env:
|
||||
REF_NAME: ${{ github.head_ref || github.ref_name }}
|
||||
run: echo "VERSION=$REF_NAME-$(git rev-parse --short HEAD)" >> "$GITHUB_OUTPUT"
|
||||
|
||||
- name: Build
|
||||
run: yarn build
|
||||
env:
|
||||
APP_VERSION: ${{ steps.version.outputs.VERSION }}
|
||||
|
||||
- name: Check data-source
|
||||
run: yarn ts-node tools/checkDataSource.ts
|
||||
|
||||
- name: Build web docker image
|
||||
uses: docker/build-push-action@v7
|
||||
with:
|
||||
context: apps/web
|
||||
file: apps/web/Dockerfile
|
||||
push: true
|
||||
build-args: |
|
||||
CADDYFILE=Caddyfile.staging
|
||||
tags: git.jt4d.ru/${{ github.repository }}/web:${{ github.head_ref || github.ref_name }}
|
||||
cache-from: git.jt4d.ru/${{ github.repository }}/web:latest
|
||||
labels: |
|
||||
org.opencontainers.image.ref.name=${{ github.head_ref || github.ref_name }}
|
||||
|
||||
- name: Copy
|
||||
run: cp yarn.lock apps/api/
|
||||
|
||||
- name: Build api docker image
|
||||
uses: docker/build-push-action@v7
|
||||
with:
|
||||
context: apps/api
|
||||
file: apps/api/Dockerfile
|
||||
push: true
|
||||
tags: git.jt4d.ru/${{ github.repository }}/api:${{ github.head_ref || github.ref_name }}
|
||||
cache-from: git.jt4d.ru/${{ github.repository }}/api:latest
|
||||
labels: |
|
||||
org.opencontainers.image.ref.name=${{ github.head_ref || github.ref_name }}
|
||||
|
||||
deploy-staging:
|
||||
name: Деплой на стейджинг
|
||||
runs-on: ubuntu-latest
|
||||
needs: build
|
||||
env:
|
||||
DEPLOY_URL: https://${{ github.head_ref || github.ref_name }}.it-smi.jt4d.ru.net
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v4
|
||||
|
||||
- name: Deploy via SSH
|
||||
uses: jt4d-lab/ssh-action@v1
|
||||
env:
|
||||
BRANCH: ${{ github.head_ref || github.ref_name }}
|
||||
with:
|
||||
host: ${{ vars.STAGING_HOST }}
|
||||
username: ${{ vars.STAGING_USER }}
|
||||
key: ${{ secrets.STAGING_SSH_PRIVATE_KEY }}
|
||||
port: ${{ vars.STAGING_PORT }}
|
||||
workdir: /home/${{ vars.STAGING_USER }}/${{ github.event.repository.name }}_${{ github.head_ref || github.ref_name }}
|
||||
files: docker-compose.staging.yml
|
||||
script_stop: true
|
||||
envs: BRANCH
|
||||
script: |
|
||||
mv -f docker-compose.staging.yml docker-compose.yml
|
||||
# \${BRANCH} — литеральный плейсхолдер в docker-compose.staging.yml,
|
||||
# $BRANCH — имя ветки из окружения.
|
||||
sed -i "s/\${BRANCH}/$BRANCH/g" docker-compose.yml
|
||||
docker compose pull --quiet
|
||||
staging-db-postgres create "${{ github.repository }}" "$BRANCH"
|
||||
docker compose down
|
||||
docker compose up -d
|
||||
|
||||
echo "Список миграций"
|
||||
docker compose exec -T api node_modules/.bin/typeorm migration:show -d data-source.js
|
||||
echo "Применение миграций"
|
||||
docker compose exec -T api node_modules/.bin/typeorm migration:run -t each -d data-source.js
|
||||
|
||||
docker system prune -f
|
||||
|
||||
- name: Set deployment status
|
||||
env:
|
||||
BRANCH: ${{ github.head_ref || github.ref_name }}
|
||||
run: |
|
||||
curl -s -X POST \
|
||||
-H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" \
|
||||
-H "Content-Type: application/json" \
|
||||
-d '{
|
||||
"state": "success",
|
||||
"context": "Стенд",
|
||||
"description": "'"$BRANCH"'",
|
||||
"target_url": "'"$DEPLOY_URL"'"
|
||||
}' \
|
||||
"${{ github.server_url }}/api/v1/repos/${{ github.repository }}/statuses/${{ github.sha }}"
|
||||
|
||||
- name: Write stand URL to summary
|
||||
run: echo "**Стенд:** $DEPLOY_URL" >> "$GITHUB_STEP_SUMMARY"
|
||||
|
||||
check:
|
||||
name: Проверка кода
|
||||
runs-on: ubuntu-latest
|
||||
needs: build
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v4
|
||||
|
||||
- name: Login to Gitea Registry
|
||||
uses: docker/login-action@v3
|
||||
with:
|
||||
registry: git.jt4d.ru
|
||||
username: ${{ vars.REGISTRY_USER }}
|
||||
password: ${{ secrets.REGISTRY_PASSWORD }}
|
||||
|
||||
- name: Install dependencies
|
||||
run: yarn install --frozen-lockfile
|
||||
|
||||
- name: Lint
|
||||
run: yarn lint:check
|
||||
Reference in new issue
Block a user