diff --git a/.github/workflows/build-production.yml b/.github/workflows/build-production.yml new file mode 100644 index 00000000..e7c83917 --- /dev/null +++ b/.github/workflows/build-production.yml @@ -0,0 +1,33 @@ +name: Build - Production Image + +on: + push: + tags: + - "v*.*.*" + +jobs: + build-prod: + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v5 + + - name: Set tag + run: echo "TAG=${GITHUB_REF_NAME}" >> $GITHUB_ENV + + - name: Login to registry + uses: docker/login-action@v3 + with: + registry: ghcr.io + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} + + - name: Build backend + run: | + docker build -t ghcr.io/${{ github.repository }}/backend:$TAG ./backend + docker push ghcr.io/${{ github.repository }}/backend:$TAG + + - name: Build frontend + run: | + docker build -t ghcr.io/${{ github.repository }}/frontend:$TAG ./frontend + docker push ghcr.io/${{ github.repository }}/frontend:$TAG \ No newline at end of file diff --git a/.github/workflows/cd-staging.yml b/.github/workflows/cd-staging.yml new file mode 100644 index 00000000..f8e4bb5d --- /dev/null +++ b/.github/workflows/cd-staging.yml @@ -0,0 +1,45 @@ +name: CD - Staging + +on: + push: + branches: + - develop + +jobs: + deploy-stage: + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v5 + + - name: Set image tag + id: meta + run: echo "TAG=stage-${GITHUB_SHA::7}" >> $GITHUB_ENV + + - name: Login to registry + uses: docker/login-action@v3 + with: + registry: ghcr.io + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} + + - name: Set image name + run: echo "IMAGE_NAME=$(echo '${{ github.repository }}' | tr '[:upper:]' '[:lower:]')" >> $GITHUB_ENV + + - name: Build backend image + run: | + docker build -t ghcr.io/$IMAGE_NAME/backend:$TAG . + docker push ghcr.io/$IMAGE_NAME/backend:$TAG + + - name: Deploy to staging server + uses: appleboy/ssh-action@v1 + with: + host: ${{ secrets.STAGE_SSH_HOST }} + username: ${{ secrets.STAGE_SSH_USER }} + key: ${{ secrets.STAGE_SSH_KEY }} + script: | + cd /opt/methodologist + echo "BACKEND_IMAGE_TAG=$TAG" > .deploy.env + echo "FRONTEND_IMAGE_TAG=$TAG" >> .deploy.env + docker compose --env-file .deploy.env pull + docker compose --env-file .deploy.env up -d \ No newline at end of file diff --git a/.github/workflows/deploy-production.yml b/.github/workflows/deploy-production.yml new file mode 100644 index 00000000..9fe32973 --- /dev/null +++ b/.github/workflows/deploy-production.yml @@ -0,0 +1,26 @@ +name: Deploy - Production (Manual) + +on: + workflow_dispatch: + inputs: + version: + description: "Production version tag (e.g. v0.1.7)" + required: true + +jobs: + deploy-prod: + runs-on: ubuntu-latest + + steps: + - name: Deploy to production + uses: appleboy/ssh-action@v1 + with: + host: ${{ secrets.PROD_SSH_HOST }} + username: ${{ secrets.PROD_SSH_USER }} + key: ${{ secrets.PROD_SSH_KEY }} + script: | + cd /opt/methodologist + echo "BACKEND_IMAGE_TAG=${{ github.event.inputs.version }}" > .deploy.env + echo "FRONTEND_IMAGE_TAG=${{ github.event.inputs.version }}" >> .deploy.env + docker compose --env-file .deploy.env pull + docker compose --env-file .deploy.env up -d \ No newline at end of file diff --git a/app/src/main/java/tools/vitruv/methodologist/vsum/service/VsumService.java b/app/src/main/java/tools/vitruv/methodologist/vsum/service/VsumService.java index 312af103..78137082 100644 --- a/app/src/main/java/tools/vitruv/methodologist/vsum/service/VsumService.java +++ b/app/src/main/java/tools/vitruv/methodologist/vsum/service/VsumService.java @@ -386,7 +386,6 @@ public byte[] getJarfat(String callerEmail, Long id) { .orElseThrow(() -> new AccessDeniedException(USER_DOSE_NOT_HAVE_ACCESS)); Vsum vsum = vsumUser.getVsum(); - if (vsum.getMetaModelRelations() == null || vsum.getMetaModelRelations().isEmpty()) { throw new NotFoundException(REACTION_FILE_IDS_ID_NOT_FOUND_ERROR); }