Skip to content

Commit

Permalink
[DEVOPS-530] Replace Azure PowerShell actions and update logging (#148)
Browse files Browse the repository at this point in the history
<details open>
<summary><a href="https://amuniversal.atlassian.net/browse/DEVOPS-530"
title="DEVOPS-530" target="_blank">DEVOPS-530</a></summary>
  <br />
  <table>
    <tr>
      <th>Summary</th>
<td>Update Boley DNS workflow failing on "Record already exists"</td>
    </tr>
    <tr>
      <th>Type</th>
      <td>
<img alt="Bug"
src="https://amuniversal.atlassian.net/rest/api/2/universal_avatar/view/type/issuetype/avatar/10308?size=medium"
/>
        Bug
      </td>
    </tr>
    <tr>
      <th>Status</th>
      <td>In Development Env</td>
    </tr>
    <tr>
      <th>Points</th>
      <td>N/A</td>
    </tr>
    <tr>
      <th>Labels</th>
      <td>-</td>
    </tr>
  </table>
</details>
<!--
do not remove this marker as it will break action-jira-linter's
functionality.
  added_by_jira_lint
-->
---

<!-- Please make sure you read the contribution guidelines and then fill
out the blanks below.

Please format the PR title appropriately based on the type of change:
  [JIRA-XXX]: <description>
-->

## Description

- Replace Azure PowerShell actions and update logging
  - Only update record if it needs to be changed
  - Move timeout to update DNS step
  - Convert `azure/powershell` actions to base pwsh shell scripts

## Related Links

<!-- List any links related to this pull request here

Replace "JIRA-XXX" with the your Jira issue key -->

- Jira Issue: DEVOPS-530
  • Loading branch information
ebronson68 committed Sep 3, 2024
1 parent 4747c22 commit c408c71
Showing 1 changed file with 50 additions and 55 deletions.
105 changes: 50 additions & 55 deletions .github/workflows/update-addns.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -31,70 +31,65 @@ on:

jobs:
update-dns:
runs-on: [self-hosted, Windows, boley]
continue-on-error: false
timeout-minutes: 10
name: Update Boley DNS
runs-on: [self-hosted, Windows, boley]
steps:
- name: Retrieve Application information
id: getappinfo
uses: azure/powershell@v2
with:
azPSVersion: "latest"
inlineScript: |
Install-Module -Name AzTable -Force
Import-Module AzTable
shell: pwsh
run: |
Install-Module -Name AzTable -Force
Import-Module AzTable
$storageAccountName = "${{ inputs.storageAccountName }}"
$storageAccountKey = ${{ secrets.storageAccountKey }}
$appInfoTableName = "${{ inputs.appInfoTableName }}"
$storageAccountName = "${{ inputs.storageAccountName }}"
$storageAccountKey = ${{ secrets.storageAccountKey }}
$appInfoTableName = "${{ inputs.appInfoTableName }}"
$storageContext = New-AzStorageContext -StorageAccountName $storageAccountName -StorageAccountKey $storageAccountKey
$storageContext = New-AzStorageContext -StorageAccountName $storageAccountName -StorageAccountKey $storageAccountKey
#Get Storage table
try {
$appInfoTable = (Get-AzStorageTable -Name $appInfoTableName -Context $storageContext -ErrorAction Stop).CloudTable
}
catch {
Write-Error -Message "Error accessing cloud $appInfoTableName table. Error message was: $_.Exception.Message"
return
}
#Get Storage table
try {
$appInfoTable = (Get-AzStorageTable -Name $appInfoTableName -Context $storageContext -ErrorAction Stop).CloudTable
}
catch {
Write-Error -Message "Error accessing cloud $appInfoTableName table. Error message was: $_.Exception.Message"
return
}
$appInfo = Get-AzTableRow -Table $appInfoTable -PartitionKey "${{ inputs.repositoryName }}" -RowKey "${{ inputs.environment }}"
$appInfo = Get-AzTableRow -Table $appInfoTable -PartitionKey "${{ inputs.repositoryName }}" -RowKey "${{ inputs.environment }}"
$applicationName = $appInfo.ApplicationName
$version = $appInfo.Version
$keyVault = $appInfo.KeyVault
$hostName = $appInfo.HostName
$domainName = $appInfo.DomainName
$ingressFqdn = $appInfo.IngressFqdn
$healthCheckPath = $appInfo.HealthCheckPath
$aksIngress = $appInfo.AksIngress
$applicationName = $appInfo.ApplicationName
$version = $appInfo.Version
$keyVault = $appInfo.KeyVault
$hostName = $appInfo.HostName
$domainName = $appInfo.DomainName
$ingressFqdn = $appInfo.IngressFqdn
$healthCheckPath = $appInfo.HealthCheckPath
$aksIngress = $appInfo.AksIngress
echo "applicationName=$applicationName" >> $env:GITHUB_ENV
echo "version=$version" >> $env:GITHUB_ENV
echo "keyVault=$keyVault" >> $env:GITHUB_ENV
echo "hostName=$hostName" >> $env:GITHUB_ENV
echo "domainName=$domainName" >> $env:GITHUB_ENV
echo "applicationIngressFqdn=$ingressFqdn" >> $env:GITHUB_ENV
echo "healthCheckPath=$healthCheckPath" >> $env:GITHUB_ENV
echo "aksIngress=$aksIngress" >> $env:GITHUB_ENV
echo "applicationName=$applicationName" >> $env:GITHUB_ENV
echo "version=$version" >> $env:GITHUB_ENV
echo "keyVault=$keyVault" >> $env:GITHUB_ENV
echo "hostName=$hostName" >> $env:GITHUB_ENV
echo "domainName=$domainName" >> $env:GITHUB_ENV
echo "applicationIngressFqdn=$ingressFqdn" >> $env:GITHUB_ENV
echo "healthCheckPath=$healthCheckPath" >> $env:GITHUB_ENV
echo "aksIngress=$aksIngress" >> $env:GITHUB_ENV
- name: Update Internal Boley DNS
uses: azure/powershell@v2
with:
azPSVersion: "latest"
inlineScript: |
try {
Add-DnsServerResourceRecordCName -Name "${{ env.hostName }}" -HostNameAlias "${{ env.aksIngress}}" -ZoneName "${{ env.domainName }}" -ComputerName ${{ secrets.domainController }}
}
catch {
Write-Host "Record Already Exists"
}
Get-DnsServerResourceRecord -ZoneName "${{ env.domainName }}" -ComputerName ${{ secrets.domainController }} | Where-Object HostName -eq "${{ env.aksIngress }}" | Format-List
try {
Sync-DnsServerZone -Name "${{ env.domainName }}" -ComputerName ${{ secrets.domainController }}
}
catch {
Write-Host "Skipping zone sync. Zone is currently being synced."
}
timeout-minutes: 15
shell: pwsh
run: |
try {
Add-DnsServerResourceRecordCName -Name "${{ env.hostName }}" -HostNameAlias "${{ env.aksIngress}}" -ZoneName "${{ env.domainName }}" -ComputerName ${{ secrets.domainController }}
}
catch {
Write-Host "Record Already Exists"
}
Get-DnsServerResourceRecord -ZoneName "${{ env.domainName }}" -ComputerName ${{ secrets.domainController }} | Where-Object HostName -eq "${{ env.aksIngress }}" | Format-List
try {
Sync-DnsServerZone -Name "${{ env.domainName }}" -ComputerName ${{ secrets.domainController }}
}
catch {
Write-Host "Skipping zone sync. Zone is currently being synced."
}

0 comments on commit c408c71

Please sign in to comment.