v1.6.1 release #17
Workflow file for this run
This file contains hidden or 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: Notify on release | |
| on: | |
| release: | |
| types: [published] | |
| jobs: | |
| notify: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v4 | |
| - name: Get files from release, convert into role pings and notify. | |
| shell: pwsh | |
| run: | | |
| $releaseId = ${{ github.event.release.id }} | |
| $releaseUrl = "https://api.github.com/repos/${{ github.repository }}/releases/$releaseId/assets" | |
| $assets = Invoke-RestMethod -Uri $releaseUrl | |
| $releasePath = "${{ github.workspace }}/release" | |
| if (-Not (Test-Path -Path $releasePath)) { | |
| New-Item -ItemType Directory -Path $releasePath | |
| } | |
| foreach ($asset in $assets) { | |
| $assetUrl = $asset.browser_download_url | |
| $assetName = $asset.name | |
| Invoke-WebRequest -Uri $assetUrl -OutFile "$releasePath/$assetName" | |
| } | |
| $roleMap = @{ | |
| "DiscordLab.Bot" = "1326565513392033844" | |
| "DiscordLab.AdvancedLogging" = "1326565584334225469" | |
| "DiscordLab.BotStatus" = "1326565625249660990" | |
| "DiscordLab.ConnectionLogs" = "1326565678601212016" | |
| "DiscordLab.DeathLogs" = "1326565793856622628" | |
| "DiscordLab.Moderation" = "1326565888962596966" | |
| "DiscordLab.ModerationLogs" = "1326565923242639492" | |
| "DiscordLab.SCPSwap" = "1326565946915295365" | |
| "DiscordLab.StatusChannel" = "1326565978125107211" | |
| "DiscordLab.XPSystem" = "1326566015861260298" | |
| "DiscordLab.AdminLogs" = "1327362549368361000" | |
| "DiscordLab.RoundLogs" = "1327631517769531453" | |
| } | |
| $releaseFiles = Get-ChildItem -Path $releasePath | |
| $rolePings = @() | |
| foreach ($file in $releaseFiles) { | |
| $fileName = [System.IO.Path]::GetFileNameWithoutExtension($file.Name) | |
| if ($roleMap.ContainsKey($fileName)) { | |
| $rolePings += "<@&$($roleMap[$fileName])>" | |
| } | |
| } | |
| $rolePingString = $rolePings -join " " | |
| echo "role_pings=$rolePingString" >> $GITHUB_OUTPUT | |
| $webhookUrl = "${{ secrets.DISCORD_WEBHOOK }}" | |
| $releaseTag = "${{ github.ref }}" | |
| $repositoryUrl = "${{ github.server_url }}/${{ github.repository }}" | |
| $releaseMessage = "New release available! $rolePingString`n$repositoryUrl/releases/tag/$releaseTag" | |
| $body = @{ | |
| content = $releaseMessage | |
| } | ConvertTo-Json | |
| Invoke-RestMethod -Uri $webhookUrl -Method Post -Body $body -ContentType "application/json" |