From 44d6253c23f331062be2d0fd9905a278de9b0e69 Mon Sep 17 00:00:00 2001 From: Stanislav Melnichuk Date: Thu, 24 Aug 2023 12:01:07 +0300 Subject: [PATCH] Added option to use custom notification hook url. --- .../java-pull-request-check-template.yml | 20 +++++++++++++++++-- .gitea/workflows/werf-deploy-template.yml | 20 +++++++++++++++++-- 2 files changed, 36 insertions(+), 4 deletions(-) diff --git a/.gitea/workflows/java-pull-request-check-template.yml b/.gitea/workflows/java-pull-request-check-template.yml index e41eddb..652cd7c 100644 --- a/.gitea/workflows/java-pull-request-check-template.yml +++ b/.gitea/workflows/java-pull-request-check-template.yml @@ -7,6 +7,11 @@ on: default: false required: false type: boolean + custom_notification_hook_enabled: + description: "Использовать ли кастомный url хук для оповещений (должен лежать в vault секрете проекта)" + default: false + required: false + type: boolean notification_channel: description: "Канал для оповещений о результатах деплоя" default: internal_projects_notifications @@ -85,8 +90,19 @@ jobs: with: dockerfile: Dockerfile - - name: Get notification url - if: ${{ inputs.notification_enabled && job.status == 'failure' }} + - name: Get general notification url + if: ${{ inputs.notification_enabled && ! inputs.custom_notification_hook_enabled && (job.status == 'success' || job.status == 'failure') }} + uses: https://github.com/hashicorp/vault-action@v2 + with: + url: https://vault.wilix.dev + method: approle + roleId: ${{ secrets.VAULT_ROLE_ID }} + secretId: ${{ secrets.VAULT_SECRET_ID }} + secrets: | + ${{ env.vault_main_base_path }} notification_url | MATTERMOST_WEBHOOK_URL ; + + - name: Get custom notification url + if: ${{ inputs.notification_enabled && inputs.custom_notification_hook_enabled && (job.status == 'success' || job.status == 'failure') }} uses: https://github.com/hashicorp/vault-action@v2 with: url: https://vault.wilix.dev diff --git a/.gitea/workflows/werf-deploy-template.yml b/.gitea/workflows/werf-deploy-template.yml index 5314af7..073621f 100644 --- a/.gitea/workflows/werf-deploy-template.yml +++ b/.gitea/workflows/werf-deploy-template.yml @@ -36,6 +36,11 @@ on: default: true required: false type: boolean + custom_notification_hook_enabled: + description: "Использовать ли кастомный url хук для оповещений (должен лежать в vault секрете проекта)" + default: false + required: false + type: boolean notification_channel: description: "Канал для оповещений о результатах деплоя" default: internal_projects_notifications @@ -121,8 +126,19 @@ jobs: WERF_REPO: ${{ inputs.docker_repo_path }}/${{ inputs.docker_images_path }} WERF_KUBECONFIG_BASE64: ${{ steps.import-secrets.outputs.local_cluster_kube_config_base64 }} - - name: Get notification url - if: ${{ inputs.notification_enabled && (job.status == 'success' || job.status == 'failure') }} + - name: Get general notification url + if: ${{ inputs.notification_enabled && ! inputs.custom_notification_hook_enabled && (job.status == 'success' || job.status == 'failure') }} + uses: https://github.com/hashicorp/vault-action@v2 + with: + url: https://vault.wilix.dev + method: approle + roleId: ${{ secrets.VAULT_ROLE_ID }} + secretId: ${{ secrets.VAULT_SECRET_ID }} + secrets: | + ${{ env.vault_main_base_path }} notification_url | MATTERMOST_WEBHOOK_URL ; + + - name: Get custom notification url + if: ${{ inputs.notification_enabled && inputs.custom_notification_hook_enabled && (job.status == 'success' || job.status == 'failure') }} uses: https://github.com/hashicorp/vault-action@v2 with: url: https://vault.wilix.dev