:wrecnh: ec2 pipe #58
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: Java CI with Maven | |
on: | |
push: | |
branches: | |
- developer | |
pull_request: | |
branches: | |
- main | |
jobs: | |
unit-test: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Check out the code | |
uses: actions/checkout@v2 | |
- name: Set up JDK 17 | |
uses: actions/setup-java@v2 | |
with: | |
java-version: '17' | |
distribution: 'adopt' | |
- name: Build with Maven | |
run: mvn clean install | |
- name: Run Tests with JUnit and JaCoCo | |
run: mvn test jacoco:report | |
- name: Publish JaCoCo Report | |
if: success() # Only run if previous steps succeeded | |
run: | | |
if [ -d target/site/jacoco ]; then | |
mkdir -p coverage | |
cp -r target/site/jacoco/* coverage/ | |
echo "JaCoCo report generated at: coverage/index.html" | |
else | |
echo "JaCoCo report directory does not exist." | |
fi | |
- name: Upload JaCoCo report | |
if: success() # Only run if previous steps succeeded | |
uses: actions/upload-artifact@v3 | |
with: | |
name: jacoco-report | |
path: coverage | |
build: | |
runs-on: ubuntu-latest | |
needs: unit-test | |
steps: | |
- name: Check out code | |
uses: actions/checkout@v2 | |
- name: Set up JDK 17 | |
uses: actions/setup-java@v2 | |
with: | |
java-version: '17' | |
distribution: 'adopt' | |
- name: Build with Maven | |
run: mvn clean install | |
- name: Run tests | |
run: mvn test | |
publish: | |
runs-on: ubuntu-latest | |
needs: build | |
if: github.ref == 'refs/heads/main' | |
steps: | |
- name: Check out code | |
uses: actions/checkout@v2 | |
- name: Set up JDK 17 | |
uses: actions/setup-java@v2 | |
with: | |
java-version: '17' | |
distribution: 'adopt' | |
- name: Set up Docker Buildx | |
uses: docker/setup-buildx-action@v1 | |
with: | |
version: v0.7.0 | |
- name: Build the Docker image | |
run: docker build -t migprogrammer/neighborfood-clean:latest . | |
- name: Log into Docker Hub | |
run: docker login -u migprogrammer -p ${{secrets.DOCKERHUB_TOKEN}} | |
- name: Push image to Docker Hub | |
run: docker push migprogrammer/neighborfood-clean:latest |