|
| 1 | +# Deploy Javadoc to GitHub Pages |
| 2 | + |
| 3 | +This GitHub Action automates the deployment of Javadoc documentation to GitHub Pages. It builds your Java project, generates Javadoc, and publishes it to a GitHub Pages branch. |
| 4 | + |
| 5 | +## Features |
| 6 | + |
| 7 | +- **Automatic Javadoc Generation**: Builds the project and generates Javadoc documentation. |
| 8 | +- **Customizable Branch**: Publish Javadoc to a specified GitHub Pages branch. |
| 9 | +- **JDK Configuration**: Supports multiple JDK versions and distributions. |
| 10 | +- **Test Skipping**: Option to skip tests during the build process. |
| 11 | +- **Branch Cleanup**: Option to clean up old branches before publishing. |
| 12 | + |
| 13 | +## Inputs |
| 14 | + |
| 15 | +### `GITHUB_TOKEN` |
| 16 | +- **Description**: GitHub token used for repository access and authentication. |
| 17 | +- **Required**: Yes |
| 18 | + |
| 19 | +### `CLEANUP_BRANCH` |
| 20 | +- **Description**: Whether to clean up old branches. Set to `'true'` to delete the old branch before publishing. Defaults to `'false'`. |
| 21 | +- **Required**: No |
| 22 | +- **Default**: `'false'` |
| 23 | + |
| 24 | +### `BRANCH` |
| 25 | +- **Description**: The name of the branch where the Javadoc documentation will be published. Defaults to `'gh-pages'`. |
| 26 | +- **Required**: No |
| 27 | +- **Default**: `'gh-pages'` |
| 28 | + |
| 29 | +### `JAVA_VERSION` |
| 30 | +- **Description**: The version of Java your project is using (e.g., 17). |
| 31 | +- **Required**: Yes |
| 32 | +- **Default**: `'17'` |
| 33 | + |
| 34 | +### `JAVA_DISTRIBUTION` |
| 35 | +- **Description**: The JDK distribution to use (e.g., `'adopt'`, `'zulu'`). Defaults to `'adopt'`. |
| 36 | +- **Required**: No |
| 37 | +- **Default**: `'adopt'` |
| 38 | + |
| 39 | +### `SKIP_TESTS` |
| 40 | +- **Description**: Whether to skip tests during the build process. Set to `'true'` to skip tests, `'false'` otherwise. |
| 41 | +- **Required**: No |
| 42 | +- **Default**: `'false'` |
| 43 | + |
| 44 | +### `DOC_DIRECTORY` |
| 45 | +- **Description**: The directory where the Javadoc documentation is generated. Defaults to `'target/reports/apidocs'`. |
| 46 | +- **Required**: No |
| 47 | +- **Default**: `'target/reports/apidocs'` |
| 48 | + |
| 49 | +## Usage |
| 50 | + |
| 51 | +To use this GitHub Action, create a workflow YAML file in your repository's `.github/workflows` directory. |
| 52 | + |
| 53 | +### Example Workflow |
| 54 | + |
| 55 | +Here’s an example workflow that builds the project, generates Javadoc, and publishes it to the `gh-pages` branch: |
| 56 | + |
| 57 | +```yaml |
| 58 | +name: Deploy Javadoc to GitHub Pages |
| 59 | + |
| 60 | +on: |
| 61 | + push: |
| 62 | + branches: |
| 63 | + - main |
| 64 | + |
| 65 | +jobs: |
| 66 | + deploy-javadoc: |
| 67 | + runs-on: ubuntu-latest |
| 68 | + |
| 69 | + steps: |
| 70 | + - name: Check out the repository |
| 71 | + uses: actions/checkout@v4 |
| 72 | + |
| 73 | + - name: Deploy Javadoc |
| 74 | + uses: DashioDevs/action-javadocs-deploy@v1 |
| 75 | + with: |
| 76 | + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 77 | + JAVA_VERSION: '17' |
| 78 | + JAVA_DISTRIBUTION: 'adopt' |
| 79 | + SKIP_TESTS: 'false' |
| 80 | + DOC_DIRECTORY: 'target/reports/apidocs' |
| 81 | + BRANCH: 'gh-pages' |
| 82 | + CLEANUP_BRANCH: 'false' |
| 83 | +``` |
| 84 | +
|
| 85 | +### Example with Branch Cleanup |
| 86 | +
|
| 87 | +If you want to clean up old branches before publishing, set the CLEANUP_BRANCH input to 'true': |
| 88 | +
|
| 89 | +```yaml |
| 90 | +name: Deploy Javadoc to GitHub Pages |
| 91 | + |
| 92 | +on: |
| 93 | + push: |
| 94 | + branches: |
| 95 | + - main |
| 96 | + |
| 97 | +jobs: |
| 98 | + deploy-javadoc: |
| 99 | + runs-on: ubuntu-latest |
| 100 | + |
| 101 | + steps: |
| 102 | + - name: Check out the repository |
| 103 | + uses: actions/checkout@v4 |
| 104 | + |
| 105 | + - name: Deploy Javadoc |
| 106 | + uses: DashioDevs/action-javadocs-deploy@v1 |
| 107 | + with: |
| 108 | + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 109 | + JAVA_VERSION: '17' |
| 110 | + JAVA_DISTRIBUTION: 'adopt' |
| 111 | + SKIP_TESTS: 'false' |
| 112 | + DOC_DIRECTORY: 'target/reports/apidocs' |
| 113 | + BRANCH: 'gh-pages' |
| 114 | + CLEANUP_BRANCH: 'true' |
| 115 | +``` |
0 commit comments