Daily check for updates #917
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Daily check for updates | |
on: | |
schedule: | |
- cron: "0 0,6,9,12,15,18 * * *" | |
workflow_dispatch: null | |
jobs: | |
job: | |
name: Run | |
runs-on: ubuntu-latest | |
steps: | |
- name: Generate hash from Marketplace items | |
id: generate_hash | |
shell: pwsh | |
run: | | |
$results = Invoke-WebRequest -Method POST -UseBasicParsing ` | |
-Uri https://marketplace.visualstudio.com/_apis/public/gallery/extensionquery?api-version=3.0-preview.1 ` | |
-Body '{"filters":[{"criteria":[{"filterType":8,"value":"Microsoft.VisualStudio.Code"},{"filterType":12,"value":"4096"},{"filterType":7,"value":"ms-dynamics-smb.al"}],"pageNumber":1,"pageSize":50,"sortBy":0,"sortOrder":0}],"assetTypes":[],"flags":0x192}' ` | |
-ContentType application/json | ConvertFrom-Json | |
# Loop through results and remove the statistics property | |
foreach ($result in $results.results) { | |
foreach ($extension in $result.extensions) { | |
$extension.PSObject.Properties.Remove("statistics") | |
} | |
} | |
$results = $($results | ConvertTo-Json -Compress -Depth 8) | |
$md5 = [System.Security.Cryptography.MD5]::Create() | |
$bytes = [System.Text.Encoding]::UTF8.GetBytes($results) | |
$hashBytes = $md5.ComputeHash($bytes) | |
$hashString = [BitConverter]::ToString($hashBytes).ToLower() -replace '-', '' | |
Write-Host "Calculated hash is: $($hashString)" | |
echo "hash=$($hashString)" >> $env:GITHUB_OUTPUT | |
- uses: actions/cache/restore@v4 | |
id: get_hash | |
with: | |
path: ${{ runner.temp }}/hash.txt | |
key: al-marketplace-hash-${{ steps.generate_hash.outputs.hash }} | |
fail-on-cache-miss: false | |
- name: Create file with hash value | |
id: create_file_with_hash | |
if: steps.get_hash.outputs.cache-hit != 'true' | |
shell: pwsh | |
env: | |
HASH: ${{ steps.generate_hash.outputs.hash }} | |
RUNNER_TEMP: ${{ runner.temp }} | |
run: | | |
$hashFilePath = Join-Path $env:RUNNER_TEMP 'hash.txt' | |
$env:HASH | Set-Content -Path $hashFilePath | |
- name: Add new hash value to cache | |
id: add_hash | |
if: steps.get_hash.outputs.cache-hit != 'true' | |
uses: actions/cache/save@v4 | |
with: | |
path: ${{ runner.temp }}/hash.txt | |
key: al-marketplace-hash-${{ steps.generate_hash.outputs.hash }} | |
- uses: actions/checkout@v4 | |
if: steps.get_hash.outputs.cache-hit != 'true' | |
- name: Trigger for executing check of new release of the AL Language | |
if: steps.get_hash.outputs.cache-hit != 'true' | |
shell: pwsh | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
run: | | |
gh workflow run NewReleaseAL.yml --ref main -f update-release=true |