Skip to content

Instantly share code, notes, and snippets.


Gustavo Américo GustavoAmerico

View GitHub Profile
GustavoAmerico / Delete_Remote_Branch_By_NamePattern.ps1
Last active Nov 11, 2022
[danger] Esse comando é utilizado para apagar multiplos branchs que utilizam o mesmo padrão de nomenclatura
View Delete_Remote_Branch_By_NamePattern.ps1
ATENÇÃO: Esse comando não verifica se as alterações forma mescladas com a branch principal!! O branch vai ser apagado
$remoteName = 'origin')
git branch --all --merged | Select-String -Pattern $branchNamePattern
| %{$_.ToString().Replace("remotes/$remoteName/",'').Trim()}
| %{ git push origin :$_ }
GustavoAmerico / CopyPRTagsToBuild.ps1
Last active Oct 22, 2022
Script to copy Azure DevOps pullrequest tags to AzureDevOps Pipeline Build
View CopyPRTagsToBuild.ps1
$tagNameExpression = "target-*"
# Define the PR URI based in azure devops pipeline runtime variables
$prUri = "$(System.CollectionUri)/$(System.TeamProject)/_apis/git/repositories/$(Build.Repository.ID)/pullRequests/$(System.PullRequest.PullRequestId)/labels?api-version=6.0-preview.1";
$buildUri= "$(System.CollectionUri)/$(System.TeamProject)/_apis/build/builds/$(Build.BuildId)/tags";
# Get PullRequest Details
$FoundTags = Invoke-WebRequest `
-Uri $prUri `
-Authentication Bearer `
GustavoAmerico / scale_up_and_down_alldeployment.ps1
Created Feb 10, 2022
Scale all deployment from namespace on single line, this command should be used for scale down dev and hmo env on day off
View scale_up_and_down_alldeployment.ps1
[Parameter(Mandatory=$true)][System.String] $namespace,
kubectl get deployments -n $namespace --output jsonpath="{range .items[*]}{}{'\n'}{end}" |%{
kubectl scale deployment/$_ -n $namespace --replicas $numberOfReplicas;
GustavoAmerico / AddOrUpdateTableAndColumnDescription
Last active Apr 22, 2021
Procedure for add or update SQL Server table and column description
View AddOrUpdateTableAndColumnDescription
CREATE PROCEDURE dbo.PROC_AddOrUpdateTableAndColumnDescription
@fullName varchar(255),
@description varchar(255)
Table exemple: <schema>.<table name> dbo.MyTable
Column Exemple: <schema>.<table name>.<column name> dbo.MyTable.Id
/*Extrai o primeiro valor antes do ponto, representa o schema*/
View azure-storage-file-as-windows-disk.ps1
# This script help you setting an azure storage account as a network folder or windows disk
# Is need Azure CLI installed
$resourceGroupName = "<resource group>",
$storageAccountName = "<storage account name>",
$subscription = "<subscription name or id>",
GustavoAmerico / Cleanup-Azure-Container-Registry.ps1
Last active May 13, 2021
View Cleanup-Azure-Container-Registry.ps1
[Parameter(Mandatory=$true)] $acrAccountName,
$takeLastImages = 5,
$likeRepositories = '',
$selectTagPattern = '^([0-9]+(\.)?){3,4}$'
#Get all repository where the name like with parameter $likeRepositories
$repositories = az acr repository list --name $acrAccountName --query ("[?contains(@, '" + $likeRepositories + "')]") | ConvertFrom-Json ;
GustavoAmerico / azure-database-export.ps1
Created Sep 18, 2019
Script para executar a exportação do Azure SQL Database para um Azure Storage
View azure-database-export.ps1
#Esse script pode ser utilizado em tarefa do AzureDevOps para executar o backup da base de dados dentro do processo de Build ou Release
$BaseStorageUri = "https://<your-storage>",
$StorageKey = "<Shared key>",
$DatabaseName = @( "db1","db2","db3"),
$ResourceGroupName = "<database-resource-group-name>",
$ServerName = "<database-server-name>",
$serverAdmin = "<database-user-with-permission-login>",
$serverPassword = "<database-user-with-permission-password>"