-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathREADME.md.ps1
More file actions
121 lines (100 loc) · 2.94 KB
/
Copy pathREADME.md.ps1
File metadata and controls
121 lines (100 loc) · 2.94 KB
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
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
<#
.SYNOPSIS
Organization Repos
.DESCRIPTION
Gets the public repos in this organization
#>
param(
# The GitHub organization.
# This should default to the repository owner.
[string]$Organization = $(
if ($env:GITHUB_REPOSITORY_OWNER) {
$env:GITHUB_REPOSITORY_OWNER
} else {
'PoshWeb'
}
),
[string]
$Logo = "/PoshWeb-Animated.svg",
[string]
$Intro = "
We make a few cool projects
"
)
if (-not $script:Cache) {$script:Cache = [Ordered]@{}}
$orgInfoUrl = "https://api.github.com/orgs/$Organization"
if (-not $script:Cache[$orgInfoUrl]) {
Write-Warning "Getting $orgInfoUrl"
$script:Cache[$orgInfoUrl] = Invoke-RestMethod -Uri $orgInfoUrl
}
$projectsUrl = "https://api.github.com/orgs/$Organization/repos?per_page=100"
if (-not $script:Cache[$projectsUrl]) {
Write-Warning "Getting $projectsUrl"
$script:Cache[$projectsUrl] = Invoke-RestMethod -Uri $projectsUrl |
Where-Object Name -notmatch '^.github'
}
if ($logo) {
"
<div align='center'>
<img src='$Logo' style='height:400px' />
</div>
"
}
"# $($script:Cache[$orgInfoUrl].name)"
"## $($script:Cache[$orgInfoUrl].description)"
$Intro
"### Repo of the Build:"
$randomRepo = $script:Cache[$projectsUrl] | Get-Random
"#### [$($randomRepo.Name)]($($randomRepo.html_url))"
"> $($randomRepo.description)"
"### Recently Updated"
$(
""
$script:Cache[$projectsUrl] |
Sort-Object updated_at -Descending |
Select-Object -First 10 |
Get-Random -Count 10 |
ForEach-Object {
$project = $_
"* [$($project.Name)]($($project.html_url))"
}
""
)
"### All Projects"
"| |Projects| |"
"|:-|:-:|-:|"
foreach (
$project in $script:Cache[$projectsUrl] |
Sort-Object stargazers_count -Descending
) {
$LinkTo =
if ($project.custom_properties.Website) {
$project.custom_properties.Website
} else {
$project.html_url
}
$projectBadges = @(
"[
)/$($(
$project.name
)))]($(
$LinkTo
)/stargazers)"
if ($project.custom_properties.DeployBadge) {
"[)]($(
$project.custom_properties.DeployBadge -replace '/[^/]+$'
))"
}
if ($project.custom_properties.PowerShellGalleryID) {
$galleryId = $project.custom_properties.PowerShellGalleryID
"[]($(
"https://www.powershellgallery.com/packages/$galleryId"
))"
}
) -join ' '
"| |<h3>$("[$($project.name)]($($LinkTo))</h3>",
"<h4>[$($project.description -replace '\|', '\|')]($($LinkTo))</h4>",
"$projectBadges" -join
' ')| |"
}