Workflow file for this run
This file contains hidden or 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: Deploy on AKS | ||
on: | ||
workflow_call: | ||
inputs: | ||
environment: | ||
required: true | ||
description: The name of the environment where to deploy | ||
type: string | ||
target: | ||
required: true | ||
description: The environment target of the job | ||
type: string | ||
pagopa_release: | ||
required: true | ||
type: string | ||
description: release version to deploy for PagoPA microservice | ||
pagopa_force: | ||
required: false | ||
type: boolean | ||
description: force re-deploy PagoPA microservice | ||
default: false | ||
current_release: | ||
required: true | ||
type: string | ||
description: release version of the current deploy | ||
branch: | ||
required: false | ||
default: ${{ github.ref_name }} | ||
type: string | ||
env: | ||
APP_NAME: cache | ||
permissions: | ||
id-token: write | ||
contents: read | ||
jobs: | ||
setting_env: | ||
name: Setting Environment | ||
runs-on: ubuntu-22.04 | ||
if: ${{ inputs.target == inputs.environment }} | ||
outputs: | ||
environment: ${{ steps.get_env.outputs.environment }} | ||
pagopa_rel: ${{ steps.get_releases.outputs.pagopa_rel }} | ||
steps: | ||
- name: Get Environment | ||
id: get_env | ||
shell: bash | ||
run: | | ||
current_env="${{ inputs.environment }}" | ||
echo "environment=$current_env" >> $GITHUB_OUTPUT | ||
- name: Get Releases | ||
id: get_releases | ||
shell: bash | ||
run: | | ||
pagopa_version=${{ inputs.current_release }} | ||
if [[ "${{ inputs.pagopa_release }}" != "" ]]; then | ||
pagopa_version=${{ inputs.pagopa_release }} | ||
fi | ||
echo "pagopa_rel=$pagopa_version" >> $GITHUB_OUTPUT | ||
deploy: | ||
needs: [ setting_env ] | ||
runs-on: [ self-hosted-job, "${{ inputs.environment }}" ] | ||
if: ${{ inputs.target == inputs.environment }} | ||
name: Deploy on AKS | ||
environment: ${{ needs.setting_env.outputs.environment }} | ||
steps: | ||
- name: Deploy DEV | ||
uses: pagopa/github-actions-template/aks-deploy@5db4c9108164a07d96527978da1c3febec934f22 #v1.11.1 | ||
if: ${{ inputs.environment == 'dev' }} | ||
with: | ||
branch: ${{ inputs.branch }} | ||
client_id: ${{ secrets.CLIENT_ID }} | ||
subscription_id: ${{ secrets.SUBSCRIPTION_ID }} | ||
tenant_id: ${{ secrets.TENANT_ID }} | ||
env: ${{ needs.setting_env.outputs.environment }} | ||
namespace: ${{ vars.NAMESPACE }} | ||
cluster_name: ${{ vars.CLUSTER_NAME }} | ||
resource_group: ${{ vars.CLUSTER_RESOURCE_GROUP }} | ||
app_name: ${{ env.APP_NAME }} | ||
helm_upgrade_options: ' --debug | ||
--set microservice-chart.azure.workloadIdentityClientId=${{vars.WORKLOAD_IDENTITY_ID}} | ||
--set refresh-p.azure.workloadIdentityClientId=${{vars.WORKLOAD_IDENTITY_ID}} | ||
--set refresh-p-replica.azure.workloadIdentityClientId=${{vars.WORKLOAD_IDENTITY_ID}} | ||
--set postgresql.azure.workloadIdentityClientId=${{vars.WORKLOAD_IDENTITY_ID}} | ||
--set postgresql-replica.azure.workloadIdentityClientId=${{vars.WORKLOAD_IDENTITY_ID}} | ||
--set postgresql.forceRedeploy=${{ inputs.pagopa_force }} | ||
--set postgresql.image.tag=${{ needs.setting_env.outputs.pagopa_rel }} | ||
timeout: '15m0s' | ||
- name: Deploy UAT | ||
uses: pagopa/github-actions-template/aks-deploy@5db4c9108164a07d96527978da1c3febec934f22 #v1.11.1 | ||
if: ${{ inputs.environment == 'uat' }} | ||
with: | ||
branch: ${{ inputs.branch }} | ||
client_id: ${{ secrets.CLIENT_ID }} | ||
subscription_id: ${{ secrets.SUBSCRIPTION_ID }} | ||
tenant_id: ${{ secrets.TENANT_ID }} | ||
env: ${{ needs.setting_env.outputs.environment }} | ||
namespace: ${{ vars.NAMESPACE }} | ||
cluster_name: ${{ vars.CLUSTER_NAME }} | ||
resource_group: ${{ vars.CLUSTER_RESOURCE_GROUP }} | ||
app_name: ${{ env.APP_NAME }} | ||
helm_upgrade_options: ' --debug | ||
--set microservice-chart.azure.workloadIdentityClientId=${{vars.WORKLOAD_IDENTITY_ID}} | ||
--set refresh-p.azure.workloadIdentityClientId=${{vars.WORKLOAD_IDENTITY_ID}} | ||
--set refresh-p-replica.azure.workloadIdentityClientId=${{vars.WORKLOAD_IDENTITY_ID}} | ||
--set postgresql.azure.workloadIdentityClientId=${{vars.WORKLOAD_IDENTITY_ID}} | ||
--set postgresql-replica.azure.workloadIdentityClientId=${{vars.WORKLOAD_IDENTITY_ID}} | ||
--set postgresql.forceRedeploy=${{ inputs.pagopa_force }} | ||
--set postgresql.image.tag=${{ needs.setting_env.outputs.pagopa_rel }} | ||
--set postgresql-replica.forceRedeploy=${{ inputs.pagopa_force }} | ||
--set postgresql-replica.image.tag=${{ needs.setting_env.outputs.pagopa_rel }} | ||
timeout: '15m0s' | ||
- name: Deploy PROD | ||
uses: pagopa/github-actions-template/aks-deploy@5db4c9108164a07d96527978da1c3febec934f22 #v1.11.1 | ||
if: ${{ inputs.environment == 'prod' }} | ||
with: | ||
branch: ${{ inputs.branch }} | ||
client_id: ${{ secrets.CLIENT_ID }} | ||
subscription_id: ${{ secrets.SUBSCRIPTION_ID }} | ||
tenant_id: ${{ secrets.TENANT_ID }} | ||
env: ${{ needs.setting_env.outputs.environment }} | ||
namespace: ${{ vars.NAMESPACE }} | ||
cluster_name: ${{ vars.CLUSTER_NAME }} | ||
resource_group: ${{ vars.CLUSTER_RESOURCE_GROUP }} | ||
app_name: ${{ env.APP_NAME }} | ||
helm_upgrade_options: '--debug | ||
--set microservice-chart.azure.workloadIdentityClientId=${{vars.WORKLOAD_IDENTITY_ID}} | ||
--set refresh-p.azure.workloadIdentityClientId=${{vars.WORKLOAD_IDENTITY_ID}} | ||
--set refresh-p-replica.azure.workloadIdentityClientId=${{vars.WORKLOAD_IDENTITY_ID}} | ||
--set microservice-chart.azure.workloadIdentityClientId=${{vars.WORKLOAD_IDENTITY_ID}} | ||
--set postgresql.azure.workloadIdentityClientId=${{vars.WORKLOAD_IDENTITY_ID}} | ||
--set postgresql-replica.azure.workloadIdentityClientId=${{vars.WORKLOAD_IDENTITY_ID}} | ||
--set postgresql.forceRedeploy=${{ inputs.pagopa_force }} | ||
--set postgresql.image.tag=${{ needs.setting_env.outputs.pagopa_rel }}' | ||
timeout: '15m0s' | ||
update_openapi: | ||
needs: [ setting_env, deploy ] | ||
runs-on: ubuntu-latest | ||
name: Update OpenAPI | ||
if: ${{ inputs.target == inputs.environment }} | ||
environment: ${{ needs.setting_env.outputs.environment }} | ||
steps: | ||
- name: Checkout | ||
id: checkout | ||
# from https://github.com/actions/checkout/commits/main | ||
uses: actions/checkout@0ad4b8fadaa221de15dcec353f45205ec38ea70b #v4.1.4 | ||
with: | ||
persist-credentials: false | ||
- name: Read current terraform version | ||
run: | | ||
VER=$(cat .terraform-version) | ||
echo "TERRAFORM_VERSION=$VER" >> $GITHUB_ENV | ||
- name: Setup Terraform | ||
# from https://github.com/hashicorp/setup-terraform/commits/main | ||
uses: hashicorp/setup-terraform@97f030cf6dc0b4f5e0da352c7bca9cca34579800 #v3.1.0 | ||
with: | ||
terraform_version: "${{ env.TERRAFORM_VERSION }}" | ||
- name: Apply terraform.sh | ||
uses: pagopa/eng-github-actions-iac-template/azure/terraform-sh-apply-azure-action@ae723dfbdc457ffa6b4acd99f2444fc08c1efb85 #v1.11.0 | ||
with: | ||
client_id: "${{ secrets.CLIENT_ID }}" | ||
tenant_id: "${{ secrets.TENANT_ID }}" | ||
subscription_id: "${{ secrets.SUBSCRIPTION_ID }}" | ||
tf_environment: "weu-${{ needs.setting_env.outputs.environment }}" | ||
dir: "infra" |