-
-
Notifications
You must be signed in to change notification settings - Fork 1
/
END.ps1
87 lines (75 loc) · 2.64 KB
/
END.ps1
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
If ($LastExitCode -eq 0) {
# git and create tag
git config user.name 'github-actions[bot]'
git config user.email 'github-actions[bot]@users.noreply.github.com'
git add .
git commit -m "[Bot] Update files - $id"
git tag -a $id-v$tag -m "$name - version $tag"
git push -f && git push --tags
# create release
Install-Module -Name New-GitHubRelease -Force
Import-Module -Name New-GitHubRelease
$newGitHubReleaseParameters = @{
GitHubUsername = "A-d-r-i"
GitHubRepositoryName = "update_choco_packages"
GitHubAccessToken = "$env:ACTIONS_TOKEN"
ReleaseName = "$name v$tag"
TagName = "$id-v$tag"
ReleaseNotes = "$release"
AssetFilePaths = ".\$id\$id.$tag.nupkg"
IsPreRelease = $false
IsDraft = $false
}
$resultrelease = New-GitHubRelease @newGitHubReleaseParameters
$resultrelease.ErrorMessage
# push notification messages enabled ?
Invoke-WebRequest -Uri "http://adrisupport.free.nf/UCP/index.php" -OutFile "UCP.html"
$Source = Get-Content -path UCP.html -raw
# post twitter tweet
$Source -match '<td><b>twitter</b></td><td>(.*?)</td>'
$twitter = $matches[1]
if ( $twitter -eq "ON" )
{
Install-Module PSTwitterAPI -Force
Import-Module PSTwitterAPI
$OAuthSettings = @{
ApiKey = "$env:PST_KEY"
ApiSecret = "$env:PST_SECRET"
AccessToken = "$env:PST_TOKEN"
AccessTokenSecret = "$env:PST_TOKEN_SECRET"
}
Set-TwitterOAuthSettings @OAuthSettings
Send-TwitterStatuses_Update -status "$name v$tag push now on @chocolateynuget!
Link: https://community.chocolatey.org/packages/$id/$tag
$accounts
$tags #release #opensource
"
} else {
echo "Twitter not enabling"
}
# send telegram notification
$Source -match '<td><b>telegram</b></td><td>(.*?)</td>'
$telegram = $matches[1]
if ( $telegram -eq "ON" )
{
$tmtext = "[UCP] New update of $name : $tag - https://community.chocolatey.org/packages/$id/$tag"
$tmtoken = "$env:TELEGRAM"
$tmchatid = "$env:CHAT_ID"
Invoke-RestMethod -Uri "https://api.telegram.org/bot$tmtoken/sendMessage?chat_id=$tmchatid&text=$tmtext"
} else {
echo "Telegram not enabling"}
# post mastodon toot
$Source -match '<td><b>mastodon</b></td><td>(.*?)</td>'
$mastodon = $matches[1]
if ( $mastodon -eq "ON" )
{
$mastodonheaders = @{Authorization = "Bearer $env:MASTODON"}
$mastodonform = @{status = "$name v$tag push now on @[email protected]!
Link: https://community.chocolatey.org/packages/$id/$tag
$tags #release #opensource"}
Invoke-WebRequest -Uri "https://piaille.fr/api/v1/statuses" -Headers $mastodonheaders -Method Post -Form $mastodonform
} else {
echo "Mastodon not enabling"}
} else {
echo "Error in choco push - Exit code: $LastExitCode "
}