From 4bc15d55b5b7ddcaef733ed6ff88588b176e48df Mon Sep 17 00:00:00 2001 From: Gabriel Goulis Date: Mon, 23 Sep 2024 19:32:10 -0500 Subject: [PATCH 1/4] Remove output directory for javadoc --- .github/workflows/main.yml | 50 +++++++++++++------------------------- pom.xml | 2 ++ 2 files changed, 19 insertions(+), 33 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 9b79e39a..afc5c488 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -26,7 +26,7 @@ jobs: javadoc: runs-on: ubuntu-latest - needs: test # Ensures the javadoc phase runs only after the test phase succeeds + needs: test # Ensures the javadoc job runs after tests pass steps: - name: Checkout code uses: actions/checkout@v2 @@ -38,46 +38,30 @@ jobs: java-version: '17' - name: Generate Javadoc - run: mvn javadoc:javadoc --no-transfer-progress -DadditionalJOption=-Xdoclint:none # Ignore warnings + run: mvn javadoc:javadoc --no-transfer-progress - name: Verify Javadoc run: | - if [ -d target/site/apidocs ]; then - echo "Javadoc generated successfully." - else - echo "Javadoc failed to generate!" - exit 1 - fi + if [ -d docs/apidocs ]; then + echo "Javadoc generated successfully." + else + echo "Javadoc failed to generate!" + exit 1 + fi - update-docs: + deploy: runs-on: ubuntu-latest - needs: [test, javadoc] # This ensures that deploy phase runs only after both test and javadoc phases succeed - if: github.event.pull_request.merged == true # Ensures this runs only when the PR is merged + needs: javadoc # Ensures deploy runs only after Javadoc is generated + if: github.ref == 'refs/heads/main' # Deploy only on push to main + steps: - name: Checkout code uses: actions/checkout@v2 - - name: Set up SSH for deploy key - run: | - mkdir -p ~/.ssh - echo "${{ secrets.DEPLOY_KEY }}" > ~/.ssh/deploy_key - chmod 600 ~/.ssh/deploy_key - ssh-keyscan github.com >> ~/.ssh/known_hosts - env: - SSH_AUTH_SOCK: /tmp/ssh_agent.sock - - - name: Generate Javadoc + - name: Generate Javadoc for deploy run: mvn javadoc:javadoc --no-transfer-progress - - name: Deploy docs to GitHub Pages - run: | - git config user.name "github-actions[bot]" - git config user.email "github-actions[bot]@users.noreply.github.com" - git remote set-url origin git@github.com:${{ github.repository }}.git - rm -rf docs/apidocs - mv target/site/apidocs docs/apidocs - git add docs/apidocs - git commit -m "Update Javadoc" - git push origin main - env: - GIT_SSH_COMMAND: "ssh -i ~/.ssh/deploy_key -o IdentitiesOnly=yes" + - name: Deploy to GitHub Pages + uses: actions/deploy-pages@v1 # GitHub Pages deploy action + with: + publish_dir: ./docs # Javadoc output folder diff --git a/pom.xml b/pom.xml index b22175cc..7b955156 100644 --- a/pom.xml +++ b/pom.xml @@ -157,6 +157,8 @@ 3.4.1 private + ./docs + ./docs common From 6ede3b6cbbca3c07dad456ca95150f64b96a73b5 Mon Sep 17 00:00:00 2001 From: Gabriel Goulis Date: Mon, 23 Sep 2024 19:35:48 -0500 Subject: [PATCH 2/4] Final main.yml --- .github/workflows/main.yml | 14 +------------- 1 file changed, 1 insertion(+), 13 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index afc5c488..0723690c 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -49,19 +49,7 @@ jobs: exit 1 fi - deploy: - runs-on: ubuntu-latest - needs: javadoc # Ensures deploy runs only after Javadoc is generated - if: github.ref == 'refs/heads/main' # Deploy only on push to main - - steps: - - name: Checkout code - uses: actions/checkout@v2 - - - name: Generate Javadoc for deploy - run: mvn javadoc:javadoc --no-transfer-progress - - name: Deploy to GitHub Pages uses: actions/deploy-pages@v1 # GitHub Pages deploy action with: - publish_dir: ./docs # Javadoc output folder + publish_dir: ./docs # Javadoc output folder \ No newline at end of file From 9391c2a1af2c44ee388fa86922296f2a1864bed9 Mon Sep 17 00:00:00 2001 From: Gabriel Goulis Date: Mon, 23 Sep 2024 19:38:42 -0500 Subject: [PATCH 3/4] Final main.yml --- .github/workflows/main.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 0723690c..234eb47d 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -27,6 +27,9 @@ jobs: javadoc: runs-on: ubuntu-latest needs: test # Ensures the javadoc job runs after tests pass + permissions: + pages: write # Grant permission to deploy to GitHub Pages + id-token: write # Required for GitHub Pages deployment steps: - name: Checkout code uses: actions/checkout@v2 From de7412f16829920106e0619929b37d9f5c0546f7 Mon Sep 17 00:00:00 2001 From: Gabriel Goulis Date: Mon, 23 Sep 2024 19:47:02 -0500 Subject: [PATCH 4/4] Final main.yml --- .github/workflows/main.yml | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 234eb47d..891c8862 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -5,6 +5,10 @@ on: branches: - main +permissions: + pages: write # Grant permission to deploy to GitHub Pages + id-token: write # Required for GitHub Pages deployment + jobs: test: runs-on: ubuntu-latest @@ -27,9 +31,7 @@ jobs: javadoc: runs-on: ubuntu-latest needs: test # Ensures the javadoc job runs after tests pass - permissions: - pages: write # Grant permission to deploy to GitHub Pages - id-token: write # Required for GitHub Pages deployment + steps: - name: Checkout code uses: actions/checkout@v2 @@ -52,7 +54,10 @@ jobs: exit 1 fi - - name: Deploy to GitHub Pages - uses: actions/deploy-pages@v1 # GitHub Pages deploy action + - name: Upload artifact + uses: actions/upload-pages-artifact@v3 with: - publish_dir: ./docs # Javadoc output folder \ No newline at end of file + path: './docs' + + - name: Deploy to GitHub Pages + uses: actions/deploy-pages@v4 # GitHub Pages deploy action