Add more parameters for deploy template.

This commit is contained in:
Stanislav Melnichuk 2023-05-30 10:38:51 +03:00
parent a1a845cd62
commit af1eef10ed
2 changed files with 42 additions and 11 deletions

View File

@ -2,10 +2,11 @@ on:
workflow_call: workflow_call:
inputs: inputs:
stand_name: stand_name:
description: 'Stand name, has influence on addresses and settings.' description: 'Общее наименование стенда'
required: true required: true
type: string type: string
kube_namespace: kube_namespace:
description: 'Местоположение для деплоя в кластере'
required: true required: true
type: string type: string
docker_repo_path: docker_repo_path:
@ -13,6 +14,11 @@ on:
required: false required: false
type: string type: string
docker_images_path: docker_images_path:
description: 'Относительный путь для образов проекта'
required: true
type: string
vault_secrets_base_path:
description: 'Базовый путь для секретов проекта в vault'
required: true required: true
type: string type: string
has_secrets: has_secrets:
@ -20,7 +26,19 @@ on:
required: false required: false
type: boolean type: boolean
werf_secret_key_vault_location: werf_secret_key_vault_location:
required: true description: "Имя секрета, содержащего ключ для дешифрования werf, расположенного по базовому пути в vault"
default: werf_secret_key
required: false
type: string
notification_enabled:
description: "Включение оповещений о разворачивании, требуется иметь url для оповещений в vault"
default: true
required: false
type: boolean
notification_channel:
description: "Канал для оповещений о результатах деплоя"
default: internal_projects_notifications
required: false
type: string type: string
werf_debug: werf_debug:
default: false default: false
@ -32,8 +50,6 @@ on:
VAULT_SECRET_ID: VAULT_SECRET_ID:
required: true required: true
# FIXME Убрать хардкод для токена оповещений и канала оповещений
jobs: jobs:
converge: converge:
name: Deploy stand name: Deploy stand
@ -45,6 +61,7 @@ jobs:
with: with:
fetch-depth: 0 fetch-depth: 0
# FIXME Эти секреты нужно будет сделать полностью различными для проектов, идеально - краткосрочные генерируемые vault
- id: import-secrets - id: import-secrets
uses: https://github.com/hashicorp/vault-action@v2 uses: https://github.com/hashicorp/vault-action@v2
with: with:
@ -56,7 +73,6 @@ jobs:
dev/wilix/main/data/ci local_cluster_kube_config_base64 ; dev/wilix/main/data/ci local_cluster_kube_config_base64 ;
dev/wilix/main/data/ci docker_registry_username ; dev/wilix/main/data/ci docker_registry_username ;
dev/wilix/main/data/ci docker_registry_password ; dev/wilix/main/data/ci docker_registry_password ;
dev/wilix/loop/data/ci/loop-vizor notification_url | MATTERMOST_WEBHOOK_URL ;
- name: Login to nexus docker - name: Login to nexus docker
uses: https://github.com/docker/login-action@v2 uses: https://github.com/docker/login-action@v2
@ -73,7 +89,7 @@ jobs:
werf helm repo add wilix-dysnix https://artifacts.wilix.dev/repository/helm-dysnix werf helm repo add wilix-dysnix https://artifacts.wilix.dev/repository/helm-dysnix
werf helm repo add wilix-bitnami https://artifacts.wilix.dev/repository/helm-bitnami werf helm repo add wilix-bitnami https://artifacts.wilix.dev/repository/helm-bitnami
- name: Get werf secret key if needed - name: Get werf secret key if need
if: ${{ inputs.has_secrets }} if: ${{ inputs.has_secrets }}
uses: https://github.com/hashicorp/vault-action@v2 uses: https://github.com/hashicorp/vault-action@v2
with: with:
@ -82,7 +98,7 @@ jobs:
roleId: ${{ secrets.VAULT_ROLE_ID }} roleId: ${{ secrets.VAULT_ROLE_ID }}
secretId: ${{ secrets.VAULT_SECRET_ID }} secretId: ${{ secrets.VAULT_SECRET_ID }}
secrets: | secrets: |
${{ inputs.werf_secret_key_vault_location }} | WERF_SECRET_KEY ; ${{ inputs.vault_secrets_base_path }} ${{ inputs.werf_secret_key_vault_location }} | WERF_SECRET_KEY ;
- name: Setup secrets if need - name: Setup secrets if need
if: ${{ inputs.has_secrets }} if: ${{ inputs.has_secrets }}
@ -101,13 +117,25 @@ jobs:
WERF_REPO: ${{ inputs.docker_repo_path }}/${{ inputs.docker_images_path }} WERF_REPO: ${{ inputs.docker_repo_path }}/${{ inputs.docker_images_path }}
WERF_KUBECONFIG_BASE64: ${{ steps.import-secrets.outputs.local_cluster_kube_config_base64 }} WERF_KUBECONFIG_BASE64: ${{ steps.import-secrets.outputs.local_cluster_kube_config_base64 }}
- name: Get notification url
if: ${{ inputs.notification_enabled }}
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: |
${{ inputs.vault_secrets_base_path }} notification_url | MATTERMOST_WEBHOOK_URL ;
- name: prepare success notification body - name: prepare success notification body
uses: https://github.com/finnp/create-file-action@master uses: https://github.com/finnp/create-file-action@master
if: ${{ inputs.notification_enabled }}
env: env:
FILE_NAME: "mattermost.json" FILE_NAME: "mattermost.json"
FILE_DATA: | FILE_DATA: |
{ {
"channel": "project_loop_notifications", "channel": "${{ inputs.notification_channel }}",
"attachments": [ "attachments": [
{ {
"fallback": "Деплой прошел успешно для ${{ gitea.repository }}", "fallback": "Деплой прошел успешно для ${{ gitea.repository }}",
@ -126,12 +154,12 @@ jobs:
- name: prepare failed notification body - name: prepare failed notification body
uses: https://github.com/finnp/create-file-action@master uses: https://github.com/finnp/create-file-action@master
if: failure() if: ${{ inputs.notification_enabled && failure() }}
env: env:
FILE_NAME: "mattermost.json" FILE_NAME: "mattermost.json"
FILE_DATA: | FILE_DATA: |
{ {
"channel": "project_loop_notifications", "channel": "${{ inputs.notification_channel }}",
"attachments": [ "attachments": [
{ {
"fallback": "Деплой упал для ${{ gitea.repository }}", "fallback": "Деплой упал для ${{ gitea.repository }}",
@ -150,4 +178,4 @@ jobs:
- name: loop fail notification - name: loop fail notification
uses: https://github.com/mattermost/action-mattermost-notify@master uses: https://github.com/mattermost/action-mattermost-notify@master
if: ${{ job.status == 'success' || job.status == 'failure' }} if: ${{ inputs.notification_enabled && (job.status == 'success' || job.status == 'failure') }}

View File

@ -0,0 +1,3 @@
Общие шаблоны для Gitea Actions.
ВНИМАНИЕ! Открытый доступ, нельзя выкладывать любую чувствительную информацию.