From 2c5eca3fe9e560e50615e2cc23031e73bd975af1 Mon Sep 17 00:00:00 2001 From: Andrea De Rinaldis Date: Thu, 26 Oct 2023 17:42:08 +0200 Subject: [PATCH] [NOD-541] fix: Updated variable retrieving --- .github/workflows/04_release_deploy.yml | 3 +-- .github/workflows/04_self_hosted.yml | 32 +++++++++---------------- .identity/00_data.tf | 2 +- .identity/02_application_action.tf | 2 +- Dockerfile | 22 +++++++++++++++++ 5 files changed, 36 insertions(+), 25 deletions(-) create mode 100644 Dockerfile diff --git a/.github/workflows/04_release_deploy.yml b/.github/workflows/04_release_deploy.yml index 9d8236f..32ccce4 100644 --- a/.github/workflows/04_release_deploy.yml +++ b/.github/workflows/04_release_deploy.yml @@ -69,6 +69,7 @@ jobs: name: Create a New Release runs-on: ubuntu-latest needs: [setup] + environment: ${{ inputs.environment }} outputs: version: ${{ steps.release.outputs.version }} registry_image: ${{ steps.get_image.outputs.registry_image }} @@ -112,8 +113,6 @@ jobs: with: environment: ${{ matrix.environment }} target: ${{ needs.setup.outputs.environment }} - resource_group: ${{ vars.FUNCTION_RESOURCE_GROUP }} - app_name: ${{ vars.FUNCTION_APP_NAME }} registry_image: ${{ needs.release.outputs.registry_image }} notify: diff --git a/.github/workflows/04_self_hosted.yml b/.github/workflows/04_self_hosted.yml index 5c30d00..3c058dc 100644 --- a/.github/workflows/04_self_hosted.yml +++ b/.github/workflows/04_self_hosted.yml @@ -11,14 +11,6 @@ on: required: true description: The environment target of the job type: string - resource_group: - required: true - description: The resource group of the function to deploy - type: string - app_name: - required: true - description: The name of the function to deploy - type: string registry_image: required: true description: The name of the image from container registry to be used @@ -32,13 +24,14 @@ jobs: show_input: runs-on: ubuntu-latest if: ${{ inputs.target == inputs.environment }} + environment: ${{ inputs.environment }} steps: - name: Get input parameters run: | echo environment=${{ inputs.environment }} echo target=${{ inputs.target }} - echo resource_group=${{ inputs.resource_group }} - echo app_name=${{ inputs.app_name }} + echo resource_group=${{ vars.FUNCTION_RESOURCE_GROUP }} + echo app_name=${{ vars.FUNCTION_APP_NAME }} echo registry_image=${{ inputs.registry_image }} @@ -47,8 +40,7 @@ jobs: name: Create staging slots runs-on: ubuntu-22.04 if: ${{ inputs.target == inputs.environment && inputs.target == 'prod' }} - environment: - name: ${{ inputs.environment }} + environment: ${{ inputs.environment }} steps: - name: Create staging slots uses: pagopa/github-actions-template/azure-function-start-staging-slot@a1b72480e9ac555364be0b7ecdcc8f5ab1c89ad9 @@ -57,8 +49,8 @@ jobs: client_id: ${{ secrets.CLIENT_ID }} tenant_id: ${{ secrets.TENANT_ID }} subscription_id: ${{ secrets.SUBSCRIPTION_ID }} - resource_group: ${{ inputs.resource_group }} - app_name: ${{ inputs.app_name }} + resource_group: ${{ vars.FUNCTION_RESOURCE_GROUP }} + app_name: ${{ vars.FUNCTION_APP_NAME }} registry_image: ${{ inputs.registry_image }} @@ -68,8 +60,7 @@ jobs: runs-on: ubuntu-22.04 needs: [ start_staging_slot ] if: ${{ always() && inputs.target == inputs.environment }} - environment: - name: ${{ inputs.environment }} + environment: ${{ inputs.environment }} steps: - name: Deploy Azure Function uses: pagopa/github-actions-template/azure-functions-deploy@a1b72480e9ac555364be0b7ecdcc8f5ab1c89ad9 @@ -78,7 +69,7 @@ jobs: client_id: ${{ secrets.CLIENT_ID }} tenant_id: ${{ secrets.TENANT_ID }} subscription_id: ${{ secrets.SUBSCRIPTION_ID }} - app_name: ${{ inputs.app_name }} + app_name: ${{ vars.FUNCTION_APP_NAME }} registry_image: ${{ inputs.registry_image }} @@ -88,8 +79,7 @@ jobs: needs: [ start_staging_slot, deploy ] if: ${{ success() || failure() && (inputs.target == inputs.environment && inputs.target == 'prod') }} runs-on: ubuntu-22.04 - environment: - name: ${{ inputs.environment }} + environment: ${{ inputs.environment }} steps: - name: Deploy Azure Function uses: pagopa/github-actions-template/azure-function-stop-staging-slot@a1b72480e9ac555364be0b7ecdcc8f5ab1c89ad9 @@ -98,6 +88,6 @@ jobs: client_id: ${{ secrets.CLIENT_ID }} tenant_id: ${{ secrets.TENANT_ID }} subscription_id: ${{ secrets.SUBSCRIPTION_ID }} - resource_group: ${{ inputs.resource_group }} - app_name: ${{ inputs.app_name }} + resource_group: ${{ vars.FUNCTION_RESOURCE_GROUP }} + app_name: ${{ vars.FUNCTION_APP_NAME }} registry_image: ${{ inputs.registry_image }} \ No newline at end of file diff --git a/.identity/00_data.tf b/.identity/00_data.tf index 9b84660..d797098 100644 --- a/.identity/00_data.tf +++ b/.identity/00_data.tf @@ -37,6 +37,6 @@ data "azurerm_key_vault_secret" "key_vault_slack_webhook_url" { key_vault_id = data.azurerm_key_vault.domain_key_vault.id } -data "azurerm_resource_group" "nodo_re_rg" { +data "azurerm_resource_group" "nodo_verifyko_rg" { name = "pagopa-${var.env_short}-${local.location_short}-nodo-verifyko-to-datastore-rg" } diff --git a/.identity/02_application_action.tf b/.identity/02_application_action.tf index b519782..dd36e0f 100644 --- a/.identity/02_application_action.tf +++ b/.identity/02_application_action.tf @@ -42,7 +42,7 @@ resource "null_resource" "github_runner_app_permissions_to_namespace" { } resource "azurerm_role_assignment" "environment_function" { - scope = data.azurerm_resource_group.nodo_re_rg.id + scope = data.azurerm_resource_group.nodo_verifyko_rg.id role_definition_name = "Contributor" principal_id = module.github_runner_app.object_id } diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..dd42d12 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,22 @@ +ARG JAVA_VERSION=11 +# This image additionally contains function core tools – useful when using custom extensions +FROM mcr.microsoft.com/azure-functions/java:3.0-java$JAVA_VERSION-build AS installer-env + +COPY . /src/java-function-app +RUN cd /src/java-function-app && \ + mkdir -p /home/site/wwwroot && \ + mvn clean package -Dmaven.test.skip=true && \ + cd ./target/azure-functions/ && \ + cd $(ls -d */|head -n 1) && \ + cp -a . /home/site/wwwroot + +# This image is ssh enabled +#FROM mcr.microsoft.com/azure-functions/java:3.0-java$JAVA_VERSION-appservice +# This image isn't ssh enabled +FROM mcr.microsoft.com/azure-functions/java:3.0-java$JAVA_VERSION + +ENV AzureWebJobsScriptRoot=/home/site/wwwroot \ + AzureFunctionsJobHost__Logging__Console__IsEnabled=true + +EXPOSE 80 +COPY --from=installer-env ["/home/site/wwwroot", "/home/site/wwwroot"] \ No newline at end of file