QCMPLUS-40 : update display AnswersList and delete unused import #21
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v3 | |
# Step 2: Qodana Scan | |
qodana: | |
needs: checkout | |
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 | |
uses: JetBrains/qodana-action@v2024.1 | |
env: | |
QODANA_TOKEN: ${{ secrets.QODANA_TOKEN }} | |
# Step 3: Build Backend (qcmplus) | |
build-backend: | |
needs: [checkout, qodana] | |
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-frontend: | |
needs: build-backend | |
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-backend: | |
needs: build-backend | |
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-frontend: | |
needs: build-frontend | |
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: | |
if: github.ref == 'refs/heads/master' | |
needs: [test-backend, test-frontend] | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v3 | |
- name: Log in to Docker Hub | |
run: echo ${{ secrets.DOCKER_PASSWORD }} | docker login -u ${{ secrets.DOCKER_USERNAME }} --password-stdin | |
- 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 |