Fix file I/O thread safety #252
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: GitHub Feed Notification | |
| on: | |
| push: | |
| jobs: | |
| notify: | |
| runs-on: windows-latest | |
| steps: | |
| - name: Send Discord GitHub Feed Notification | |
| shell: pwsh | |
| env: | |
| COMMIT_MESSAGE: ${{ github.event.head_commit.message }} | |
| run: | | |
| $webhookUrl = "${{ secrets.DISCORD_GITHUB_FEED_WEBHOOK }}" | |
| if (-not $webhookUrl) { | |
| Write-Warning "DISCORD_GITHUB_FEED_WEBHOOK secret is not set. Skipping notification." | |
| exit 0 | |
| } | |
| # Only proceed if there's a head commit | |
| $commitHash = "${{ github.sha }}" | |
| if (-not $commitHash) { | |
| exit 0 | |
| } | |
| $repo = "${{ github.repository }}" | |
| $branch = "${{ github.ref_name }}" | |
| $actor = "${{ github.actor }}" | |
| $compareUrl = "${{ github.event.compare }}" | |
| if (-not $compareUrl) { $compareUrl = "https://github.com/$repo/commits/$branch" } | |
| $commitUrl = "${{ github.event.head_commit.url }}" | |
| if (-not $commitUrl) { $commitUrl = "https://github.com/$repo/commit/$commitHash" } | |
| $commitShort = $commitHash.Substring(0, 7) | |
| $commitMessage = $env:COMMIT_MESSAGE | |
| if ([string]::IsNullOrWhiteSpace($commitMessage)) { | |
| $commitMessage = "No commit message provided." | |
| } elseif ($commitMessage.Length -gt 1000) { | |
| $commitMessage = $commitMessage.Substring(0, 1000) + "..." | |
| } | |
| $payload = @{ | |
| embeds = @(@{ | |
| title = "❖ New Commit on $branch ❖" | |
| description = "**Author:** $actor`n**Commit:** ``$commitShort```n`n### ❯ Message`n" + '```text' + "`n$commitMessage`n" + '```' | |
| color = 7506394 | |
| image = @{ url = "https://cdn.discordapp.com/attachments/1493841758864412715/1512177063572934717/banner.png" } | |
| author = @{ name = $actor; icon_url = "https://github.com/${actor}.png" } | |
| footer = @{ text = "PocketMC GitHub Feed" } | |
| }) | |
| components = @(@{ | |
| type = 1 | |
| components = @( | |
| @{ type = 2; style = 5; label = "View Commit"; url = $commitUrl }, | |
| @{ type = 2; style = 5; label = "View Comparison"; url = $compareUrl } | |
| ) | |
| }) | |
| } | |
| $json = $payload | ConvertTo-Json -Depth 5 | |
| Invoke-RestMethod -Uri $webhookUrl -Method Post -Body $json -ContentType "application/json" |