Skip to content

.Platform: Update API Specs file #104

.Platform: Update API Specs file

.Platform: Update API Specs file #104

name: ".Platform: Update API Specs file"
on:
workflow_dispatch:
schedule:
- cron: "0 12 * * 0" # Weekly Sunday Update
env:
pipelinePrincipalGitUserName: "CARMLPipelinePrincipal"
pipelinePrincipalGitUserEmail: "[email protected]"
jobs:
job_update_api_specs_file:
name: "Update file"
if: github.ref == 'refs/heads/main' || github.ref == 'refs/heads/master'
runs-on: ubuntu-latest
steps:
- name: "Checkout"
uses: actions/checkout@v4
with:
fetch-depth: 0
token: "${{ secrets.PLATFORM_REPO_UPDATE_PAT }}" # Sets general GIT credentials up
# [Setup] task(s)
# ---------------
- name: "Setup agent"
shell: pwsh
run: |
# Load used functions
. (Join-Path $env:GITHUB_WORKSPACE 'utilities' 'pipelines' 'sharedScripts' 'Set-EnvironmentOnAgent.ps1')
# Define PS modules to install on the runner
$modules = @(
@{ Name = 'Az.Accounts' },
@{ Name = 'Az.Resources' }
)
# Set agent up
Set-EnvironmentOnAgent -PSModules $modules
- name: Azure Login
uses: Azure/login@v1
with:
creds: ${{ secrets.AZURE_CREDENTIALS }}
enable-AzPSSession: true
- name: "Update file"
shell: pwsh
run: |
# Load used functions
. (Join-Path $env:GITHUB_WORKSPACE 'utilities' 'tools' 'platform' 'Set-ApiSpecsFile.ps1')
$functionInput = @{
SpecsFilePath = Join-Path $env:GITHUB_WORKSPACE 'utilities' 'src' 'apiSpecsList.json'
IncludePreview = $true
IncludeExternalSources = $true
}
Write-Verbose "Invoke task with" -Verbose
Write-Verbose ($functionInput | ConvertTo-Json | Out-String) -Verbose
Set-ApiSpecsFile @functionInput -Verbose
- name: "Push changes"
shell: pwsh
run: |
git config --global user.email '${{ env.pipelinePrincipalGitUserEmail }}'
git config --global user.name '${{ env.pipelinePrincipalGitUserName }}'
git pull
git status
git add .
git commit -m 'Push updated API Specs file'
git push