forked from vilelaricardo/mandacarubroker
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Criar pipeline de deploy automatizado para um app services da azure #23…
… (#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
1 parent
42a4c8b
commit c2c6ebc
Showing
3 changed files
with
48 additions
and
1 deletion.
There are no files selected for viewing
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
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
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' |
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