-
Notifications
You must be signed in to change notification settings - Fork 0
69 lines (57 loc) · 2.02 KB
/
cd.yml
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
63
64
65
66
67
68
69
name: "Continuous Deployment"
on:
workflow_dispatch:
push:
branches:
- main
jobs:
cd_build_push:
if: false
name: "Build and Push"
runs-on: ubuntu-latest
environment:
name: ${{ github.ref_name == 'main' && 'development' || 'production' }}
steps:
- uses: actions/checkout@v4
- uses: ./.github/actions/build-and-push
with:
setup-qemu: "false"
build-image: "true"
push-image: "true"
image-name: ${{ vars.IMAGE_NAME_SSO_SERVICE }}
image-tag: ${{ vars.IMAGE_TAG }}
push-image-registry-url: ${{ secrets.REGISTRY_URL }}
push-image-registry-username: ${{ secrets.REGISTRY_USERNAME }}
push-image-registry-token: ${{ secrets.REGISTRY_TOKEN }}
cd_deploy:
name: Deploy to Cluster
runs-on: deploy
needs: [cd_build_push]
environment:
name: ${{ github.ref_name == 'main' && 'development' || 'production' }}
url: ${{ env.DEPLOYMENT_URL }}
steps:
- uses: actions/checkout@v4
- id: config
name: produce key=value with runtime env vars
shell: bash
run: |
# Transforma os (secrets e vars) presentes nesta action para o runtime do sistema
# Combina objetos JSON, filtra por prefixo, e converte para key=value
RUNTIME_ENV=$(\
echo '${{ toJson(secrets) }} ${{ toJson(vars) }}' \
| jq -s add \
| jq --arg prefix "${{ vars.PREFIX_RUNTIME }}" 'with_entries(select(.key | startswith($prefix)) | .key |= sub("^" + $prefix; ""))' \
| jq -r 'to_entries|map("\(.key)=\(.value|tostring)")|.[]' \
);
{
echo 'RUNTIME_ENV<<EOF'
echo "${RUNTIME_ENV}"
echo EOF
} >> "$GITHUB_OUTPUT"
- uses: ./.github/actions/deploy-k8s
with:
runtime-env: ${{ steps.config.outputs.RUNTIME_ENV }}
pwd: ${{ env.K8S_PWD }}
deployment: ${{ env.K8S_DEPLOYMENT }}
namespace: ${{ env.K8S_NAMESPACE }}