site_v1.1 #5
This file contains hidden or 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: Build Java Showcase Website | |
| on: | |
| push: | |
| branches: [ main ] | |
| pull_request: | |
| branches: [ main ] | |
| workflow_dispatch: | |
| permissions: | |
| contents: read | |
| pages: write | |
| id-token: write | |
| concurrency: | |
| group: "pages" | |
| cancel-in-progress: false | |
| jobs: | |
| build: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@v4 | |
| - name: Set up JDK 17 | |
| uses: actions/setup-java@v4 | |
| with: | |
| java-version: '17' | |
| distribution: 'temurin' | |
| - name: Create output directory | |
| run: mkdir -p docs | |
| - name: Compile all Java projects | |
| run: | | |
| echo "Compiling Java projects..." | |
| # Compile Cerchio | |
| if [ -d "Cerchio/src" ]; then | |
| javac -d Cerchio/bin Cerchio/src/*.java 2>&1 | tee docs/cerchio-compile.log || true | |
| fi | |
| # Compile mergeArray | |
| if [ -d "mergeArray/src" ]; then | |
| javac -d mergeArray/bin mergeArray/src/*.java 2>&1 | tee docs/mergearray-compile.log || true | |
| fi | |
| # Compile OggettoCD | |
| if [ -d "OggettoCD/src" ]; then | |
| javac -d OggettoCD/bin OggettoCD/src/*.java 2>&1 | tee docs/oggettocd-compile.log || true | |
| fi | |
| # Compile Punto | |
| if [ -d "Punto/src" ]; then | |
| javac -d Punto/bin Punto/src/*.java 2>&1 | tee docs/punto-compile.log || true | |
| fi | |
| # Compile Rettangolo | |
| if [ -d "Rettangolo/src" ]; then | |
| javac -d Rettangolo/bin Rettangolo/src/*.java 2>&1 | tee docs/rettangolo-compile.log || true | |
| fi | |
| # Compile vocalcount | |
| if [ -d "vocalcount/src" ]; then | |
| javac -d vocalcount/bin vocalcount/src/*.java 2>&1 | tee docs/vocalcount-compile.log || true | |
| fi | |
| - name: Run Java programs and capture output | |
| run: | | |
| echo "Running Java programs..." | |
| # Run Cerchio | |
| if [ -f "Cerchio/bin/Cerchio.class" ]; then | |
| cd Cerchio/bin && java Cerchio > ../../docs/cerchio-output.txt 2>&1 || echo "Error running Cerchio" > ../../docs/cerchio-output.txt | |
| cd ../.. | |
| fi | |
| # Run mergeArrays | |
| if [ -f "mergeArray/bin/mergeArrays.class" ]; then | |
| cd mergeArray/bin && java mergeArrays > ../../docs/mergearray-output.txt 2>&1 || echo "Error running mergeArrays" > ../../docs/mergearray-output.txt | |
| cd ../.. | |
| fi | |
| # Run Cd | |
| if [ -f "OggettoCD/bin/Cd.class" ]; then | |
| cd OggettoCD/bin && java Cd > ../../docs/oggettocd-output.txt 2>&1 || echo "Error running Cd" > ../../docs/oggettocd-output.txt | |
| cd ../.. | |
| fi | |
| # Run Punto | |
| if [ -f "Punto/bin/Punto.class" ]; then | |
| cd Punto/bin && java Punto > ../../docs/punto-output.txt 2>&1 || echo "Error running Punto" > ../../docs/punto-output.txt | |
| cd ../.. | |
| fi | |
| # Run Rettangolo | |
| if [ -f "Rettangolo/bin/Rettangolo.class" ]; then | |
| cd Rettangolo/bin && java Rettangolo > ../../docs/rettangolo-output.txt 2>&1 || echo "Error running Rettangolo" > ../../docs/rettangolo-output.txt | |
| cd ../.. | |
| fi | |
| # Run voc_count | |
| if [ -f "vocalcount/bin/voc_count.class" ]; then | |
| cd vocalcount/bin && java voc_count > ../../docs/vocalcount-output.txt 2>&1 || echo "Error running voc_count" > ../../docs/vocalcount-output.txt | |
| cd ../.. | |
| fi | |
| - name: Generate website | |
| run: python3 .github/scripts/generate-site.py | |
| - name: Upload artifact | |
| uses: actions/upload-pages-artifact@v3 | |
| with: | |
| path: docs | |
| deploy: | |
| if: github.ref == 'refs/heads/main' | |
| environment: | |
| name: github-pages | |
| url: ${{ steps.deployment.outputs.page_url }} | |
| runs-on: ubuntu-latest | |
| needs: build | |
| steps: | |
| - name: Deploy to GitHub Pages | |
| id: deployment | |
| uses: actions/deploy-pages@v4 |