<commit_before>﻿#requires -Version 3
<#
.Synopsis
    Check GIT repository for new commits. If found sync the changes into
    the current SMA environment

.Parameter RepositoryName
#>
Workflow Monitor-GitRepositoryChange
{
    Param(
    )
    $ErrorActionPreference = [System.Management.Automation.ActionPreference]::Stop
    
    $GlobalVars = Get-BatchAutomationVariable -Prefix 'Global' `
                                              -Name 'AutomationAccountName',
                                                    'SubscriptionName',
                                                    'SubscriptionAccessCredentialName',
                                                    'RunbookWorkerAccessCredentialName',
                                                    'ResourceGroupName'
    do
    {
        $NextRun = (Get-Date).AddSeconds(30)
        
        $RepositoryInformationJSON = Get-AutomationVariable -Name 'ContinuousIntegration-RepositoryInformation'
        $SubscriptionAccessCredential = Get-AutomationPSCredential -Name $GlobalVars.SubscriptionAccessCredentialName
        $RunbookWorkerAccessCredential = Get-AutomationPSCredential -Name $GlobalVars.RunbookWorkerAccessCredentialName
        
        Try
        {
            $UpdatedRepositoryInformation = Sync-GitRepositoryToAzureAutomation -AutomationAccountName $GlobalVars.AutomationAccountName `
                                                                                -SubscriptionName $GlobalVars.SubscriptionName `
                                                                                -SubscriptionAccessCredential $SubscriptionAccessCredential `
                                                                                -RunbookWorkerAccessCredenial $RunbookWorkerAccessCredential `
                                                                                -RepositoryInformationJSON $RepositoryInformationJSON `
                                                                                -ResourceGroupName $GlobalVars.ResourceGroupName

            Set-AutomationVariable -Name 'ContinuousIntegration-RepositoryInformation' `
                                    -Value $UpdatedRepositoryInformation
        }
        Catch
        {
            Write-Exception -Stream Warning -Exception $_
        }

        do
        {
            Start-Sleep -Seconds 5
            Checkpoint-Workflow
            $Sleeping = (Get-Date) -lt $NextRun
        } while($Sleeping)
    }
    while($true)
}
<commit_msg>change to a psscript<commit_after>﻿#requires -Version 3
<#
.Synopsis
    Check GIT repository for new commits. If found sync the changes into
    the current SMA environment
#>
Param(
)

$ErrorActionPreference = [System.Management.Automation.ActionPreference]::Stop
    
$GlobalVars = Get-BatchAutomationVariable -Prefix 'Global' `
                                            -Name 'AutomationAccountName',
                                                'SubscriptionName',
                                                'SubscriptionAccessCredentialName',
                                                'RunbookWorkerAccessCredentialName',
                                                'ResourceGroupName'
do
{
    $NextRun = (Get-Date).AddSeconds(30)
        
    $RepositoryInformationJSON = Get-AutomationVariable -Name 'ContinuousIntegration-RepositoryInformation'
    $SubscriptionAccessCredential = Get-AutomationPSCredential -Name $GlobalVars.SubscriptionAccessCredentialName
    $RunbookWorkerAccessCredential = Get-AutomationPSCredential -Name $GlobalVars.RunbookWorkerAccessCredentialName
        
    Try
    {
        $UpdatedRepositoryInformation = Sync-GitRepositoryToAzureAutomation -AutomationAccountName $GlobalVars.AutomationAccountName `
                                                                            -SubscriptionName $GlobalVars.SubscriptionName `
                                                                            -SubscriptionAccessCredential $SubscriptionAccessCredential `
                                                                            -RunbookWorkerAccessCredenial $RunbookWorkerAccessCredential `
                                                                            -RepositoryInformationJSON $RepositoryInformationJSON `
                                                                            -ResourceGroupName $GlobalVars.ResourceGroupName

        Set-AutomationVariable -Name 'ContinuousIntegration-RepositoryInformation' `
                                -Value $UpdatedRepositoryInformation
    }
    Catch
    {
        Write-Exception -Stream Warning -Exception $_
    }

    do
    {
        Start-Sleep -Seconds 5
        Checkpoint-Workflow
        $Sleeping = (Get-Date) -lt $NextRun
    } while($Sleeping)
}
while($true)

{'fraction_non_alphanumeric': 0.054981397271599834, 'fraction_numerical': 0.0016535758577924762, 'mean_word_length': 1.3813976377952757, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 51, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '134710', 'n_tokens_mistral': 933, 'n_tokens_neox': 927, 'n_words': 175}