Skip to content

Commit

Permalink
Added devnew CD and cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
Helder Pinto committed Apr 9, 2024
1 parent cb6c4e5 commit 19f0dfe
Show file tree
Hide file tree
Showing 2 changed files with 86 additions and 0 deletions.
34 changes: 34 additions & 0 deletions .github/workflows/cleanup-dev-new.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
name: AOE Clean Up (DEV NEW)
on:
workflow_dispatch:
schedule:
- cron: '0 0 * * *' # This will run the action every day at midnight
permissions:
id-token: write
contents: read
jobs:
AOE-CD:
environment: devnew
runs-on: ubuntu-latest
steps:
- run: echo "This job is now running on a ${{ runner.os }} server hosted by GitHub for the ${{ github.ref }} branch of the ${{ github.repository }} repository!"
- name: Installing modules
shell: pwsh
run: |
Set-PSRepository PSGallery -InstallationPolicy Trusted
Install-Module -Name Az.Accounts,Az.Resources -Force
- name: Check out repository code
uses: actions/checkout@v3
- name: Login via Az module
uses: azure/login@v2
with:
client-id: ${{ secrets.AZURE_CLIENT_ID }}
tenant-id: ${{ secrets.AZURE_TENANT_ID }}
subscription-id: ${{ secrets.AZURE_SUBSCRIPTION_ID }}
enable-AzPSSession: true
- name: Testing PowerShell script call
shell: pwsh
run: |
$aoeResource = Get-AzResource -Id "/subscriptions/${{ secrets.AZURE_SUBSCRIPTION_ID }}/resourceGroups/${{ secrets.AOE_NAMEPREFIX }}-rg/providers/Microsoft.Automation/automationAccounts/${{ secrets.AOE_NAMEPREFIX }}-auto" -ExpandProperties
if ((Get-Date) -gt $aoeResource.Properties.creationTime.AddDays(${{ vars.AOE_MAXAGEDAYS }})) { Write-Host "Deleting Resource Group"; Remove-AzResourceGroup -Name "${{ secrets.AOE_NAMEPREFIX }}-rg" -Force -AsJob } else { Write-Host "Resource Group is not old enough to delete" }
- run: echo "🍏 This job's status is ${{ job.status }}."
52 changes: 52 additions & 0 deletions .github/workflows/continuous-deployment-dev-new.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
name: AOE Continuous Deployment (DEV NEW)
on:
workflow_dispatch:
push:
branches:
- dev
permissions:
id-token: write
contents: read
jobs:
AOE-CD:
environment: devnew
runs-on: ubuntu-latest
env:
AZURE_SUBSCRIPTION_ID: ${{ secrets.AZURE_SUBSCRIPTION_ID }}
AOE_SQL_ADMIN: ${{ secrets.AOE_SQL_ADMIN }}
AOE_SQL_PASSWD: ${{ secrets.AOE_SQL_PASSWD }}
AOE_LOCATION: ${{ secrets.AOE_LOCATION }}
AOE_NAMEPREFIX: ${{ secrets.AOE_NAMEPREFIX }}
steps:
- run: echo "This job is now running on a ${{ runner.os }} server hosted by GitHub for the ${{ github.ref }} branch of the ${{ github.repository }} repository!"
- name: Installing modules
shell: pwsh
run: |
Set-PSRepository PSGallery -InstallationPolicy Trusted
Install-Module -Name Az.Accounts,Az.Resources,Az.Storage,Az.OperationalInsights,Az.Sql,Az.Automation,Microsoft.Graph.Authentication,Microsoft.Graph.Identity.DirectoryManagement -Force
- name: Check out repository code
uses: actions/checkout@v3
- name: Login via Az module
uses: azure/login@v2
with:
client-id: ${{ secrets.AZURE_CLIENT_ID }}
tenant-id: ${{ secrets.AZURE_TENANT_ID }}
subscription-id: ${{ secrets.AZURE_SUBSCRIPTION_ID }}
enable-AzPSSession: true
- name: Create Deployment Settings JSON file
run: |
echo '{
"SubscriptionId": "'"$AZURE_SUBSCRIPTION_ID"'",
"NamePrefix": "'"$AOE_NAMEPREFIX"'",
"WorkspaceReuse": "n",
"DeployWorkbooks": "y",
"SqlAdmin": "'"$AOE_SQL_ADMIN"'",
"SqlPass": "'"$AOE_SQL_PASSWD"'",
"TargetLocation": "'"$AOE_LOCATION"'",
"DeployBenefitsUsageDependencies": "n"
}' > ./deploymentSettings.json
- name: Testing PowerShell script call
shell: pwsh
run: |
./Deploy-AzureOptimizationEngine.ps1 -SilentDeploymentSettingsPath ./deploymentSettings.json -TemplateUri "https://raw.githubusercontent.com/helderpinto/AzureOptimizationEngine/dev/azuredeploy.bicep"
- run: echo "🍏 This job's status is ${{ job.status }}."

0 comments on commit 19f0dfe

Please sign in to comment.