From 778981b06de499449a7f661bdfacb01722a71ac3 Mon Sep 17 00:00:00 2001 From: xLima12 Date: Wed, 6 May 2026 22:34:06 -0300 Subject: [PATCH] feat: implement gitops versioning and fix flyway checksums --- .github/workflows/backend-cd.yml | 18 ++++- .github/workflows/frontend-cd.yml | 19 ++++- backend/pom.xml | 5 ++ .../migration/V1__Create_Initial_Schema.sql | 70 +++++++++---------- k8s/backend/deployment.yaml | 2 + k8s/frontend/deployment.yaml | 2 + 6 files changed, 79 insertions(+), 37 deletions(-) diff --git a/.github/workflows/backend-cd.yml b/.github/workflows/backend-cd.yml index beda9f7..76459f9 100644 --- a/.github/workflows/backend-cd.yml +++ b/.github/workflows/backend-cd.yml @@ -15,7 +15,7 @@ jobs: build-and-push: runs-on: ubuntu-latest permissions: - contents: read + contents: write packages: write env: DB_USER: test @@ -48,12 +48,19 @@ jobs: username: ${{ github.actor }} password: ${{ secrets.GITHUB_TOKEN }} + - name: Extract backend version + id: version + run: | + VERSION=$(backend/mvnw help:evaluate -Dexpression=project.version -q -DforceStdout -f backend/pom.xml) + echo "VERSION=$VERSION" >> $GITHUB_ENV + - name: Extract metadata (tags, labels) for Docker id: meta uses: docker/metadata-action@v5 with: images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} tags: | + type=raw,value=${{ env.VERSION }} type=raw,value=latest type=sha @@ -65,3 +72,12 @@ jobs: push: true tags: ${{ steps.meta.outputs.tags }} labels: ${{ steps.meta.outputs.labels }} + + - name: Update Kubernetes manifest + run: | + sed -i "s|image: ghcr.io/devflima/flima.dev-backend:.*|image: ghcr.io/devflima/flima.dev-backend:${{ env.VERSION }}|g" k8s/backend/deployment.yaml + git config --global user.name 'github-actions[bot]' + git config --global user.email 'github-actions[bot]@users.noreply.github.com' + git add k8s/backend/deployment.yaml + git commit -m "chore: update backend image tag to ${{ env.VERSION }} [skip ci]" || echo "No changes to commit" + git push diff --git a/.github/workflows/frontend-cd.yml b/.github/workflows/frontend-cd.yml index d13cb09..097d9bb 100644 --- a/.github/workflows/frontend-cd.yml +++ b/.github/workflows/frontend-cd.yml @@ -15,7 +15,7 @@ jobs: build-and-push: runs-on: ubuntu-latest permissions: - contents: read + contents: write packages: write steps: - name: Checkout Code @@ -28,12 +28,20 @@ jobs: username: ${{ github.actor }} password: ${{ secrets.GITHUB_TOKEN }} + - name: Extract frontend version + id: version + working-directory: ./frontend + run: | + VERSION=$(node -p "require('./package.json').version") + echo "VERSION=$VERSION" >> $GITHUB_ENV + - name: Extract metadata (tags, labels) for Docker id: meta uses: docker/metadata-action@v5 with: images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} tags: | + type=raw,value=${{ env.VERSION }} type=raw,value=latest type=sha @@ -45,4 +53,13 @@ jobs: tags: ${{ steps.meta.outputs.tags }} labels: ${{ steps.meta.outputs.labels }} + - name: Update Kubernetes manifest + run: | + sed -i "s|image: ghcr.io/devflima/flima.dev:.*|image: ghcr.io/devflima/flima.dev:${{ env.VERSION }}|g" k8s/frontend/deployment.yaml + git config --global user.name 'github-actions[bot]' + git config --global user.email 'github-actions[bot]@users.noreply.github.com' + git add k8s/frontend/deployment.yaml + git commit -m "chore: update frontend image tag to ${{ env.VERSION }} [skip ci]" || echo "No changes to commit" + git push + diff --git a/backend/pom.xml b/backend/pom.xml index cb84385..3e85431 100644 --- a/backend/pom.xml +++ b/backend/pom.xml @@ -16,6 +16,11 @@ 3.34.5 true 3.5.4 + + + e1 + * + src/main/resources/db/migration/V1__Create_Initial_Schema.sql diff --git a/backend/src/main/resources/db/migration/V1__Create_Initial_Schema.sql b/backend/src/main/resources/db/migration/V1__Create_Initial_Schema.sql index 90cac5f..7236ea4 100644 --- a/backend/src/main/resources/db/migration/V1__Create_Initial_Schema.sql +++ b/backend/src/main/resources/db/migration/V1__Create_Initial_Schema.sql @@ -10,23 +10,23 @@ CREATE TYPE role_enum AS ENUM ('OWNER'); CREATE TABLE contents ( id UUID PRIMARY KEY DEFAULT gen_random_uuid(), section_type section_type_enum NOT NULL, - title VARCHAR(255) NOT NULL CHECK (length(trim(title)) > 0), - subtitle VARCHAR(255) NOT NULL CHECK (length(trim(subtitle)) > 0) + title VARCHAR(255) NOT NULL CHECK (trim(title) <> ''), + subtitle VARCHAR(255) NOT NULL CHECK (trim(title) <> '') ); CREATE TABLE educations ( id UUID PRIMARY KEY DEFAULT gen_random_uuid(), education_type education_type_enum NOT NULL, - degree VARCHAR(255) NOT NULL CHECK (length(trim(degree)) > 0), - title VARCHAR(255) NOT NULL CHECK (length(trim(title)) > 0), - institution VARCHAR(255) NOT NULL CHECK (length(trim(institution)) > 0), - period VARCHAR(100) NOT NULL CHECK (length(trim(period)) > 0), - specialization VARCHAR(255) NOT NULL CHECK (length(trim(specialization)) > 0) + degree VARCHAR(255) NOT NULL CHECK (trim(degree) <> ''), + title VARCHAR(255) NOT NULL CHECK (trim(title) <> ''), + institution VARCHAR(255) NOT NULL CHECK (trim(institution) <> ''), + period VARCHAR(100) NOT NULL CHECK (trim(period) <> ''), + specialization VARCHAR(255) NOT NULL CHECK (trim(specialization) <> '') ); CREATE TABLE education_skills ( education_id UUID NOT NULL, - skill VARCHAR(150) NOT NULL CHECK (length(trim(skill)) > 0), + skill VARCHAR(150) NOT NULL CHECK (trim(skill) <> ''), PRIMARY KEY (education_id, skill), @@ -38,7 +38,7 @@ CREATE TABLE education_skills ( CREATE TABLE education_architectures ( education_id UUID NOT NULL, - architecture VARCHAR(150) NOT NULL CHECK (length(trim(architecture)) > 0), + architecture VARCHAR(150) NOT NULL CHECK (trim(architecture) <> ''), PRIMARY KEY (education_id, architecture), @@ -50,15 +50,15 @@ CREATE TABLE education_architectures ( CREATE TABLE experiences ( id UUID PRIMARY KEY DEFAULT gen_random_uuid(), - title VARCHAR(255) NOT NULL CHECK (length(trim(title)) > 0), - company VARCHAR(255) NOT NULL CHECK (length(trim(company)) > 0), - period VARCHAR(100) NOT NULL CHECK (length(trim(period)) > 0), - icon VARCHAR(50) NOT NULL CHECK (length(trim(icon)) > 0) + title VARCHAR(255) NOT NULL CHECK (trim(title) <> ''), + company VARCHAR(255) NOT NULL CHECK (trim(company) <> ''), + period VARCHAR(100) NOT NULL CHECK (trim(period) <> ''), + icon VARCHAR(50) NOT NULL CHECK (trim(icon) <> '') ); CREATE TABLE experience_bullets ( experience_id UUID NOT NULL, - bullet VARCHAR(150) NOT NULL CHECK (length(trim(bullet)) > 0), + bullet VARCHAR(150) NOT NULL CHECK (trim(bullet) <> ''), PRIMARY KEY (experience_id, bullet), @@ -70,7 +70,7 @@ CREATE TABLE experience_bullets ( CREATE TABLE experience_technologies ( experience_id UUID NOT NULL, - technology VARCHAR(150) NOT NULL CHECK (length(trim(technology)) > 0), + technology VARCHAR(150) NOT NULL CHECK (trim(technology) <> ''), PRIMARY KEY (experience_id, technology), @@ -82,26 +82,26 @@ CREATE TABLE experience_technologies ( CREATE TABLE messages ( id UUID PRIMARY KEY DEFAULT gen_random_uuid(), - username VARCHAR(150) NOT NULL CHECK (length(trim(username)) > 0), - email VARCHAR(255) NOT NULL CHECK (length(trim(email)) > 0) CHECK (position('@' in email) > 1), - subject VARCHAR(255) NOT NULL CHECK (length(trim(subject)) > 0), - message TEXT NOT NULL CHECK (length(trim(message)) > 0), + username VARCHAR(150) NOT NULL CHECK (trim(username) <> ''), + email VARCHAR(255) NOT NULL CHECK (trim(email) <> '') CHECK (position('@' in email) > 1), + subject VARCHAR(255) NOT NULL CHECK (trim(subject) <> ''), + message TEXT NOT NULL CHECK (trim(message) <> ''), timestamp TIMESTAMP NOT NULL, status_message status_message_enum NOT NULL ); CREATE TABLE projects ( id UUID PRIMARY KEY DEFAULT gen_random_uuid(), - title VARCHAR(255) NOT NULL CHECK (length(trim(title)) > 0), - subtitle VARCHAR(255) NOT NULL CHECK (length(trim(subtitle)) > 0), - description VARCHAR(255) NOT NULL CHECK (length(trim(description)) > 0), + title VARCHAR(255) NOT NULL CHECK (trim(title) <> ''), + subtitle VARCHAR(255) NOT NULL CHECK (trim(subtitle) <> ''), + description VARCHAR(255) NOT NULL CHECK (trim(description) <> ''), codeSnippet VARCHAR(200), icon VARCHAR(50) ); CREATE TABLE project_technologies ( project_id UUID NOT NULL, - technology VARCHAR(150) NOT NULL CHECK (length(trim(technology)) > 0), + technology VARCHAR(150) NOT NULL CHECK (trim(technology) <> ''), PRIMARY KEY (project_id, technology), @@ -118,7 +118,7 @@ CREATE TABLE stacks ( CREATE TABLE stack_technologies ( stack_id UUID NOT NULL, - technology VARCHAR(150) NOT NULL CHECK (length(trim(technology)) > 0), + technology VARCHAR(150) NOT NULL CHECK (trim(technology) <> ''), PRIMARY KEY (stack_id, technology), @@ -130,22 +130,22 @@ CREATE TABLE stack_technologies ( CREATE TABLE stats ( id UUID PRIMARY KEY DEFAULT gen_random_uuid(), - yearsExperience VARCHAR(10) NOT NULL CHECK (length(trim(yearsExperience)) > 0), - systemDeployed VARCHAR(10) NOT NULL CHECK (length(trim(systemDeployed)) > 0), - uptimeSLA VARCHAR(15) NOT NULL CHECK (length(trim(uptimeSLA)) > 0), - commitsLogged VARCHAR(10) NOT NULL CHECK (length(trim(commitsLogged)) > 0), - status VARCHAR(10) NOT NULL CHECK (length(trim(status)) > 0), - objective VARCHAR(10) NOT NULL CHECK (length(trim(objective)) > 0) + yearsExperience VARCHAR(10) NOT NULL CHECK (trim(yearsExperience) <> ''), + systemDeployed VARCHAR(10) NOT NULL CHECK (trim(systemDeployed) <> ''), + uptimeSLA VARCHAR(15) NOT NULL CHECK (trim(uptimeSLA) <> ''), + commitsLogged VARCHAR(10) NOT NULL CHECK (trim(commitsLogged) <> ''), + status VARCHAR(10) NOT NULL CHECK (trim(status) <> ''), + objective VARCHAR(10) NOT NULL CHECK (trim(objective) <> '') ); CREATE TABLE users ( id UUID PRIMARY KEY DEFAULT gen_random_uuid(), - username VARCHAR(15) UNIQUE NOT NULL CHECK (length(trim(username)) > 0), - name VARCHAR(15) NOT NULL CHECK (length(trim(name)) > 0), - last_name VARCHAR(15) NOT NULL CHECK (length(trim(last_name)) > 0), - email VARCHAR(255) UNIQUE NOT NULL CHECK (length(trim(email)) > 0) CHECK (position('@' in email) > 1), + username VARCHAR(15) UNIQUE NOT NULL CHECK (trim(username) <> ''), + name VARCHAR(15) NOT NULL CHECK (trim(name) <> ''), + last_name VARCHAR(15) NOT NULL CHECK (trim(last_name) <> ''), + email VARCHAR(255) UNIQUE NOT NULL CHECK (trim(email) <> '') CHECK (position('@' in email) > 1), role role_enum NOT NULL, - password VARCHAR(255) NOT NULL CHECK (length(trim(password)) > 0) + password VARCHAR(255) NOT NULL CHECK (trim(password) <> '') ); -- Índices diff --git a/k8s/backend/deployment.yaml b/k8s/backend/deployment.yaml index 030b84a..5548b85 100644 --- a/k8s/backend/deployment.yaml +++ b/k8s/backend/deployment.yaml @@ -14,6 +14,8 @@ spec: metadata: labels: app: flima-backend + annotations: + rollout-trigger: "2026-05-06" spec: automountServiceAccountToken: false containers: diff --git a/k8s/frontend/deployment.yaml b/k8s/frontend/deployment.yaml index 7ffbbbf..20db2bf 100644 --- a/k8s/frontend/deployment.yaml +++ b/k8s/frontend/deployment.yaml @@ -14,6 +14,8 @@ spec: metadata: labels: app: flima-frontend + annotations: + rollout-trigger: "2026-05-06" spec: automountServiceAccountToken: false containers: