Skip to content

Commit 09be1b5

Browse files
🚀 [Feature]: Rename RunStartedAt attribute to StartedAt for workflow runs + example update (#480)
## Description This pull request refactors PowerShell scripts for managing GitHub apps and updates a property name in the `GitHubWorkflowRun` class for consistency. The changes focus on improving code clarity, standardizing naming conventions, and enhancing maintainability. ### 🌟 Updates to `GitHubWorkflowRun` class: * Renamed the `RunStartedAt` property to `StartedAt` for consistency with other properties. * Updated the constructor to reflect the property name change from `RunStartedAt` to `StartedAt`. ### Refactoring of GitHub app management scripts: * Removed the `examples/Apps/AppManagement.ps1` example entirely, consolidating its functionality into `examples/Apps/EnterpriseApps.ps1` for better organization. * Updated `examples/Apps/EnterpriseApps.ps1` to: - Replace hardcoded app IDs with a more flexible `$ClientIDs` array. - Introduce parameters for private key and client ID authentication (`$PrivateKey` and `$ClientID`). - Simplify organization filtering by using `$org.Name` instead of `$org.login`. ## Type of change <!-- Use the check-boxes [x] on the options that are relevant. --> - [ ] 📖 [Docs] - [ ] 🪲 [Fix] - [ ] 🩹 [Patch] - [ ] ⚠️ [Security fix] - [x] 🚀 [Feature] - [ ] 🌟 [Breaking change] ## Checklist <!-- Use the check-boxes [x] on the options that are relevant. --> - [x] I have performed a self-review of my own code - [x] I have commented my code, particularly in hard-to-understand areas
1 parent 67650ba commit 09be1b5

File tree

3 files changed

+20
-47
lines changed

3 files changed

+20
-47
lines changed

examples/Apps/AppManagement.ps1

Lines changed: 0 additions & 10 deletions
This file was deleted.

examples/Apps/EnterpriseApps.ps1

Lines changed: 18 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -1,40 +1,23 @@
1-
$appIDs = @(
2-
'qweqweqwe',
3-
'qweqweqweqwe'
4-
)
5-
6-
$organization = '*'
7-
filter Install-GithubApp {
8-
param(
9-
[Parameter()]
10-
[string] $Enterprise = 'msx',
1+
$ClientID = ''
2+
$PrivateKey = @'
3+
-----BEGIN RSA PRIVATE KEY-----
114
12-
[Parameter()]
13-
[string] $Organization = '*',
5+
-----END RSA PRIVATE KEY-----
6+
'@
7+
Connect-GitHub -ClientID $ClientID -PrivateKey $PrivateKey
8+
Connect-GitHubApp -Enterprise 'msx'
149

15-
[Parameter(
16-
Mandatory,
17-
ValueFromPipeline
18-
)]
19-
[string] $AppID
20-
)
10+
# The apps you want to install on orgs in the enterprise
11+
$ClientIDs = @(
12+
'Iv1.f26b61bc99e69405'
13+
)
14+
$Enterprise = 'msx'
15+
$Organization = '*'
2116

22-
process {
23-
$installableOrgs = Get-GitHubOrganization -Enterprise $Enterprise
24-
$orgs = $installableOrgs | Where-Object { $_.login -like $organization }
25-
foreach ($org in $orgs) {
26-
foreach ($appIDitem in $AppID) {
27-
Install-GitHubApp -Enterprise $Enterprise -Organization $org.login -ClientID $appIDitem -RepositorySelection all | ForEach-Object {
28-
[PSCustomObject]@{
29-
Organization = $org.login
30-
AppID = $appIDitem
31-
}
32-
}
33-
}
34-
}
17+
$installableOrgs = Get-GitHubOrganization -Enterprise $Enterprise
18+
$orgs = $installableOrgs | Where-Object { $_.Name -like $Organization }
19+
foreach ($org in $orgs) {
20+
foreach ($ClientID in $ClientIDs) {
21+
Install-GitHubApp -Enterprise $Enterprise -Organization $org.Name -ClientID $ClientID -RepositorySelection all
3522
}
3623
}
37-
38-
$appIDs | Install-GitHubApp -Organization $organization
39-
40-
$installation = Get-GitHubAppInstallation

src/classes/public/Workflows/GitHubWorkflowRun.ps1

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@
8585

8686
# The start time of the latest run. Resets on re-run.
8787
# Example: "2023-01-01T12:01:00Z"
88-
[System.Nullable[datetime]] $RunStartedAt
88+
[System.Nullable[datetime]] $StartedAt
8989

9090
# The head commit details.
9191
# Example: (nullable-simple-commit object)
@@ -126,7 +126,7 @@
126126
$this.PullRequests = $_.pull_requests
127127
$this.CreatedAt = $_.created_at
128128
$this.UpdatedAt = $_.updated_at
129-
$this.RunStartedAt = $_.run_started_at
129+
$this.StartedAt = $_.run_started_at
130130
$this.Actor = [GitHubUser]::new($_.actor)
131131
$this.TriggeringActor = [GitHubUser]::new($_.triggering_actor)
132132
$this.HeadCommit = $_.head_commit

0 commit comments

Comments
 (0)