-
Notifications
You must be signed in to change notification settings - Fork 3
62 lines (50 loc) · 1.57 KB
/
Copy pathdeploy.yml
File metadata and controls
62 lines (50 loc) · 1.57 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
name: Deploy
on:
workflow_dispatch:
env:
REGISTRY: container-registry.br-se1.magalu.cloud
IMAGE_NAME: cloud-application
jobs:
test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: '3.11'
- name: Instalar dependências
run: |
pip install poetry
poetry install --no-root
- name: Executar testes
run: poetry run pytest
build-and-deploy:
needs: test
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Login no Container Registry
run: |
docker login https://${{ env.REGISTRY }} \
-u ${{ secrets.MGC_REGISTRY_USER }} \
-p ${{ secrets.MGC_REGISTRY_PASSWORD }}
- name: Build e push da imagem
run: |
IMAGE=${{ env.REGISTRY }}/${{ secrets.MGC_REGISTRY_NAME }}/${{ env.IMAGE_NAME }}:latest
docker build -t $IMAGE .
docker push $IMAGE
- name: Configurar kubectl
run: |
echo "${{ secrets.MGC_KUBECONFIG }}" > kubeconfig.yaml
- name: Criar Secret do banco
run: |
export KUBECONFIG=kubeconfig.yaml
kubectl create secret generic db-secret \
--from-literal=url=${{ secrets.DATABASE_URL }} \
--dry-run=client -o yaml | kubectl apply -f -
- name: Deploy no Kubernetes
run: |
export KUBECONFIG=kubeconfig.yaml
export MGC_REGISTRY_NAME=${{ secrets.MGC_REGISTRY_NAME }}
envsubst < k8s/app.yaml | kubectl apply -f -
kubectl rollout status deployment/cloud-application