Merge pull request #1 from surya/patch-1-added-initial-workflow #1
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 Pipeline | |
| on: | |
| push: | |
| branches: | |
| - main | |
| workflow_dispatch: # For manual triggers | |
| jobs: | |
| build: | |
| name: Build | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v3 | |
| - name: Set up Maven | |
| uses: actions/setup-java@v3 | |
| with: | |
| distribution: 'temurin' | |
| java-version: '17' | |
| - name: Compile Project | |
| run: mvn compile | |
| test: | |
| name: Test | |
| runs-on: ubuntu-latest | |
| services: | |
| docker: | |
| image: docker:20.10-dind | |
| options: --privileged | |
| env: | |
| DOCKER_HOST: tcp://localhost:2375 | |
| DOCKER_TLS_CERTDIR: "" | |
| DOCKER_DRIVER: overlay2 | |
| steps: | |
| - uses: actions/checkout@v3 | |
| - name: Set up Maven | |
| uses: actions/setup-java@v3 | |
| with: | |
| distribution: 'temurin' | |
| java-version: '17' | |
| - name: Run Tests | |
| run: | | |
| mvn clean test | |
| mkdir -p artifacts/junit | |
| cp target/surefire-reports/*.xml artifacts/junit/ | |
| mkdir -p artifacts/coverage | |
| cp target/jacoco/coverage-reports/*.xml artifacts/coverage/ | |
| - name: Upload Test Results | |
| uses: actions/upload-artifact@v3 | |
| with: | |
| name: junit-reports | |
| path: artifacts/junit | |
| - name: Upload Coverage Reports | |
| uses: actions/upload-artifact@v3 | |
| with: | |
| name: coverage-reports | |
| path: artifacts/coverage | |
| package: | |
| name: Package | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v3 | |
| - name: Set up Maven | |
| uses: actions/setup-java@v3 | |
| with: | |
| distribution: 'temurin' | |
| java-version: '17' | |
| - name: Package Project | |
| run: mvn clean package | |
| - name: Upload JAR | |
| uses: actions/upload-artifact@v3 | |
| with: | |
| name: packaged-jar | |
| path: target/idatt2002demo-1.0-SNAPSHOT-jar-with-dependencies.jar | |
| generate-pdf: | |
| name: Generate PDF | |
| runs-on: ubuntu-20.04 | |
| if: github.event_name == 'workflow_dispatch' | |
| steps: | |
| - name: Install Dependencies | |
| run: | | |
| sudo apt-get update | |
| sudo apt-get install -y wget fontconfig libfreetype6 libjpeg-turbo8 libpng16-16 libx11-6 libxcb1 libxext6 libxrender1 xfonts-75dpi xfonts-base | |
| sudo apt-get install -y nodejs npm git | |
| wget https://github.com/wkhtmltopdf/packaging/releases/download/0.12.6-1/wkhtmltox_0.12.6-1.focal_amd64.deb | |
| sudo dpkg -i wkhtmltox_0.12.6-1.focal_amd64.deb | |
| npm install -g github-wikito-converter | |
| - name: Clone Wiki Repository | |
| run: | | |
| git clone https://<USERNAME>:<TOKEN>@github.com/<ORG>/<REPO>.wiki.git | |
| gwtc <REPO>.wiki | |
| - name: Convert to PDF | |
| run: wkhtmltopdf documentation.html wiki.pdf | |
| - name: Upload PDF | |
| uses: actions/upload-artifact@v3 | |
| with: | |
| name: wiki-pdf | |
| path: wiki.pdf | |
| deploy-pages: | |
| name: Deploy Pages | |
| runs-on: ubuntu-latest | |
| if: github.event_name == 'workflow_dispatch' | |
| steps: | |
| - uses: actions/checkout@v3 | |
| - name: Set up Maven | |
| uses: actions/setup-java@v3 | |
| with: | |
| distribution: 'temurin' | |
| java-version: '17' | |
| - name: Generate Javadoc and Pages | |
| run: | | |
| mvn clean package | |
| mvn javadoc:javadoc | |
| mkdir -p public/apidocs | |
| cp -r target/site/apidocs/* public/apidocs/ | |
| cp -r target/jacoco/* public/ | |
| cp -r page/index.html public/ | |
| - name: Deploy to GitHub Pages | |
| uses: actions/upload-pages-artifact@v1 | |
| with: | |
| path: public | |
| - name: Publish Pages | |
| uses: actions/deploy-pages@v1 | |
| with: | |
| token: ${{ secrets.GITHUB_TOKEN }} |