Update main.yml #3
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 Workflow | |
| on: | |
| push: | |
| branches: | |
| - main | |
| workflow_dispatch: # Allows manual triggering of the workflow | |
| # Sets permissions of the GITHUB_TOKEN to allow deployment to GitHub Pages | |
| permissions: | |
| contents: read | |
| pages: write | |
| id-token: write | |
| # Allow only one concurrent deployment, and do NOT cancel in-progress runs | |
| concurrency: | |
| group: "pages" | |
| cancel-in-progress: false | |
| jobs: | |
| build: | |
| name: Build | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v3 | |
| - name: Set up JDK | |
| uses: actions/setup-java@v3 | |
| with: | |
| distribution: 'temurin' | |
| java-version: '17' | |
| - name: Build with Maven | |
| run: mvn compile | |
| test: | |
| name: Test | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v3 | |
| - name: Set up JDK | |
| uses: actions/setup-java@v3 | |
| with: | |
| distribution: 'temurin' | |
| java-version: '17' | |
| - name: Run Tests | |
| run: mvn clean test | |
| - name: Upload Test Results | |
| uses: actions/upload-artifact@v3 | |
| with: | |
| name: surefire-reports | |
| path: target/surefire-reports/ | |
| - name: Upload Coverage Report | |
| uses: actions/upload-artifact@v3 | |
| with: | |
| name: jacoco-report | |
| path: target/jacoco/coverage-reports/jacoco.xml | |
| package: | |
| name: Package | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v3 | |
| - name: Set up JDK | |
| uses: actions/setup-java@v3 | |
| with: | |
| distribution: 'temurin' | |
| java-version: '17' | |
| - name: Build Package | |
| run: mvn clean package | |
| - name: Upload Package | |
| uses: actions/upload-artifact@v3 | |
| with: | |
| name: packaged-app | |
| path: target/idatt2002demo-1.0-SNAPSHOT-jar-with-dependencies.jar | |
| deployPages: | |
| environment: | |
| name: github-pages | |
| url: ${{ steps.deployment.outputs.page_url }} | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v3 | |
| - name: Set up JDK | |
| uses: actions/setup-java@v3 | |
| with: | |
| distribution: 'temurin' | |
| java-version: '17' | |
| - name: Generate Javadoc | |
| run: | | |
| mvn clean package | |
| mvn javadoc:javadoc | |
| cp -rf target/site/* page/ | |
| cp -rf target/jacoco/* page/ | |
| - name: Setup Pages | |
| uses: actions/configure-pages@v5 | |
| - name: Upload index.html | |
| uses: actions/upload-pages-artifact@v3 | |
| with: | |
| path: 'page/' | |
| - name: Deploy to GitHub Pages | |
| id: deployment | |
| uses: actions/deploy-pages@v4 |