Skip to content

[✨FEATURE] Adapt Swagger (#12) #3

[✨FEATURE] Adapt Swagger (#12)

[✨FEATURE] Adapt Swagger (#12) #3

Workflow file for this run

name: Deploy Spring Boot to EC2
on:
push:
branches:
- main
- develop
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v2
- name: Set up JDK 21
uses: actions/setup-java@v1
with:
java-version: '21'
- name: Build with Gradle
run: ./gradlew build
- name: List build/libs contents
run: ls -la build/libs
- name: Log in to Docker Hub
run: echo "${{ secrets.DOCKER_PASSWORD }}" | docker login -u "${{ secrets.DOCKER_USERNAME }}" --password-stdin
- name: Build Docker image
run: docker build -t ${{ secrets.DOCKER_USERNAME }}/the_monitor:latest .
- name: Push Docker image
run: docker push ${{ secrets.DOCKER_USERNAME }}/the_monitor:latest
deploy:
runs-on: ubuntu-latest
needs: build
steps:
- name: Connect to EC2 and deploy
uses: appleboy/ssh-action@master
with:
host: ${{ secrets.EC2_HOST }}
username: ec2-user
key: ${{ secrets.EC2_PRIVATE_KEY }}
script: |
docker pull ${{ secrets.DOCKER_USERNAME }}/the_monitor:latest
docker stop the_monitor-container || true
docker rm the_monitor-container || true
docker run -d -p 8080:8080 --name the_monitor-container \
-e SPRING_PROFILES_ACTIVE=prod \
-e SPRING_DATASOURCE_USERNAME=${{ secrets.SPRING_DATASOURCE_USERNAME }} \
-e SPRING_DATASOURCE_PASSWORD=${{ secrets.SPRING_DATASOURCE_PASSWORD }} \
-e SPRING_MAIL_HOST=smtp.gmail.com \
-e SPRING_MAIL_PORT=587 \
-e SPRING_MAIL_USERNAME=${{ secrets.SPRING_MAIL_USERNAME }} \
-e SPRING_MAIL_PASSWORD=${{ secrets.SPRING_MAIL_PASSWORD }} \
-e JWT_SECRET_KEY=${{ secrets.JWT_SECRET_KEY }} \
-e JWT_ACCESS_TOKEN_EXPIRE=${{ secrets.JWT_ACCESS_TOKEN_EXPIRE }} \
-e JWT_REFRESH_TOKEN_EXPIRE=${{ secrets.JWT_REFRESH_TOKEN_EXPIRE }} \
${{ secrets.DOCKER_USERNAME }}/the_monitor:latest