Skip to content

chore: cd

chore: cd #31

Workflow file for this run

name: "Continuous Deployment"
on:
workflow_dispatch:
push:
branches:
- main
jobs:
cd_build_push:
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 }}