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/[email protected] | |
- uses: actions/[email protected] | |
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/[email protected] | |
with: | |
username: lucianobrum | |
password: ${{ secrets.PWD_DOCKER_HUB }} | |
- name: Build and push Docker images | |
if: steps.check-test-status.outcome == 'success' | |
uses: docker/[email protected] | |
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/[email protected] | |
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 |