From c10e9a93bd56c5fa1597051c5f86b5da60ecae4a Mon Sep 17 00:00:00 2001 From: giomella Date: Thu, 12 Sep 2024 09:38:28 +0200 Subject: [PATCH] [PPANTT-77] added and configured create dashboard opex action --- .github/workflows/create_dashboard.yaml | 76 +++++++++++++++++++++++++ .gitignore | 4 ++ .opex/env/prod/backend.tfvars | 2 +- .opex/env/prod/config.yaml | 6 +- .opex/env/prod/terraform.tfvars | 2 +- 5 files changed, 84 insertions(+), 6 deletions(-) create mode 100644 .github/workflows/create_dashboard.yaml diff --git a/.github/workflows/create_dashboard.yaml b/.github/workflows/create_dashboard.yaml new file mode 100644 index 0000000..556b2cc --- /dev/null +++ b/.github/workflows/create_dashboard.yaml @@ -0,0 +1,76 @@ +name: Create Dashboard + +# Controls when the workflow will run +on: + workflow_dispatch: + +permissions: + id-token: write + contents: read + deployments: write + +# A workflow run is made up of one or more jobs that can run sequentially or in parallel +jobs: + dashboard: + # The type of runner that the job will run on + runs-on: ubuntu-22.04 + + strategy: + matrix: + environment: [ prod ] + environment: + name: ${{ matrix.environment }} + # Steps represent a sequence of tasks that will be executed as part of the job + steps: + - name: Checkout + id: checkout + # from https://github.com/actions/checkout/commits/main + uses: actions/checkout@1f9a0c22da41e6ebfa534300ef656657ea2c6707 + with: + persist-credentials: false + + # from https://github.com/pagopa/opex-dashboard-azure-action/ + - uses: pagopa/opex-dashboard-azure-action@v1.1.2 + with: + environment: ${{ matrix.environment }} + api-name: + config: .opex/env/${{ matrix.environment }}/config.yaml + client-id: ${{ secrets.CLIENT_ID }} + tenant-id: ${{ secrets.TENANT_ID }} + subscription-id: ${{ secrets.SUBSCRIPTION_ID }} + # from https://github.com/pagopa/opex-dashboard-azure-action/pkgs/container/opex-dashboard-azure-action + docker-version: sha256:e4245954566cd3470e1b5527d33bb58ca132ce7493eac01be9e808fd25a11c8d + + delete_github_deployments: + runs-on: ubuntu-latest + needs: dashboard + if: ${{ always() }} + steps: + - name: Delete Previous deployments + uses: actions/github-script@v6 + env: + SHA_HEAD: ${{ (github.event_name == 'pull_request' && github.event.pull_request.head.sha) || github.sha}} + with: + script: | + const { SHA_HEAD } = process.env + + const deployments = await github.rest.repos.listDeployments({ + owner: context.repo.owner, + repo: context.repo.repo, + sha: SHA_HEAD + }); + await Promise.all( + deployments.data.map(async (deployment) => { + await github.rest.repos.createDeploymentStatus({ + owner: context.repo.owner, + repo: context.repo.repo, + deployment_id: deployment.id, + state: 'inactive' + }); + return github.rest.repos.deleteDeployment({ + owner: context.repo.owner, + repo: context.repo.repo, + deployment_id: deployment.id + }); + }) + ); diff --git a/.gitignore b/.gitignore index a68cd72..b7b02d3 100644 --- a/.gitignore +++ b/.gitignore @@ -23,3 +23,7 @@ hs_err_pid* replay_pid* /target/ + +# IntelliJ +.idea +*.iml diff --git a/.opex/env/prod/backend.tfvars b/.opex/env/prod/backend.tfvars index ae0e6e4..c1fd18f 100644 --- a/.opex/env/prod/backend.tfvars +++ b/.opex/env/prod/backend.tfvars @@ -1,4 +1,4 @@ resource_group_name = "io-infra-rg" storage_account_name = "pagopainfraterraformprod" container_name = "azurermstate" -key = "opex..terraform.tfstate" #TODO +key = "opex.pagopa-payment-options-service.terraform.tfstate" diff --git a/.opex/env/prod/config.yaml b/.opex/env/prod/config.yaml index 8a57e0d..db0266d 100644 --- a/.opex/env/prod/config.yaml +++ b/.opex/env/prod/config.yaml @@ -1,14 +1,12 @@ oa3_spec: ./openapi/openapi.json # If start with http the file would be downloaded from the internet -name: opex_ # TODO -location: West Europe +name: opex_pagopa-payment-options-service +location: Italy North timespan: 5m # Default, a number or a timespan https://docs.microsoft.com/en-us/azure/data-explorer/kusto/query/scalar-data-types/timespan -# TODO configure data_source according to public or private configuration # public data_source data_source: /subscriptions/b9fc9419-6097-45fe-9f74-ba0641c91912/resourceGroups/pagopa-p-vnet-rg/providers/Microsoft.Network/applicationGateways/pagopa-p-app-gw # private data_source #data_source: /subscriptions/b9fc9419-6097-45fe-9f74-ba0641c91912/resourceGroups/pagopa-p-api-rg/providers/Microsoft.ApiManagement/service/pagopa-p-apim -# TODO configure according to the data_source #resource_type: api-management # default is app-gw. uncomment for api-management action_groups: - /subscriptions/b9fc9419-6097-45fe-9f74-ba0641c91912/resourceGroups/pagopa-p-monitor-rg/providers/microsoft.insights/actionGroups/PagoPA diff --git a/.opex/env/prod/terraform.tfvars b/.opex/env/prod/terraform.tfvars index 1445485..484d668 100644 --- a/.opex/env/prod/terraform.tfvars +++ b/.opex/env/prod/terraform.tfvars @@ -6,6 +6,6 @@ tags = { CreatedBy = "Terraform" Environment = "Prod" Owner = "pagoPA" - Source = "https://github.com/pagopa/your-repository" # TODO + Source = "https://github.com/pagopa/pagopa-payment-options-service" CostCenter = "TS310 - PAGAMENTI & SERVIZI" }