Spring boot upgraded to version 3.2.2 #36
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
#file: noinspection YAMLSchemaValidation | |
name: ds-deliver | |
on: | |
push: | |
branches: [ "main", "CI-CD" ] | |
pull_request: | |
branches: [ "main" ] | |
env: | |
JAVA_VERSION: 21 | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v3.3.0 | |
- uses: actions/setup-java@v3.10.0 | |
with: | |
java-version: ${{ env.JAVA_VERSION }} | |
distribution: temurin | |
- name: Build and Test with Maven | |
run: | | |
./mvnw clean verify -Dspring.profiles.active=test | |
- name: Check Test Status | |
id: check-test-status | |
run: | | |
if grep -q "BUILD FAILURE" target/surefire-reports/*.txt; then | |
echo "Tests failed." | |
exit 1 | |
else | |
echo "Tests passed." | |
fi | |
- name: Build artifact | |
if: steps.check-test-status.outcome == 'success' | |
run: | | |
./mvnw --no-transfer-progress clean package -DskipTests -P prod | |
- name: Docker Login | |
if: steps.check-test-status.outcome == 'success' | |
uses: docker/login-action@v2.1.0 | |
with: | |
username: lucianobrum | |
password: ${{ secrets.PWD_DOCKER_HUB }} | |
- name: Build and push Docker images | |
if: steps.check-test-status.outcome == 'success' | |
uses: docker/build-push-action@v4.0.0 | |
with: | |
context: . | |
file: ./Dockerfile | |
push: true | |
tags: lucianobrum/dsdeliver:${{github.ref_name}}, lucianobrum/dsdeliver:latest | |
- uses: actions/checkout@master | |
- name: copy file via ssh password | |
if: steps.check-test-status.outcome == 'success' | |
uses: appleboy/scp-action@master | |
with: | |
host: ${{ secrets.HOST }} | |
username: ${{ secrets.USERNAME }} | |
key: ${{ secrets.KEY }} | |
port: ${{ secrets.PORT }} | |
source: "./docker-compose.yml" | |
target: "/home/ubuntu/dsdeliver" | |
deploy: | |
needs: build | |
runs-on: ubuntu-latest | |
steps: | |
- name: deploy aws ec2 | |
uses: appleboy/ssh-action@v0.1.7 | |
with: | |
host: ${{ secrets.HOST }} | |
username: ${{ secrets.USERNAME }} | |
key: ${{ secrets.KEY }} | |
port: ${{ secrets.PORT }} | |
script: | | |
cd /home/ubuntu/dsdeliver | |
sudo docker compose down | |
sudo docker system prune -a -f | |
sudo docker compose build | |
sudo docker compose up -d |