|
| 1 | +# Any *.PSA.ps1 file will be run when PSA runs. |
| 2 | + |
| 3 | +# A good thing to do at the start of this file is to connect. |
| 4 | + |
| 5 | +Connect-BlueSky |
| 6 | + |
| 7 | +# If $env:AT_PROTOCOL_HANDLE or $env:AT_PROTOCOL_EMAIL is set, it will be treated as the username |
| 8 | +# If $env:AT_PROTOCOL_APP_PASSWORD is set, it will be treated as the App Password. |
| 9 | +# _Never_ use your actual BlueSky password |
| 10 | + |
| 11 | +# Once we're connected, we can do anything our app password allows. |
| 12 | + |
| 13 | +# However, you _might_ want to output some information first, so that you can see you're connected. |
| 14 | + |
| 15 | +Get-BskyActorProfile -Actor $env:AT_PROTOCOL_HANDLE -Cache | Out-Host |
| 16 | + |
| 17 | +# To ensure you're not going to send a skeet on every checkin, it's a good idea to ask what GitHub is up to |
| 18 | + |
| 19 | +# There will be a variable, $GitHubEvent, that contains information about the event. |
| 20 | + |
| 21 | +# A fairly common scenario is to perform an annoucement whenever a PR is merged. |
| 22 | + |
| 23 | +$isMergeToMain = |
| 24 | + ($gitHubEvent.head_commit.message -match "Merge Pull Request #(?<PRNumber>\d+)") -and |
| 25 | + $gitHubEvent.ref -eq 'refs/heads/main' |
| 26 | + |
| 27 | +Push-Location ($PSScriptRoot | Split-Path) |
| 28 | + |
| 29 | +$importedModule = Import-Module .\EZOut.psd1 -Global -PassThru |
| 30 | +$importedModule | Out-Host |
| 31 | +$moduleAndVersion = "$($importedModule.Name) $($importedModule.Version)" |
| 32 | + |
| 33 | +$isManuallyTriggered = $gitHubEvent.psobject.properties["inputs"] |
| 34 | + |
| 35 | +if ($isMergeToMain -or $isManuallyTriggered) { |
| 36 | + |
| 37 | + $fullMessage = @( |
| 38 | + $importedModule.PrivateData.Taglines | Get-Random |
| 39 | + |
| 40 | + "$($importedModule.PrivateData.PSData.ProjectURI)" |
| 41 | + ) -join [Environment]::NewLine |
| 42 | + |
| 43 | + $sendSplat = [Ordered]@{ |
| 44 | + Text = $fullMessage |
| 45 | + } |
| 46 | + if ($importedModule.PrivateData.PSData.ProjectURI) { |
| 47 | + $sendSplat.WebCard = @{Url=$importedModule.PrivateData.PSData.ProjectURI} |
| 48 | + $sendSplat.LinkPattern = @{$importedModule.Name=$importedModule.PrivateData.PSData.ProjectURI} |
| 49 | + } |
| 50 | + |
| 51 | + Send-AtProto @sendSplat |
| 52 | +} |
| 53 | + |
| 54 | +Pop-Location |
0 commit comments