Skip to content

Commit

Permalink
Criar pipeline de deploy automatizado para um app services da azure #23
Browse files Browse the repository at this point in the history
… (#25)

* feat: adicionando workflow de deploy para azure

* fix: renomeando arquivo yaml

* fix: renomeando arquivo yaml

* fix: renomeando arquivo yaml

* cd: adicionando worfklow de deploy automatizado na azure

* cd: adicionando worfklow de deploy automatizado na azure

* cd: adicionando worfklow de deploy automatizado na azure

* cd: ajustando precedencia da pipeline de CD

* cd: ajustando precedencia da pipeline de CD

* cd: adicionando configuração de workflow de CD para realizar deploy apenas quando realizar merge commit

* fix: removendo variáveis de ambiente não utilziadas
  • Loading branch information
williambrunos authored Feb 24, 2024
1 parent 42a4c8b commit c2c6ebc
Show file tree
Hide file tree
Showing 3 changed files with 48 additions and 1 deletion.
2 changes: 1 addition & 1 deletion .env.test
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@ MANDACARU_POSTGRES_DB=mandacaru_broker
MANDACARU_POSTGRES_USER=time_dez
MANDACARU_POSTGRES_PASSWORD=mandacaru
MANDACARU_SQL_INIT_MODE=always
MANDACARU_API_PORT=8080
MANDACARU_API_PORT=8080
44 changes: 44 additions & 0 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
name: Deploy
on:
push:
branches:
- main

jobs:
push-to-registry:
name: Push to DockerHub Registry
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0

- name: Set up JDK 17
uses: actions/setup-java@v3
with:
java-version: 17
distribution: "zulu"

- name: Login to DockerHub
run: echo ${{ secrets.DOCKERHUB_TOKEN }} | docker login -u ${{ secrets.DOCKERHUB_USERNAME }} --password-stdin

- name: Build and push Docker image
run: |
docker build -t ${{ secrets.DOCKERHUB_USERNAME }}/mandacarubroker-api .
docker push ${{ secrets.DOCKERHUB_USERNAME }}/mandacarubroker-api
deploy:
needs: push-to-registry
name: Deploy to Azure VM
runs-on: ubuntu-latest
steps:
- name: Set up Azure CLI
uses: azure/login@v1
with:
creds: ${{ secrets.AZURE_CREDENTIALS }}

- name: Connect to Azure VM and run Docker Compose
run: |
echo "${{ secrets.SSH_PRIVATE_KEY }}" > private_key
chmod 400 private_key
ssh -o StrictHostKeyChecking=no -i private_key [email protected] 'sudo docker stop mandacarubroker-api || true && docker rm mandacarubroker-api || true && docker run --log-opt labels=applications,environment --restart unless-stopped --name mandacarubroker-api --env-file=/home/william/mandacaru-broker-jandaia/.env -p 8080:8080 -d izaiasmachado/mandacarubroker-api'
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@ target/
!**/src/main/**/target/
!**/src/test/**/target/

# scerets
/secrets

### STS ###
.apt_generated
.classpath
Expand Down

0 comments on commit c2c6ebc

Please sign in to comment.