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 for Java Project | |
on: | |
pull_request: | |
branches: | |
- main | |
jobs: | |
test: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v2 | |
- name: Set up JDK 17 | |
uses: actions/setup-java@v2 | |
with: | |
distribution: 'temurin' | |
java-version: '17' | |
- name: Install dependencies and run tests | |
run: mvn install -B | |
- name: Run tests | |
run: mvn test --no-transfer-progress | |
javadoc: | |
runs-on: ubuntu-latest | |
needs: test | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v2 | |
- name: Set up JDK 17 | |
uses: actions/setup-java@v2 | |
with: | |
distribution: 'temurin' | |
java-version: '17' | |
- name: Generate Javadoc | |
run: mvn javadoc:javadoc --no-transfer-progress | |
- name: Verify Javadoc | |
run: | | |
if [ ! -d target/site/apidocs ]; then | |
echo "Javadoc failed to compile!" | |
exit 1 | |
fi | |
deploy: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout repository | |
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 | |
run: mvn javadoc:javadoc --no-transfer-progress | |
- name: Push Javadoc to GitHub Pages | |
run: | | |
git config user.name "github-actions[bot]" | |
git config user.email "github-actions[bot]@users.noreply.github.com" | |
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" |