Skip to content

Commit bc99da1

Browse files
avilaopsavilaops
authored andcommitted
Corrige workflow GitHub Actions - atualiza ACR e resource group
1 parent dc21db6 commit bc99da1

2 files changed

Lines changed: 118 additions & 49 deletions

File tree

.github/workflows/azure-deploy.yml

Lines changed: 50 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -1,56 +1,57 @@
11
name: Deploy to Azure
22

33
on:
4-
push:
5-
branches: [main]
6-
workflow_dispatch:
4+
push:
5+
branches: [main]
6+
workflow_dispatch:
77

88
env:
9-
AZURE_WEBAPP_NAME: webapp-geolocation-prod
10-
REGISTRY_NAME: acrgeolocation
11-
IMAGE_NAME: geolocation
9+
AZURE_WEBAPP_NAME: geolocation-app
10+
REGISTRY_NAME: acrgeo4096
11+
IMAGE_NAME: geolocation
12+
RESOURCE_GROUP: rg-geolocation
1213

1314
jobs:
14-
build-and-deploy:
15-
runs-on: ubuntu-latest
16-
17-
steps:
18-
- name: Checkout code
19-
uses: actions/checkout@v4
20-
21-
- name: Set up Docker Buildx
22-
uses: docker/setup-buildx-action@v3
23-
24-
- name: Log in to Azure Container Registry
25-
uses: azure/docker-login@v1
26-
with:
27-
login-server: ${{ env.REGISTRY_NAME }}.azurecr.io
28-
username: ${{ secrets.AZURE_ACR_USERNAME }}
29-
password: ${{ secrets.AZURE_ACR_PASSWORD }}
30-
31-
- name: Build and push Docker image
32-
uses: docker/build-push-action@v5
33-
with:
34-
context: .
35-
file: ./Dockerfile
36-
push: true
37-
tags: |
38-
${{ env.REGISTRY_NAME }}.azurecr.io/${{ env.IMAGE_NAME }}:latest
39-
${{ env.REGISTRY_NAME }}.azurecr.io/${{ env.IMAGE_NAME }}:${{ github.sha }}
40-
cache-from: type=registry,ref=${{ env.REGISTRY_NAME }}.azurecr.io/${{ env.IMAGE_NAME }}:buildcache
41-
cache-to: type=registry,ref=${{ env.REGISTRY_NAME }}.azurecr.io/${{ env.IMAGE_NAME }}:buildcache,mode=max
42-
43-
- name: Azure Login
44-
uses: azure/login@v1
45-
with:
46-
creds: ${{ secrets.AZURE_CREDENTIALS }}
47-
48-
- name: Deploy to Azure Web App
49-
uses: azure/webapps-deploy@v2
50-
with:
51-
app-name: ${{ env.AZURE_WEBAPP_NAME }}
52-
images: ${{ env.REGISTRY_NAME }}.azurecr.io/${{ env.IMAGE_NAME }}:${{ github.sha }}
53-
54-
- name: Restart Web App
55-
run: |
56-
az webapp restart --name ${{ env.AZURE_WEBAPP_NAME }} --resource-group rg-geolocation-prod
15+
build-and-deploy:
16+
runs-on: ubuntu-latest
17+
18+
steps:
19+
- name: Checkout code
20+
uses: actions/checkout@v4
21+
22+
- name: Set up Docker Buildx
23+
uses: docker/setup-buildx-action@v3
24+
25+
- name: Log in to Azure Container Registry
26+
uses: azure/docker-login@v1
27+
with:
28+
login-server: ${{ env.REGISTRY_NAME }}.azurecr.io
29+
username: ${{ secrets.AZURE_ACR_USERNAME }}
30+
password: ${{ secrets.AZURE_ACR_PASSWORD }}
31+
32+
- name: Build and push Docker image
33+
uses: docker/build-push-action@v5
34+
with:
35+
context: .
36+
file: ./Dockerfile
37+
push: true
38+
tags: |
39+
${{ env.REGISTRY_NAME }}.azurecr.io/${{ env.IMAGE_NAME }}:latest
40+
${{ env.REGISTRY_NAME }}.azurecr.io/${{ env.IMAGE_NAME }}:${{ github.sha }}
41+
cache-from: type=registry,ref=${{ env.REGISTRY_NAME }}.azurecr.io/${{ env.IMAGE_NAME }}:buildcache
42+
cache-to: type=registry,ref=${{ env.REGISTRY_NAME }}.azurecr.io/${{ env.IMAGE_NAME }}:buildcache,mode=max
43+
44+
- name: Azure Login
45+
uses: azure/login@v1
46+
with:
47+
creds: ${{ secrets.AZURE_CREDENTIALS }}
48+
49+
- name: Deploy to Azure Web App
50+
uses: azure/webapps-deploy@v2
51+
with:
52+
app-name: ${{ env.AZURE_WEBAPP_NAME }}
53+
images: ${{ env.REGISTRY_NAME }}.azurecr.io/${{ env.IMAGE_NAME }}:${{ github.sha }}
54+
55+
- name: Restart Web App
56+
run: |
57+
az webapp restart --name ${{ env.AZURE_WEBAPP_NAME }} --resource-group ${{ env.RESOURCE_GROUP }}

GITHUB-SECRETS-SETUP.md

Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
# Configuração de Secrets do GitHub Actions
2+
3+
Para que o workflow de deploy funcione, você precisa configurar os seguintes secrets no GitHub:
4+
5+
## 1. Acessar Settings do Repositório
6+
7+
1. Vá para: https://github.com/avilaops/geolocation/settings/secrets/actions
8+
2. Clique em "New repository secret"
9+
10+
## 2. Adicionar os Secrets
11+
12+
### Secret 1: AZURE_ACR_USERNAME
13+
- **Name:** `AZURE_ACR_USERNAME`
14+
- **Value:** `acrgeo4096`
15+
16+
### Secret 2: AZURE_ACR_PASSWORD
17+
- **Name:** `AZURE_ACR_PASSWORD`
18+
- **Value:** `nY76S6xoiqyhWNkrcelj/HH/KwshRhCOxlDronF9g7+ACRBFcHCY`
19+
20+
### Secret 3: AZURE_CREDENTIALS
21+
- **Name:** `AZURE_CREDENTIALS`
22+
- **Value:** (copie TODO o JSON abaixo)
23+
```json
24+
{
25+
"clientId": "c56a022d-703f-48dd-8672-58a5c65a2d21",
26+
"clientSecret": "PY.8Q~~Fxs22sZr.pipLN41a9Nx6CnBZJy.-HdoE",
27+
"subscriptionId": "3b49f371-dd88-46c7-ba30-aeb54bd5c2f6",
28+
"tenantId": "0e53f641-197a-48b2-83a4-f8222f5d48c0",
29+
"activeDirectoryEndpointUrl": "https://login.microsoftonline.com",
30+
"resourceManagerEndpointUrl": "https://management.azure.com/",
31+
"activeDirectoryGraphResourceId": "https://graph.windows.net/",
32+
"sqlManagementEndpointUrl": "https://management.core.windows.net:8443/",
33+
"galleryEndpointUrl": "https://gallery.azure.com/",
34+
"managementEndpointUrl": "https://management.core.windows.net/"
35+
}
36+
```
37+
38+
## 3. Verificar Configuração
39+
40+
Após adicionar os 3 secrets, você deverá ver:
41+
- ✅ AZURE_ACR_USERNAME
42+
- ✅ AZURE_ACR_PASSWORD
43+
- ✅ AZURE_CREDENTIALS
44+
45+
## 4. Recursos Azure Configurados
46+
47+
O workflow está configurado para usar:
48+
- **Resource Group:** `rg-geolocation`
49+
- **Container Registry:** `acrgeo4096.azurecr.io`
50+
- **Web App:** `geolocation-app`
51+
- **Image:** `geolocation:latest`
52+
53+
## 5. Testar o Deploy
54+
55+
Após configurar os secrets, faça um commit e push para a branch `main`:
56+
57+
```powershell
58+
git add .
59+
git commit -m "Atualiza workflow do GitHub Actions"
60+
git push origin main
61+
```
62+
63+
O deploy será executado automaticamente via GitHub Actions!
64+
65+
## ⚠️ IMPORTANTE
66+
67+
**NUNCA** commite este arquivo com as credenciais reais no repositório público!
68+
Este arquivo deve ser mantido localmente ou deletado após configurar os secrets.

0 commit comments

Comments
 (0)