Skip to content

fix (Back) [MASTER] Update Question endpoint #42

fix (Back) [MASTER] Update Question endpoint

fix (Back) [MASTER] Update Question endpoint #42

Workflow file for this run

name: CI/CD with GitHub Actions, Maven, Qodana, and Docker
on:
workflow_dispatch:
pull_request:
push:
branches:
- '**' # Triggers on any branch
jobs:
# Step 1: Checkout code
checkout-qcmplus:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v3
# Step 2: Qodana Scan
qodana-qcmplus:
needs: checkout-qcmplus
runs-on: ubuntu-latest
continue-on-error: true
permissions:
contents: write
pull-requests: write
checks: write
steps:
- name: Checkout code
uses: actions/checkout@v3
with:
ref: ${{ github.event.pull_request.head.sha }}
fetch-depth: 0
- name: Set up JDK 17
uses: actions/setup-java@v3
with:
java-version: '17'
distribution: 'adopt'
- name: Qodana Scan Backend
uses: JetBrains/qodana-action@v2024.1
with:
project-dir: ./ # Specify the backend directory
env:
QODANA_TOKEN: ${{ secrets.QODANA_TOKEN }}
- name: Qodana Scan Frontend (qcmplusweb)
uses: JetBrains/qodana-action@v2024.1
with:
project-dir: ./qcmplusweb # Specify the frontend directory
env:
QODANA_TOKEN: ${{ secrets.QODANA_TOKEN }}
# Step 3: Build Backend (qcmplus)
build-qcmplusapp:
needs: [ checkout-qcmplus, qodana-qcmplus ]
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v3
- name: Set up JDK 17
uses: actions/setup-java@v3
with:
java-version: '17'
distribution: 'adopt'
- name: Build with Maven
run: mvn -B package --file pom.xml
# Step 4: Build Frontend (qcmplus-web)
build-qcmplusweb:
needs: build-qcmplusapp
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v3
- name: Install Node.js
uses: actions/setup-node@v3
with:
node-version: '18'
- name: Install dependencies
run: npm install --prefix qcmplusweb
- name: Build
run: npm run build --prefix qcmplusweb
# Step 5: Test Backend (qcmplus)
test-qcmplusapp:
needs: build-qcmplusapp
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v3
- name: Set up JDK 17
uses: actions/setup-java@v3
with:
java-version: '17'
distribution: 'adopt'
- name: Run Backend Tests
run: mvn test --file pom.xml
# Step 6: Test Frontend (qcmplus-web)
test-qcmplusweb:
needs: build-qcmplusweb
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v3
- name: Install Node.js
uses: actions/setup-node@v3
with:
node-version: '18'
- name: Install dependencies
run: npm install --prefix qcmplusweb
- name: Run Frontend Tests
run: npm test --prefix qcmplusweb
# Step 7: Build Docker Image and Push to Docker Hub
deploy-qcmplus:
if: github.ref == 'refs/heads/master'
needs: [ test-qcmplusapp, test-qcmplusweb ]
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v3
- name: Log in to Docker Hub
uses: docker/login-action@v2
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}
- name: Extract Git metadata
id: vars
run: |
echo "BRANCH_NAME=${GITHUB_REF#refs/heads/}" >> $GITHUB_ENV
echo "COMMIT_SHA=${GITHUB_SHA::7}" >> $GITHUB_ENV
- name: Build Docker image
run: docker build -t teclit/qcmplus:${{ env.BRANCH_NAME }}-${{ env.COMMIT_SHA }} .
- name: Tag Docker image as latest
run: docker tag teclit/qcmplus:${{ env.BRANCH_NAME }}-${{ env.COMMIT_SHA }} teclit/qcmplus:latest
- name: Push Docker image to Docker Hub with dynamic tag
run: docker push teclit/qcmplus:${{ env.BRANCH_NAME }}-${{ env.COMMIT_SHA }}
- name: Push Docker image to Docker Hub with latest tag
run: docker push teclit/qcmplus:latest