docker aws #4
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
name: Gestao de Vagas Application | |
on: | |
push: | |
branches: [main] | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v3 | |
- name: Setup Java | |
uses: actions/setup-java@v3 | |
with: | |
distribution: temurin | |
java-version: 17 | |
- name: Build Project | |
run: mvn clean install | |
- name: Login docker | |
run: docker login -u ${{secrets.DOCKER_USERNAME}} -p ${{secrets.DOCKER_PASSWORD}} | |
- name: Build Docker Image | |
run: docker build -t luiseduardoalencar/gestao_vagas . | |
- name: Publish Image | |
run: docker push luiseduardoalencar/gestao_vagas | |
deploy: | |
needs: build | |
runs-on: self-hosted | |
steps: | |
- name: Pull image docker hub | |
run: docker pull luiseduardoalencar/gestao_vagas:latest | |
- name: remove container | |
run: docker rm -f | |
- name: Run docker container gestao-vagas | |
run: docker run -d -p 8080:8080 -e DATABASE_URL=${{secrets.DATABASE_URL}} -e DATABASE_PASSWORD=${{secrets.DATABASE_PASSWORD}} -e DATABASE_USERNAME=${{secrets.DATABASE_USERNAME}} --name gestao-vagas luiseduardoalencar/gestao_vagas | |