name: Deploy K8S Modifications on: push: branches: - main - beta jobs: extract_environment: runs-on: ubuntu-22.04 outputs: environment: ${{ steps.extract_environment.outputs.environment }} steps: - name: Extract Environment run: | if [ ${GITHUB_REF} == "refs/heads/main" ]; then echo "environment=prd" >> $GITHUB_OUTPUT elif [ ${GITHUB_REF} == "refs/heads/beta" ]; then echo "environment=stg" >> $GITHUB_OUTPUT fi id: extract_environment helmfile-deploy: needs: [extract_environment] runs-on: [self-hosted, "prd-azure"] steps: - name: Checkout code uses: actions/checkout@v3 - name: Set up Helm uses: azure/setup-helm@v1 with: version: 'v3.9.0' - name: Install Azure ClI run: | curl -sL https://aka.ms/InstallAzureCLIDeb | bash - uses: azure/login@v2 with: creds: '{"clientId":"${{ secrets.ARM_CLIENT_ID }}","clientSecret":"${{ secrets.ARM_CLIENT_SECRET }}","subscriptionId":"${{ secrets.ARM_SUBSCRIPTION_ID }}","tenantId":"${{ secrets.ARM_TENANT_ID }}"}' - name: Set up Python uses: actions/setup-python@v4 with: python-version: '3.8' - name: Install Helmfile run: | wget https://github.com/helmfile/helmfile/releases/download/v0.148.0/helmfile_0.148.0_linux_amd64.tar.gz tar -xzf helmfile_0.148.0_linux_amd64.tar.gz mv helmfile /usr/local/bin/ helmfile --version - name: Install Helm Diff Plugin run: helm plugin install https://github.com/databus23/helm-diff || true - name: Setup kubectl uses: azure/setup-kubectl@v1 with: version: 'v1.30.1' - name: Authenticate with cluster env: CLUSTER_NAME: platform-${{ needs.extract_environment.outputs.environment }} run: az aks get-credentials --resource-group dadosfera-prd --name ${CLUSTER_NAME} --overwrite-existing - name: Run Helmfile Apply env: ENV: ${{ needs.extract_environment.outputs.environment }} run: helmfile -f helmfiles/${ENV}.yaml sync