Skip to content

Commit

Permalink
Merge branch 'main' into story/DEVOPS-389/test-self-hosted-github-runner
Browse files Browse the repository at this point in the history
  • Loading branch information
ebronson68 authored Mar 11, 2024
2 parents f7ae995 + 5617b76 commit b1f8d1e
Show file tree
Hide file tree
Showing 5 changed files with 161 additions and 27 deletions.
20 changes: 14 additions & 6 deletions .github/workflows/bump-nuget-version.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,18 @@ jobs:
steps:
- name: Checkout
uses: actions/checkout@v3
with:
fetch-depth: 2

- name: Check for existing version bump commit
id: check-version-bump
run: |
if git log --oneline | grep -q "Bump ${{ inputs.libraryName }} Nuget Version"; then
echo "version-bump-exists=true" >> $GITHUB_OUTPUT
else
echo "version-bump-exists=false" >> $GITHUB_OUTPUT
fi
- name: Check modified files
if: ${{ steps.check-version-bump.outputs.version-bump-exists == 'false' }}
id: files-changed
run: |
while IFS= read -r FILE; do
Expand All @@ -38,10 +46,10 @@ jobs:
if echo "${FILE}" | grep -Eq "${PROJECT_PATH}" ; then
echo "models-changed=true" >> $GITHUB_OUTPUT
fi
done < <(git diff --name-only HEAD^ HEAD)
done < <(git diff --name-only development...HEAD)
- name: Run Increment-Version.ps1
if: ${{ github.actor != 'amutechtest' && steps.files-changed.outputs.models-changed == 'true' }}
if: ${{ steps.files-changed.outputs.models-changed == 'true' && steps.check-version-bump.outputs.version-bump-exists == 'false' }}
shell: pwsh
run: |
$ProjectName = "${{ inputs.projectName }}"
Expand Down Expand Up @@ -87,15 +95,15 @@ jobs:
}
- name: Commit Changes
if: ${{ ! inputs.libraryName }}
if: ${{ ! inputs.libraryName && steps.check-version-bump.outputs.version-bump-exists == 'false' }}
uses: stefanzweifel/git-auto-commit-action@v4
with:
commit_user_name: amutechtest
commit_user_email: amu_deploy@amuniversal.com
commit_message: ⬆️ Bump Nuget version

- name: Commit Changes
if: ${{ inputs.libraryName }}
if: ${{ inputs.libraryName && steps.check-version-bump.outputs.version-bump-exists == 'false' }}
uses: stefanzweifel/git-auto-commit-action@v4
with:
commit_user_name: amutechtest
Expand Down
17 changes: 0 additions & 17 deletions .github/workflows/do-not-merge.yaml

This file was deleted.

4 changes: 2 additions & 2 deletions .github/workflows/jira-lint.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@ jobs:
- name: Retrieve Jira issue key from PR
id: jira-ticket
run: |
PR_BRANCH=$(echo "${{ env.githubPrBranch }}" | grep -Eo "\b[A-Z][A-Z0-9_]+-[1-9][0-9]*" || true)
PR_TITLE=$(echo "${{ env.githubPrTitle }}" | grep -Eo "\b[A-Z][A-Z0-9_]+-[1-9][0-9]*" || true)
PR_BRANCH=$(echo "${{ env.githubPrBranch }}" | grep -Eio "\b[A-Z][A-Z0-9_]+-[1-9][0-9]*" || true)
PR_TITLE=$(echo "${{ env.githubPrTitle }}" | grep -Eio "\b[A-Z][A-Z0-9_]+-[1-9][0-9]*" || true)
for var in ${PR_BRANCH} ${PR_TITLE}; do JIRA_TICKET_ID=$(echo $var | grep -E ".") && break ; done
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/publish-nuget-package.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ jobs:
- name: Push ${{ steps.project-name.outputs.projectName }} Packages
if: ${{ inputs.libraries }}
run: |
LIBRARIES="${{ inputs.libraries }}"
LIBRARIES=(${{ inputs.libraries }})
for LIBRARY in "${LIBRARIES[@]}"; do
cd "${{ github.workspace }}/${{ steps.project-name.outputs.projectName }}/${LIBRARY}/bin/Release/"
dotnet nuget push "*.nupkg" --api-key "${{ secrets.GITHUB_TOKEN }}" --source "https://nuget.pkg.github.com/andrews-mcmeel-universal/index.json" --skip-duplicate
Expand Down
145 changes: 144 additions & 1 deletion .github/workflows/update-game-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -26,13 +26,156 @@ jobs:
with:
ref: ${{ inputs.checkoutRef }}

- name: Login via Az module
uses: azure/login@v1
with:
creds: "${{ secrets.AZURE_CREDENTIALS }}"
enable-AzPSSession: true

- name: Generate .env file from Azure Key Vaults
uses: Andrews-McMeel-Universal/get-envs@v1
with:
azurecredentials: ${{ secrets.AZURE_CREDENTIALS }}
environment: ${{ inputs.environment }}

- name: Install SimplySql PowerShell module
shell: pwsh
run: |
Install-Module -Name SimplySql -RequiredVersion 1.9.1 -Force -AllowClobber
- name: Install Azure PowerShell module
shell: pwsh
run: |
Install-Module -Name Az -Force -AllowClobber
- name: Update Game Configs
shell: pwsh
run: |
./deployments/scripts/Update-CloudGameConfigs.ps1 -DBConnectionString "${{ env.DB_CONNECTION_STRING }}" -StorageAccountKey "${{ env.STORAGE_ACCOUNT_KEY }}" -ContainerName "${{ env.STORAGE_ACCOUNT_CONTAINER }}" -UpdatedBy 'GitHub Actions'
$StorageAccountName = "gameconfigs"
$StorageAccountTable = "GameConfigs"
$UpdatedBy = "AMU Agents"
$CDNBasePath = "gameconfigs.amuniversal.com"
$CacheControl = "max-age=86400"
Import-Module SimplySql
Import-Module Az
Function Get-MimeType {
param (
[parameter(Mandatory = $true)]
[string]$FileExtension
)
switch ($FileExtension) {
".png" { $MimeType = "image/png" }
".json" { $MimeType = "application/json" }
".jpg" { $MimeType = "image/jpeg" }
".jpeg" { $MimeType = "image/jpeg" }
".gif" { $MimeType = "image/gif" }
".svg" { $MimeType = "image/svg" }
}
return $MimeType
}
$BasePath = Get-Location
Write-Host "Base path is: $BasePath" -ForegroundColor DarkGray
$GameConfigsBasePath = Join-Path $BasePath $StorageAccountName
Write-Host "Game Configs base path is: $GameConfigsBasePath" -ForegroundColor DarkGray
# Script has to be ran from project basepath
if (!(Test-Path -Path $GameConfigsBasePath)) {
$CurrentLocation = Get-Location
$ErrorMessage = "Must be ran from project's base path. Current location is: $CurrentLocation"
Write-Error $ErrorMessage
throw $ErrorMessage
}
# Set Storage Context
$StorageContext = New-AzStorageContext -StorageAccountName $StorageAccountName -StorageAccountKey "${{ env.STORAGE_ACCOUNT_KEY }}"
try {
$Connection = New-Object Npgsql.NpgsqlConnection;
$Connection.ConnectionString = "${{ env.DB_CONNECTION_STRING }}"
$Connection.Open()
}
catch {
$ErrorMessage = "Connection Failed Error message was: $_.Exception.Message"
Write-Error $ErrorMessage
throw $ErrorMessage
}
# Remove Existing Storage Blobs
Write-Host "Removing existing blobs in '${{ env.STORAGE_ACCOUNT_CONTAINER }}' container." -ForegroundColor DarkGray
Get-AzStorageBlob -Container "${{ env.STORAGE_ACCOUNT_CONTAINER }}" -Context $StorageContext | Remove-AzStorageBlob
# Remove entries in GameConfigs table.
Write-Host "Removing current data in '$StorageAccountTable' table." -ForegroundColor DarkGray
$DeleteQuery = "DELETE FROM ""$StorageAccountTable"""
try {
$Command = $Connection.CreateCommand()
$Command.CommandText = $DeleteQuery
[Void]$Command.ExecuteNonQuery()
}
catch {
$ErrorMessage = "Error on Query. Query was: '$DeleteQuery'. Error is: $_.Exception.Message"
Write-Error $ErrorMessage
throw $ErrorMessage
}
$Features = Get-ChildItem -path $GameConfigsBasePath -Directory
$Features | ForEach-Object {
$FeatureId = $_.Name
$Products = Get-ChildItem -Path (Join-Path $GameConfigsBasePath $FeatureId) -Directory
$Products | ForEach-Object {
$Product = $_.Name
$GameFilesPath = $_.FullName
$GameFiles = Get-ChildItem -Path $GameFilesPath -File
$GameFiles | ForEach-Object {
$FileName = $_.name
$FilePath = $_.FullName
$FileMimeType = Get-MimeType($_.Extension)
if (!$FileMimeType) {
$ErrorMessage = "File type not included in MimeType list. Please add it before trying again."
Write-Error $ErrorMessage
throw $ErrorMessage
}
$BlobName = "$FeatureId/$Product/$FileName"
$BlobProperties = @{"ContentType" = $FileMimeType; "CacheControl" = $CacheControl; };
$BlobMetaData = @{"FeatureId" = $FeatureId }
# Create Blob
Write-Host "Updating Storage Blob Content with file: '$FilePath'" -ForegroundColor DarkGray
Set-AzStorageBlobContent -File $FilePath -Container "${{ env.STORAGE_ACCOUNT_CONTAINER }}" -Blob $BlobName -Properties $BlobProperties -Context $StorageContext `
-Metadata $BlobMetaData -Force
# Update Database
$UriPath = "$CDNBasePath/${{ env.STORAGE_ACCOUNT_CONTAINER }}/$BlobName"
$UpdateDate = (Get-Date -Format "yyyy-MM-dd HH:mm:ss")
$InsertQuery = "INSERT INTO ""GameConfigs"" (""ConfigName"", ""UriPath"", ""MimeType"", ""OriginalFileName"", ""FeatureId"", ""CreatedDate"", ""CreatedBy"", `
""ModifiedDate"", ""ModifiedBy"", ""ActiveFlag"") `
VALUES ('$Product', '$UriPath', '$FileMimeType', '$FileName', '$FeatureId', '$UpdateDate', '$UpdatedBy', '$UpdateDate', `
'$UpdatedBy', '1') "
try {
$Command = $Connection.CreateCommand()
$Command.CommandText = $InsertQuery
[Void]$Command.ExecuteNonQuery()
}
catch {
$ErrorMessage = "Error on Query. Query was: $InsertQuery. Error is: $_.Exception.Message"
Write-Error $ErrorMessage
throw $ErrorMessage
}
}
}
}
[Void]$Connection.Close()

0 comments on commit b1f8d1e

Please sign in to comment.