Fixed resources #2
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 and Run Java Files | |
| on: | |
| push: | |
| branches: | |
| - main | |
| pull_request: | |
| branches: | |
| - main | |
| workflow_dispatch: | |
| jobs: | |
| build-and-run: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v3 | |
| - name: Set up Java | |
| uses: actions/setup-java@v3 | |
| with: | |
| distribution: 'temurin' | |
| java-version: '21' | |
| - name: Compile all Java files | |
| run: | | |
| mkdir -p out | |
| javac -d out src/*.java | |
| cp -r src/resources out/ | |
| - name: Run each Java file and collect output | |
| run: | | |
| mkdir -p logs | |
| for file in src/*.java; do | |
| class_name=$(basename "${file}" .java) | |
| echo "Running $class_name..." | |
| java -cp out "$class_name" > logs/$class_name.log 2>&1 || echo "Execution failed for $class_name" >> logs/$class_name.log | |
| done | |
| - name: Upload logs | |
| uses: actions/upload-artifact@v3 | |
| with: | |
| name: java-output-logs | |
| path: logs/ |