chore: cd #22
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: "Continuous Deployment" | |
on: | |
workflow_dispatch: | |
push: | |
branches: | |
- main | |
jobs: | |
cd_build_push: | |
name: "Build and Push (Development)" | |
runs-on: ubuntu-latest | |
environment: | |
name: development | |
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_development: | |
name: Deploy to Cluster (Development) | |
runs-on: deploy | |
needs: [cd_build_push] | |
environment: | |
name: development | |
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-kustomize | |
with: | |
runtime-env: ${{ steps.config.outputs.RUNTIME_ENV }} | |
pwd: ${{ env.K8S_PWD }} | |
deployment: ${{ env.K8S_DEPLOYMENT }} | |
namespace: ${{ env.K8S_NAMESPACE }} |