From 167a28d3f6eb443260283b90ba7e3eb00da132a5 Mon Sep 17 00:00:00 2001 From: Dhanalakshmi Gopalswamy <34273718+acn-dgopa@users.noreply.github.com> Date: Thu, 8 Feb 2024 22:46:08 +0100 Subject: [PATCH 1/2] Update deploy script to include at21,23,24 --- .github/workflows/build-publish-dev.yml | 93 ++++++++++++++++++++++++- 1 file changed, 92 insertions(+), 1 deletion(-) diff --git a/.github/workflows/build-publish-dev.yml b/.github/workflows/build-publish-dev.yml index 7dd2730..e1e5a1a 100644 --- a/.github/workflows/build-publish-dev.yml +++ b/.github/workflows/build-publish-dev.yml @@ -42,6 +42,37 @@ jobs: with: push: true tags: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ github.sha }} + + deploy-at21: + environment: AT21 + runs-on: ubuntu-latest + needs: build-and-push-image + permissions: + id-token: write + contents: read + packages: read + steps: + - name: Azure Login + uses: azure/login@v1 + with: + client-id: ${{ secrets.AZURE_CLIENT_ID }} + tenant-id: ${{ secrets.AZURE_TENANT_ID }} + subscription-id: ${{ secrets.AZURE_SUBSCRIPTION_ID }} + - name: Deploy to containerapp + uses: azure/CLI@v1 + with: + inlineScript: > + az config set extension.use_dynamic_install=yes_without_prompt + + az containerapp update \ + --name ${{ vars.CONTAINER_APP_NAME }} \ + --container-name ${{ env.CONTAINER_APP_CONTAINER_NAME }} \ + --resource-group ${{ vars.CONTAINER_APP_RESOURCE_GROUP_NAME }} \ + --image ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ github.sha }} + - name: logout + run: > + az logout + deploy-at22: environment: AT22 runs-on: ubuntu-latest @@ -70,4 +101,64 @@ jobs: --image ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ github.sha }} - name: logout run: > - az logout + az logout + + deploy-at23: + environment: AT23 + runs-on: ubuntu-latest + needs: build-and-push-image + permissions: + id-token: write + contents: read + packages: read + steps: + - name: Azure Login + uses: azure/login@v1 + with: + client-id: ${{ secrets.AZURE_CLIENT_ID }} + tenant-id: ${{ secrets.AZURE_TENANT_ID }} + subscription-id: ${{ secrets.AZURE_SUBSCRIPTION_ID }} + - name: Deploy to containerapp + uses: azure/CLI@v1 + with: + inlineScript: > + az config set extension.use_dynamic_install=yes_without_prompt + + az containerapp update \ + --name ${{ vars.CONTAINER_APP_NAME }} \ + --container-name ${{ env.CONTAINER_APP_CONTAINER_NAME }} \ + --resource-group ${{ vars.CONTAINER_APP_RESOURCE_GROUP_NAME }} \ + --image ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ github.sha }} + - name: logout + run: > + az logout + + deploy-at24: + environment: AT24 + runs-on: ubuntu-latest + needs: build-and-push-image + permissions: + id-token: write + contents: read + packages: read + steps: + - name: Azure Login + uses: azure/login@v1 + with: + client-id: ${{ secrets.AZURE_CLIENT_ID }} + tenant-id: ${{ secrets.AZURE_TENANT_ID }} + subscription-id: ${{ secrets.AZURE_SUBSCRIPTION_ID }} + - name: Deploy to containerapp + uses: azure/CLI@v1 + with: + inlineScript: > + az config set extension.use_dynamic_install=yes_without_prompt + + az containerapp update \ + --name ${{ vars.CONTAINER_APP_NAME }} \ + --container-name ${{ env.CONTAINER_APP_CONTAINER_NAME }} \ + --resource-group ${{ vars.CONTAINER_APP_RESOURCE_GROUP_NAME }} \ + --image ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ github.sha }} + - name: logout + run: > + az logout From 9439e8be56681f0de99689051c38489f0d1ddefd Mon Sep 17 00:00:00 2001 From: acn-dgopa Date: Tue, 13 Feb 2024 22:01:38 +0100 Subject: [PATCH 2/2] added and updated deploy scripts --- .../workflows/build-deploy-functionapp.yml | 110 +++++++++++++++++- .github/workflows/build-publish-dev.yml | 1 - .../workflows/deploy-fa-to-environment.yml | 56 +++++++++ .github/workflows/deploy-to-environment.yml | 52 +++++++++ 4 files changed, 215 insertions(+), 4 deletions(-) create mode 100644 .github/workflows/deploy-fa-to-environment.yml create mode 100644 .github/workflows/deploy-to-environment.yml diff --git a/.github/workflows/build-deploy-functionapp.yml b/.github/workflows/build-deploy-functionapp.yml index 870fa85..cf585bb 100644 --- a/.github/workflows/build-deploy-functionapp.yml +++ b/.github/workflows/build-deploy-functionapp.yml @@ -15,12 +15,46 @@ on: # # 2. Change these variables for your configuration: env: - AZURE_FUNCTIONAPP_NAME: 'altinn-at22-auditlog-fa' # set this to your function app name on Azure AZURE_FUNCTIONAPP_PACKAGE_PATH: './src/Functions/Altinn.Auth.AuditLog.Functions' # set this to the path to your function app project, defaults to the repository root DOTNET_VERSION: '6.0.x' # set this to the dotnet version to use (e.g. '2.1.x', '3.1.x', '5.0.x') jobs: - build-and-deploy: + deploy-at21: + runs-on: windows-latest + environment: AT21 + permissions: + contents: read + id-token: write + steps: + - name: 'Checkout GitHub Action' + uses: actions/checkout@v3 + + - name: Azure Login + uses: azure/login@v1 + with: + client-id: ${{ secrets.AZURE_CLIENT_ID }} + tenant-id: ${{ secrets.AZURE_TENANT_ID }} + subscription-id: ${{ secrets.AZURE_SUBSCRIPTION_ID }} + + - name: Setup DotNet ${{ env.DOTNET_VERSION }} Environment + uses: actions/setup-dotnet@v3 + with: + dotnet-version: ${{ env.DOTNET_VERSION }} + + - name: 'Resolve Project Dependencies Using Dotnet' + shell: pwsh + run: | + pushd './${{ env.AZURE_FUNCTIONAPP_PACKAGE_PATH }}' + dotnet build --configuration Release --output ./output + popd + + - name: 'Run Azure Functions Action' + uses: Azure/functions-action@v1 + id: fa + with: + app-name: ${{ vars.AZURE_FUNCTIONAPP_NAME }} + package: '${{ env.AZURE_FUNCTIONAPP_PACKAGE_PATH }}/output' + deploy-at22: runs-on: windows-latest environment: AT22 permissions: @@ -53,5 +87,75 @@ jobs: uses: Azure/functions-action@v1 id: fa with: - app-name: ${{ env.AZURE_FUNCTIONAPP_NAME }} + app-name: ${{ vars.AZURE_FUNCTIONAPP_NAME }} + package: '${{ env.AZURE_FUNCTIONAPP_PACKAGE_PATH }}/output' + deploy-at23: + runs-on: windows-latest + environment: AT23 + permissions: + contents: read + id-token: write + steps: + - name: 'Checkout GitHub Action' + uses: actions/checkout@v3 + + - name: Azure Login + uses: azure/login@v1 + with: + client-id: ${{ secrets.AZURE_CLIENT_ID }} + tenant-id: ${{ secrets.AZURE_TENANT_ID }} + subscription-id: ${{ secrets.AZURE_SUBSCRIPTION_ID }} + + - name: Setup DotNet ${{ env.DOTNET_VERSION }} Environment + uses: actions/setup-dotnet@v3 + with: + dotnet-version: ${{ env.DOTNET_VERSION }} + + - name: 'Resolve Project Dependencies Using Dotnet' + shell: pwsh + run: | + pushd './${{ env.AZURE_FUNCTIONAPP_PACKAGE_PATH }}' + dotnet build --configuration Release --output ./output + popd + + - name: 'Run Azure Functions Action' + uses: Azure/functions-action@v1 + id: fa + with: + app-name: ${{ vars.AZURE_FUNCTIONAPP_NAME }} + package: '${{ env.AZURE_FUNCTIONAPP_PACKAGE_PATH }}/output' + deploy-at24: + runs-on: windows-latest + environment: AT24 + permissions: + contents: read + id-token: write + steps: + - name: 'Checkout GitHub Action' + uses: actions/checkout@v3 + + - name: Azure Login + uses: azure/login@v1 + with: + client-id: ${{ secrets.AZURE_CLIENT_ID }} + tenant-id: ${{ secrets.AZURE_TENANT_ID }} + subscription-id: ${{ secrets.AZURE_SUBSCRIPTION_ID }} + + - name: Setup DotNet ${{ env.DOTNET_VERSION }} Environment + uses: actions/setup-dotnet@v3 + with: + dotnet-version: ${{ env.DOTNET_VERSION }} + + - name: 'Resolve Project Dependencies Using Dotnet' + shell: pwsh + run: | + pushd './${{ env.AZURE_FUNCTIONAPP_PACKAGE_PATH }}' + dotnet build --configuration Release --output ./output + popd + + - name: 'Run Azure Functions Action' + uses: Azure/functions-action@v1 + id: fa + with: + app-name: ${{ vars.AZURE_FUNCTIONAPP_NAME }} package: '${{ env.AZURE_FUNCTIONAPP_PACKAGE_PATH }}/output' diff --git a/.github/workflows/build-publish-dev.yml b/.github/workflows/build-publish-dev.yml index e1e5a1a..0f09094 100644 --- a/.github/workflows/build-publish-dev.yml +++ b/.github/workflows/build-publish-dev.yml @@ -15,7 +15,6 @@ env: jobs: build-and-push-image: runs-on: ubuntu-latest - environment: AT22 permissions: contents: read packages: write diff --git a/.github/workflows/deploy-fa-to-environment.yml b/.github/workflows/deploy-fa-to-environment.yml new file mode 100644 index 0000000..c8c21b3 --- /dev/null +++ b/.github/workflows/deploy-fa-to-environment.yml @@ -0,0 +1,56 @@ +name: Deploy DotNet project to Azure Function App + +on: + workflow_dispatch: + inputs: + environment: + type: environment + description: Select the environment + +# CONFIGURATION +# For help, go to https://github.com/Azure/Actions +# +# 1. Set up the following secrets in your repository: +# AZURE_FUNCTIONAPP_PUBLISH_PROFILE +# +# 2. Change these variables for your configuration: +env: + AZURE_FUNCTIONAPP_PACKAGE_PATH: './src/Functions/Altinn.Auth.AuditLog.Functions' # set this to the path to your function app project, defaults to the repository root + DOTNET_VERSION: '6.0.x' # set this to the dotnet version to use (e.g. '2.1.x', '3.1.x', '5.0.x') + +jobs: + deploy-at21: + runs-on: windows-latest + environment: ${{ inputs.environment }} + permissions: + contents: read + id-token: write + steps: + - name: 'Checkout GitHub Action' + uses: actions/checkout@v3 + + - name: Azure Login + uses: azure/login@v1 + with: + client-id: ${{ secrets.AZURE_CLIENT_ID }} + tenant-id: ${{ secrets.AZURE_TENANT_ID }} + subscription-id: ${{ secrets.AZURE_SUBSCRIPTION_ID }} + + - name: Setup DotNet ${{ env.DOTNET_VERSION }} Environment + uses: actions/setup-dotnet@v3 + with: + dotnet-version: ${{ env.DOTNET_VERSION }} + + - name: 'Resolve Project Dependencies Using Dotnet' + shell: pwsh + run: | + pushd './${{ env.AZURE_FUNCTIONAPP_PACKAGE_PATH }}' + dotnet build --configuration Release --output ./output + popd + + - name: 'Run Azure Functions Action' + uses: Azure/functions-action@v1 + id: fa + with: + app-name: ${{ vars.AZURE_FUNCTIONAPP_NAME }} + package: '${{ env.AZURE_FUNCTIONAPP_PACKAGE_PATH }}/output' \ No newline at end of file diff --git a/.github/workflows/deploy-to-environment.yml b/.github/workflows/deploy-to-environment.yml new file mode 100644 index 0000000..91f0cd8 --- /dev/null +++ b/.github/workflows/deploy-to-environment.yml @@ -0,0 +1,52 @@ +name: Deploy to a specific environment +on: + workflow_dispatch: + inputs: + environment: + type: environment + description: Select the environment + version: + type: string + description: Enter the package version + required: true + +env: + REGISTRY: ghcr.io + IMAGE_NAME: altinn/altinn-auth-audit-log + CONTAINER_APP_CONTAINER_NAME: auditlog + +jobs: + deploy: + environment: ${{ inputs.environment }} + runs-on: ubuntu-latest + permissions: + id-token: write + contents: read + packages: read + steps: + - name: Log in to the Container registry + uses: docker/login-action@v3 + with: + registry: ${{ env.REGISTRY }} + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} + - name: Azure Login + uses: azure/login@v1 + with: + client-id: ${{ secrets.AZURE_CLIENT_ID }} + tenant-id: ${{ secrets.AZURE_TENANT_ID }} + subscription-id: ${{ secrets.AZURE_SUBSCRIPTION_ID }} + - name: Deploy to containerapp + uses: azure/CLI@v1 + with: + inlineScript: > + az config set extension.use_dynamic_install=yes_without_prompt + + az containerapp update \ + --name ${{ vars.CONTAINER_APP_NAME }} \ + --container-name ${{ env.CONTAINER_APP_CONTAINER_NAME }} \ + --resource-group ${{ vars.CONTAINER_APP_RESOURCE_GROUP_NAME }} \ + --image ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ inputs.version }} + - name: logout + run: > + az logout