Skip to content

Commit ef63fd4

Browse files
authored
ci: add GitHub Actions pipeline for Azure deployment
1 parent 4aca8b9 commit ef63fd4

1 file changed

Lines changed: 57 additions & 0 deletions

File tree

.github/workflows/main.yml

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
name: Deploy to Azure Container Apps
2+
3+
on:
4+
workflow_dispatch:
5+
push:
6+
branches: [main]
7+
8+
env:
9+
AZURE_CONTAINER_REGISTRY: controlaestoque
10+
CONTAINER_APP_NAME: controlaestoqueapi
11+
RESOURCE_GROUP: teste
12+
13+
jobs:
14+
build-and-deploy:
15+
runs-on: ubuntu-latest
16+
17+
steps:
18+
- uses: actions/checkout@v4
19+
20+
- name: Set up .NET Core
21+
uses: actions/setup-dotnet@v4
22+
with:
23+
dotnet-version: "8.0.x"
24+
25+
- name: Build
26+
run: dotnet build --configuration Release
27+
28+
- name: Set up Docker Buildx
29+
uses: docker/setup-buildx-action@v3
30+
31+
- name: Log in to ACR
32+
uses: docker/login-action@v3
33+
with:
34+
registry: ${{ env.AZURE_CONTAINER_REGISTRY }}.azurecr.io
35+
username: ${{ secrets.AZURE_REGISTRY_USERNAME }}
36+
password: ${{ secrets.AZURE_REGISTRY_PASSWORD }}
37+
38+
- name: Build and push container image to ACR
39+
uses: docker/build-push-action@v6
40+
with:
41+
push: true
42+
tags: ${{ env.AZURE_CONTAINER_REGISTRY }}.azurecr.io/${{ env.CONTAINER_APP_NAME }}:${{ github.sha }}
43+
file: Refit.Api/Dockerfile
44+
45+
- name: Azure Login
46+
uses: azure/login@v2
47+
with:
48+
creds: ${{ secrets.AZURE_CREDENTIALS }}
49+
50+
- name: Deploy to Azure Container Apps
51+
uses: azure/container-apps-deploy-action@v1
52+
with:
53+
imageToDeploy: ${{ env.AZURE_CONTAINER_REGISTRY }}.azurecr.io/${{ env.CONTAINER_APP_NAME }}:${{ github.sha }}
54+
resourceGroup: ${{ env.RESOURCE_GROUP }}
55+
containerAppName: ${{ env.CONTAINER_APP_NAME }}
56+
environmentVariables: |
57+
ASPNETCORE_ENVIRONMENT=Development

0 commit comments

Comments
 (0)