Skip to content

Commit 002d29f

Browse files
refactoring schema, ci-cd upgrade (#16)
* refactoring schema * ci-cd upgrade
1 parent fb4ff64 commit 002d29f

File tree

12 files changed

+150
-173
lines changed

12 files changed

+150
-173
lines changed

.github/workflows/deploy.yml

Lines changed: 0 additions & 88 deletions
This file was deleted.

.github/workflows/publish-backend.yml

Lines changed: 29 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,23 @@ jobs:
2020
runs-on: ubuntu-latest
2121
if: github.event_name == 'workflow_dispatch'
2222
steps:
23+
- name: Validate version format
24+
run: |
25+
VERSION="${{ github.event.inputs.version }}"
26+
27+
# Разрешить форматы типа v1.2.3 и v1.2.3-suffix
28+
if [[ ! "$VERSION" =~ ^v[0-9]+\.[0-9]+\.[0-9]+(-[a-zA-Z0-9._]+)?$ ]]; then
29+
echo "❌ Неверный формат версии. Используйте формат vX.Y.Z или vX.Y.Z-suffix (например, v1.2.3 или v1.2.3-beta)"
30+
exit 1
31+
fi
32+
33+
# Установим переменную IS_PLAIN_VERSION, если версия без суффикса
34+
if [[ "$VERSION" =~ ^v[0-9]+\.[0-9]+\.[0-9]+$ ]]; then
35+
echo "IS_PLAIN_VERSION=true" >> $GITHUB_ENV
36+
else
37+
echo "IS_PLAIN_VERSION=false" >> $GITHUB_ENV
38+
fi
39+
2340
- name: Checkout
2441
uses: actions/checkout@master
2542

@@ -51,10 +68,15 @@ jobs:
5168
-t ${{ secrets.DOCKER_LOGIN }}/bugget-api:${{ env.VERSION }} \
5269
--push \
5370
-f ./Bugget/Dockerfile .
54-
docker buildx build \
55-
--platform linux/amd64,linux/arm64 \
56-
--cache-from=type=gha \
57-
--cache-to=type=gha,mode=max \
58-
-t ${{ secrets.DOCKER_LOGIN }}/bugget-api:latest \
59-
--push \
60-
-f ./Bugget/Dockerfile .
71+
72+
if [[ "${{ env.IS_PLAIN_VERSION }}" == "true" ]]; then
73+
docker buildx build \
74+
--platform linux/amd64,linux/arm64 \
75+
--cache-from=type=gha \
76+
--cache-to=type=gha,mode=max \
77+
-t ${{ secrets.DOCKER_LOGIN }}/bugget-api:latest \
78+
--push \
79+
-f ./Bugget/Dockerfile .
80+
else
81+
echo "🔁 Пропущен пуш latest, так как версия не в виде vX.Y.Z"
82+
fi

.github/workflows/publish-frontend.yml

Lines changed: 28 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,23 @@ jobs:
2020
runs-on: ubuntu-latest
2121
if: github.event_name == 'workflow_dispatch'
2222
steps:
23+
- name: Validate version format
24+
run: |
25+
VERSION="${{ github.event.inputs.version }}"
26+
27+
# Разрешить форматы типа v1.2.3 и v1.2.3-suffix
28+
if [[ ! "$VERSION" =~ ^v[0-9]+\.[0-9]+\.[0-9]+(-[a-zA-Z0-9._]+)?$ ]]; then
29+
echo "❌ Неверный формат версии. Используйте формат vX.Y.Z или vX.Y.Z-suffix (например, v1.2.3 или v1.2.3-beta)"
30+
exit 1
31+
fi
32+
33+
# Установим переменную IS_PLAIN_VERSION, если версия без суффикса
34+
if [[ "$VERSION" =~ ^v[0-9]+\.[0-9]+\.[0-9]+$ ]]; then
35+
echo "IS_PLAIN_VERSION=true" >> $GITHUB_ENV
36+
else
37+
echo "IS_PLAIN_VERSION=false" >> $GITHUB_ENV
38+
fi
39+
2340
- name: Checkout
2441
uses: actions/checkout@master
2542

@@ -50,9 +67,14 @@ jobs:
5067
--cache-to=type=gha,mode=max \
5168
-t ${{ secrets.DOCKER_LOGIN }}/bugget-ui:${{ env.VERSION }} \
5269
--push .
53-
docker buildx build \
54-
--platform linux/amd64,linux/arm64 \
55-
--cache-from=type=gha \
56-
--cache-to=type=gha,mode=max \
57-
-t ${{ secrets.DOCKER_LOGIN }}/bugget-ui:latest \
58-
--push .
70+
71+
if [[ "${{ env.IS_PLAIN_VERSION }}" == "true" ]]; then
72+
docker buildx build \
73+
--platform linux/amd64,linux/arm64 \
74+
--cache-from=type=gha \
75+
--cache-to=type=gha,mode=max \
76+
-t ${{ secrets.DOCKER_LOGIN }}/bugget-ui:latest \
77+
--push .
78+
else
79+
echo "🔁 Пропущен пуш latest, так как версия не в виде vX.Y.Z"
80+
fi

.github/workflows/publish-migrator.yml

Lines changed: 29 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,23 @@ jobs:
2020
runs-on: ubuntu-latest
2121
if: github.event_name == 'workflow_dispatch'
2222
steps:
23+
- name: Validate version format
24+
run: |
25+
VERSION="${{ github.event.inputs.version }}"
26+
27+
# Разрешить форматы типа v1.2.3 и v1.2.3-suffix
28+
if [[ ! "$VERSION" =~ ^v[0-9]+\.[0-9]+\.[0-9]+(-[a-zA-Z0-9._]+)?$ ]]; then
29+
echo "❌ Неверный формат версии. Используйте формат vX.Y.Z или vX.Y.Z-suffix (например, v1.2.3 или v1.2.3-beta)"
30+
exit 1
31+
fi
32+
33+
# Установим переменную IS_PLAIN_VERSION, если версия без суффикса
34+
if [[ "$VERSION" =~ ^v[0-9]+\.[0-9]+\.[0-9]+$ ]]; then
35+
echo "IS_PLAIN_VERSION=true" >> $GITHUB_ENV
36+
else
37+
echo "IS_PLAIN_VERSION=false" >> $GITHUB_ENV
38+
fi
39+
2340
- name: Checkout
2441
uses: actions/checkout@master
2542

@@ -51,10 +68,15 @@ jobs:
5168
-t ${{ secrets.DOCKER_LOGIN }}/bugget-migrator:${{ env.VERSION }} \
5269
--push \
5370
-f ./Dockerfile .
54-
docker buildx build \
55-
--platform linux/amd64,linux/arm64 \
56-
--cache-from=type=gha \
57-
--cache-to=type=gha,mode=max \
58-
-t ${{ secrets.DOCKER_LOGIN }}/bugget-migrator:latest \
59-
--push \
60-
-f ./Dockerfile .
71+
72+
if [[ "${{ env.IS_PLAIN_VERSION }}" == "true" ]]; then
73+
docker buildx build \
74+
--platform linux/amd64,linux/arm64 \
75+
--cache-from=type=gha \
76+
--cache-to=type=gha,mode=max \
77+
-t ${{ secrets.DOCKER_LOGIN }}/bugget-migrator:latest \
78+
--push \
79+
-f ./Dockerfile .
80+
else
81+
echo "🔁 Пропущен пуш latest, так как версия не в виде vX.Y.Z"
82+
fi

devops/migrator/sql/001_ddl.sql

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
-- Таблица отчётов
2-
CREATE TABLE IF NOT EXISTS public.report (
2+
CREATE TABLE IF NOT EXISTS public.reports (
33
id integer generated always as identity
44
primary key,
55
title TEXT NOT NULL,
@@ -15,13 +15,13 @@ CREATE TABLE IF NOT EXISTS public.report_participants (
1515
report_id INT NOT NULL,
1616
user_id text NOT NULL,
1717
PRIMARY KEY (report_id, user_id),
18-
CONSTRAINT fk_report
18+
CONSTRAINT fk_reports
1919
FOREIGN KEY (report_id)
20-
REFERENCES public.report(id)
20+
REFERENCES public.reports(id)
2121
);
2222

23-
-- Таблица bug
24-
CREATE TABLE IF NOT EXISTS public.bug (
23+
-- Таблица багов
24+
CREATE TABLE IF NOT EXISTS public.bugs (
2525
id integer generated always as identity
2626
primary key,
2727
report_id INT NOT NULL,
@@ -32,27 +32,27 @@ CREATE TABLE IF NOT EXISTS public.bug (
3232
creator_user_id text NOT NULL,
3333
status INT NOT NULL,
3434

35-
CONSTRAINT fk_bug_report
35+
CONSTRAINT fk_bugs_reports
3636
FOREIGN KEY (report_id)
37-
REFERENCES public.report(id)
37+
REFERENCES public.reports(id)
3838
);
3939

40-
-- Таблица вложений (attachment)
41-
CREATE TABLE IF NOT EXISTS public.attachment (
40+
-- Таблица вложений
41+
CREATE TABLE IF NOT EXISTS public.attachments (
4242
id integer generated always as identity
4343
primary key,
4444
bug_id INT NOT NULL,
4545
path TEXT NOT NULL,
4646
created_at timestamp with time zone not null default now(),
4747
attach_type INT NOT NULL,
4848

49-
CONSTRAINT fk_attachment_bug
49+
CONSTRAINT fk_attachments_bugs
5050
FOREIGN KEY (bug_id)
51-
REFERENCES public.bug(id)
51+
REFERENCES public.bugs(id)
5252
);
5353

54-
-- Таблица комментариев (comment)
55-
CREATE TABLE IF NOT EXISTS public.comment (
54+
-- Таблица комментариев
55+
CREATE TABLE IF NOT EXISTS public.comments (
5656
id integer generated always as identity
5757
primary key,
5858
bug_id INT NOT NULL,
@@ -62,7 +62,7 @@ CREATE TABLE IF NOT EXISTS public.comment (
6262
updated_at timestamp with time zone not null default now(),
6363

6464

65-
CONSTRAINT fk_comment_bug
65+
CONSTRAINT fk_comments_bugs
6666
FOREIGN KEY (bug_id)
67-
REFERENCES public.bug(id)
67+
REFERENCES public.bugs(id)
6868
);

devops/migrator/sql/002_dml_reports.sql

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ DECLARE
1616
bug_json JSONB;
1717
BEGIN
1818
-- Создаём Report
19-
INSERT INTO public.report (title, status, responsible_user_id, creator_user_id)
19+
INSERT INTO public.reports (title, status, responsible_user_id, creator_user_id)
2020
VALUES (_title, _status, _responsible_user_id, _creator_user_id)
2121
RETURNING id INTO new_report_id;
2222

@@ -30,7 +30,7 @@ BEGIN
3030
FOR bug_json IN
3131
SELECT * FROM jsonb_array_elements(_bugs_json::jsonb)
3232
LOOP
33-
INSERT INTO public.bug (report_id, receive, expect, status, creator_user_id)
33+
INSERT INTO public.bugs (report_id, receive, expect, status, creator_user_id)
3434
VALUES (new_report_id,
3535
(bug_json ->> 'receive')::TEXT,
3636
(bug_json ->> 'expect')::TEXT,
@@ -79,7 +79,7 @@ BEGIN
7979
'created_at', a.created_at
8080
)
8181
)
82-
FROM public.attachment a
82+
FROM public.attachments a
8383
WHERE a.bug_id = b.id), '[]'::jsonb),
8484
'comments', COALESCE((SELECT jsonb_agg(
8585
jsonb_build_object(
@@ -91,18 +91,18 @@ BEGIN
9191
'updated_at', c.updated_at
9292
)
9393
)
94-
FROM public.comment c
94+
FROM public.comments c
9595
WHERE c.bug_id = b.id), '[]'::jsonb)
9696
)
9797
)
98-
FROM public.bug b
98+
FROM public.bugs b
9999
WHERE b.report_id = r.id), '[]'::jsonb),
100100
'participants_user_ids', COALESCE((SELECT jsonb_agg(user_id)
101101
FROM public.report_participants
102102
WHERE report_id = r.id), '[]'::jsonb)
103103
)
104104
INTO result
105-
FROM public.report r
105+
FROM public.reports r
106106
WHERE r.id = _report_id;
107107

108108
RETURN result;
@@ -120,7 +120,7 @@ $$
120120
BEGIN
121121
RETURN QUERY
122122
SELECT public.get_report(r.id)
123-
FROM public.report r
123+
FROM public.reports r
124124
WHERE r.status = 0
125125
AND r.id IN (SELECT report_id
126126
FROM public.report_participants
@@ -141,7 +141,7 @@ AS
141141
$$
142142
BEGIN
143143
-- Обновляем report, если параметры не null
144-
UPDATE public.report
144+
UPDATE public.reports
145145
SET title = COALESCE(_title, title),
146146
status = COALESCE(_status, status),
147147
responsible_user_id = COALESCE(_responsible_user_id, responsible_user_id),

0 commit comments

Comments
 (0)