Skip to content

Commit

Permalink
🔖 ci(main) Add Secrets Pipleines CI-CD ADO
Browse files Browse the repository at this point in the history
  • Loading branch information
Oscar Andres Macias Narvaez​ committed Sep 1, 2023
1 parent c0942e3 commit f91838e
Show file tree
Hide file tree
Showing 10 changed files with 150 additions and 0 deletions.
5 changes: 5 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"githubPullRequests.ignoredPullRequestBranches": [
"main"
]
}
3 changes: 3 additions & 0 deletions Azure DevOps/Secrets/.sops.yaml.enc
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
Salted__@T�NAV�5��'���[ w�(�f}YbL�~S �Φ�V���)4~@�[ ˕������^��芴m�i�����h�J�\wV
����]�� �X ���\]׆ŵ�౹�.��X�im�STa��J�%�Q�*�M��$
ɀ�Yȇp��
Expand Down
14 changes: 14 additions & 0 deletions Azure DevOps/Secrets/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# version [1.0.0]

## 20230901

- Include: Settings for mitigate hardcode.
![Cifrate_SOPS_YAML][def]
![Variables_Group][def2]
![Variables][def3]
![Artifacts][def4]

[def]: ./src/img/image-1.png
[def2]: ./src/img/image.png
[def3]: ./src/img/variable.png
[def4]: ./src/img/Artifacts.png
54 changes: 54 additions & 0 deletions Azure DevOps/Secrets/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
# Azure: Cifrado de secretos con SOPS (Pipeline)

## Descripcion

- Un saludo, espero se encuentre bien
- A continuación detallaremos, desde Infraestructura - CyberSecurity, la guía del paso a paso para:
- Que cualquier colaborador de Desrarrollo de Producto en la compañia, pueda Cifrar Secretos de repositorios o estructuras de archivos en repos desde una llave.

## Requerimientos

- Tener acceso, como lectura y escritura en cambios hacia el repositorio.

## Guía

- Crear una rama feature/test desde Main.

## Etapas

### Construcción

#### appsettings.json

- Abrir el archivo AppSettings.json.

~~~ JSON
{
"Logging": {
"LogLevel": {
"Default": "",
"Microsoft.AspNetCore": ""
}
},
"Cache": [
{
"Name": "",
"Hours": "",
"Minutes": "",
"seconds": ""
}
],
}
~~~

- Editar con el schema del archivo con claves y valores a cifrar.
- Commitear los cambios.
- Correr el pipeline "ci.yml", correspondiente al repositorio.

### Publicaciones

- Descargar el artefacto.

### Pruebas

- validar el resultado.
16 changes: 16 additions & 0 deletions Azure DevOps/Secrets/appsettings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{
"Logging": {
"LogLevel": {
"Default": "Information",
"Microsoft.AspNetCore": "Information"
}
},
"Cache": [
{
"Name": "",
"Hours": "",
"Minutes": "",
"seconds": ""
}
]
}
58 changes: 58 additions & 0 deletions Azure DevOps/Secrets/pipeline/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
---
name: "$(BuildDefinitionName)_$(Build.SourceBranchName)_$(Major).$(Minor).$(Patch)"

variables:
- name: Major
value: 1
- name: Minor
value: 0
- name: Patch
value: $[counter(format('{0}.{1}', variables['Major'], variables['Minor']), 0)]

resources:
repositories:
- repository: $ORGANIZATION-infra
type: git
name: "$PROJECT/$ORGANIZATION-infra"

trigger:
tags:
include:
- '*'
branches:
include:
- main
paths:
include:
- src
exclude:
- docs
- pipelines

pool: "Agent Pool $ORGANIZATION"

stages:
- stage: "Build"
jobs:
- deployment: build
continueOnError: false
environment: "dev"
variables:
- group: dev-key-vault-credential
- group: sops-key-vault

strategy:
runOnce:
deploy:
steps:
- checkout: self

- script: |
eval $(SOPS_PAT)
displayName: 'Download sops.yaml'
- template: "templates/installSOPS.yml@$ORGANIZATION-infra"

- template: "templates/encryptSOPS.yml@$ORGANIZATION-infra"
parameters:
FileToEncryptWithPath: "$(System.DefaultWorkingDirectory)/appsettings.json"
Binary file added Azure DevOps/Secrets/src/img/Artifacts.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Azure DevOps/Secrets/src/img/image-1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Azure DevOps/Secrets/src/img/image.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Azure DevOps/Secrets/src/img/variable.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit f91838e

Please sign in to comment.