Skip to content

Merge pull request #4 from tibetteixeira/development #6

Merge pull request #4 from tibetteixeira/development

Merge pull request #4 from tibetteixeira/development #6

Workflow file for this run

name: Deploy
on:
push:
branches:
- main
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Docker Login
uses: docker/login-action@v2.0.0
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}
- name: Setup Java
uses: actions/setup-java@v3
with:
java-version: 17
distribution: 'adopt'
cache: maven
- name: Build Application JAR
run: mvn clean package
- name: Docker Compose Build
run: docker build -t ${{ secrets.DOCKER_USERNAME }}/minhasfinancas .
- name: Push to DockerHub Container Registry
run: |
docker tag ${{ secrets.DOCKER_USERNAME }}/minhasfinancas:latest ${{ secrets.DOCKER_USERNAME }}/minhasfinancas:${{ github.run_id }}
docker push ${{ secrets.DOCKER_USERNAME }}/minhasfinancas:${{ github.run_id }}
docker push ${{ secrets.DOCKER_USERNAME }}/minhasfinancas:latest
deploy:
needs: build
runs-on: self-hosted
steps:
- name: Pull image from DockerHub
run: docker pull ${{ secrets.DOCKER_USERNAME }}/minhasfinancas:latest
- name: Remove docker container
run: docker rm -f minhasfinancas
- name: Run docker container
run: docker run -d -p 8080:8080 -e DATABASE_USERNAME=${{ secrets.DATABASE_USERNAME }} -e DATABASE_PASSWORD='${{ secrets.DATABASE_PASSWORD }}' -e DATABASE_URL=${{ secrets.DATABASE_URL }} --name minhasfinancas ${{ secrets.DOCKER_USERNAME }}/minhasfinancas:latest