Create Dashboard #108
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: Create Dashboard | |
# Controls when the workflow will run | |
on: | |
push: | |
branches: | |
- main | |
paths: | |
- 'openapi/**' | |
- '.github/workflows/create_dashboard.yaml' | |
- '.opex/**' | |
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] | |
product: [v1, v2] | |
max-parallel: 1 | |
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 | |
- run: | | |
python -m venv venv | |
source venv/bin/activate | |
git clone --branch fix-availability-dashboard https://github.com/pagopa/opex-dashboard | |
cd opex-dashboard | |
pip install -e . | |
cd .. | |
source venv/bin/activate | |
venv/bin/opex_dashboard generate \ | |
--template-name azure-dashboard \ | |
--package ./dashboard \ | |
--config-file .opex/${{ matrix.product }}/env/${{ matrix.environment }}/config.yaml | |
# we need to set env variables in the folder /azure-dashboard | |
- name: Copy Environments | |
shell: bash | |
run: | | |
cp -R .opex/${{ matrix.product }}/env ./dashboard/azure-dashboard | |
- name: Setup Terraform | |
id: setup_terraform | |
# from https://github.com/hashicorp/setup-terraform/commits/main | |
uses: hashicorp/setup-terraform@8feba2b913ea459066180f9cb177f58a881cf146 | |
with: | |
terraform_version: 1.3.6 | |
- name: Login | |
id: login | |
# from https://github.com/Azure/login/commits/master | |
uses: azure/login@92a5484dfaf04ca78a94597f4f19fea633851fa2 | |
with: | |
client-id: ${{ secrets.CD_CLIENT_ID }} | |
tenant-id: ${{ secrets.TENANT_ID }} | |
subscription-id: ${{ secrets.SUBSCRIPTION_ID }} | |
# now is possible to launch the command: terraform apply | |
- name: Terraform Apply | |
shell: bash | |
run: | | |
cd ./dashboard/azure-dashboard | |
export ARM_CLIENT_ID="${{ secrets.CD_CLIENT_ID }}" | |
export ARM_TENANT_ID="${{ secrets.TENANT_ID }}" | |
export ARM_SUBSCRIPTION_ID="${{ secrets.SUBSCRIPTION_ID }}" | |
export ARM_USE_OIDC=true | |
bash ./terraform.sh apply ${{ matrix.environment }} -auto-approve | |
# # from https://github.com/pagopa/opex-dashboard-azure-action/ | |
# - uses: pagopa/[email protected] | |
# with: | |
# environment: ${{ matrix.environment }} | |
# api-name: ${{ matrix.product }} | |
# config: .opex/${{ matrix.product }}/env/${{ matrix.environment }}/config.yaml | |
# client-id: ${{ secrets.CD_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:b17f49fc762cc2049f887f0999642c95b5546d1eb44e5ae19bed080f9d1859d4 |