forked from 51Degrees/common-ci
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathnightly-package-update.ps1
81 lines (63 loc) · 2.12 KB
/
nightly-package-update.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
param (
[Parameter(Mandatory=$true)]
[string]$RepoName,
[Parameter(Mandatory=$true)]
[string]$OrgName,
[Parameter(Mandatory=$true)]
[string]$GitHubToken,
[string]$GitHubUser = "",
[string]$GitHubEmail = "",
[string]$RunId = $Null,
[bool]$DryRun = $False
)
. ./constants.ps1
if ($GitHubUser -eq "") {
$GitHubUser = $DefaultGitUser
}
if ($GitHubEmail -eq "") {
$GitHubEmail = $DefaultGitEmail
}
# This token is used by the gh command.
Write-Output "Setting GITHUB_TOKEN"
$env:GITHUB_TOKEN="$GitHubToken"
Write-Output "::group::Configure Git"
./steps/configure-git.ps1 -GitHubToken $GitHubToken -GitHubUser $GitHubUser -GitHubEmail $GitHubEmail
Write-Output "::endgroup::"
Write-Output "::group::Clone $RepoName"
./steps/clone-repo.ps1 -RepoName $RepoName -OrgName $OrgName -Branch $PackageUpdateBranch
Write-Output "::endgroup::"
if ($LASTEXITCODE -ne 0) {
exit $LASTEXITCODE
}
Write-Output "::group::Update Package Dependencies"
./steps/run-repo-script.ps1 -RepoName $RepoName -OrgName $OrgName -ScriptName "update-packages.ps1" -DryRun $DryRun
Write-Output "::endgroup::"
if ($LASTEXITCODE -ne 0) {
exit $LASTEXITCODE
}
Write-Output "::group::Check for Changes"
./steps/has-changed.ps1 -RepoName $RepoName
Write-Output "::endgroup::"
if ($LASTEXITCODE -eq 0) {
Write-Output "::group::Commit Changes"
./steps/commit-changes.ps1 -RepoName $RepoName -Message "REF: Updated packages."
Write-Output "::endgroup::"
if ($LASTEXITCODE -ne 0) {
exit $LASTEXITCODE
}
Write-Output "::group::Push Changes"
./steps/push-changes.ps1 -RepoName $RepoName -Branch $PackageUpdateBranch -DryRun $DryRun
Write-Output "::endgroup::"
if ($LASTEXITCODE -ne 0) {
exit $LASTEXITCODE
}
Write-Output "::group::Create Pull Request"
./steps/pull-request-to-main.ps1 -RepoName $RepoName -Message "Updated packages." -DryRun $DryRun
Write-Output "::endgroup::"
if ($LASTEXITCODE -ne 0) {
exit $LASTEXITCODE
}
} else {
Write-Output "$($env:CI -eq 'true' ? '::warning::' : '')No package changes, so not creating a pull request."
exit 0
}