| 12345678910111213141516171819202122232425262728293031323334353637383940414243 |
- name: Release
- env:
- MONGO: ${{ secrets.MONGO }}
- on:
- push:
- branches: [ main ]
- jobs:
- build:
- runs-on: ubuntu-latest
- steps:
- - uses: actions/checkout@v3
- - name: Set up JDK
- uses: actions/setup-java@v3
- with:
- java-version: '17' # or the version you use
- distribution: 'temurin' # or another distribution
- - name: Build with Maven
- run: chmod +x ./mvnw && ./mvnw clean package test
- - name: Build the Docker image
- run: ./mvnw spring-boot:build-image
- - name: Login to Docker Hub
- uses: docker/login-action@v2
- with:
- username: ${{ secrets.DOCKERHUB_USERNAME }}
- password: ${{ secrets.DOCKERHUB_TOKEN }}
- - name: Push image
- run: docker push lhamacorp/stocks-be
- - name: Deploy to Server
- uses: appleboy/ssh-action@master
- with:
- host: ${{ secrets.SERVER_IP }}
- username: ${{ secrets.SERVER_USER }}
- key: ${{ secrets.SSH_PRIVATE_KEY }}
- script: |
- docker pull lhamacorp/stocks-be:latest
- docker stop stocks-be || true
- docker run -d --name stocks-be -e mongo=${{ secrets.MONGO }} -e database=${{ secrets.DATABASE }} -e provider=${{ secrets.PROVIDER_URL }} -e key=${{ secrets.PROVIDER_KEY }} lhamacorp/stocks-be:latest
|