File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 8181 ' Add-Vs' ,
8282 ' Get-ArgumentsFromConfig' ,
8383 ' Get-BuildDirectory' ,
84+ ' Get-CheckoutState' ,
8485 ' Get-Extension' ,
8586 ' Get-ExtensionConfig' ,
8687 ' Get-ExtensionName' ,
Original file line number Diff line number Diff line change 1+ Function Get-CheckoutState {
2+ <#
3+ . SYNOPSIS
4+ Get whether the current directory already contains the expected repository checkout.
5+ . PARAMETER Repository
6+ Expected owner/repository name.
7+ #>
8+ [OutputType ([string ])]
9+ param (
10+ [Parameter (Mandatory = $false , Position = 0 , HelpMessage = ' Expected owner/repository name.' )]
11+ [string ] $Repository = ' '
12+ )
13+ begin {
14+ }
15+ process {
16+ if ([string ]::IsNullOrWhiteSpace($Repository )) {
17+ $Repository = $env: GITHUB_REPOSITORY
18+ }
19+
20+ if ([string ]::IsNullOrWhiteSpace($Repository ) -or -not (Test-Path .git)) {
21+ return $false .ToString().ToLowerInvariant()
22+ }
23+
24+ try {
25+ $originUrl = git remote get-url origin 2> $null
26+ if ($LASTEXITCODE -ne 0 -or [string ]::IsNullOrWhiteSpace($originUrl )) {
27+ return $false .ToString().ToLowerInvariant()
28+ }
29+
30+ return ($originUrl -match " (^|[:/])$ ( [regex ]::Escape($Repository )) (\.git)?$" ).ToString().ToLowerInvariant()
31+ } catch {
32+ return $false .ToString().ToLowerInvariant()
33+ }
34+ }
35+ end {
36+ }
37+ }
Original file line number Diff line number Diff line change @@ -58,7 +58,15 @@ inputs:
5858runs :
5959 using : composite
6060 steps :
61+ - name : Check checkout state
62+ id : checkout-state
63+ shell : pwsh
64+ run : |
65+ Import-Module ${{ github.action_path }}\BuildPhpExtension -Force
66+ Add-Content -Path $env:GITHUB_OUTPUT -Value "checkout_state=$(Get-CheckoutState -Repository $env:GITHUB_REPOSITORY)" -Encoding utf8
67+
6168 - name : Checkout
69+ if : ${{ steps.checkout-state.outputs.checkout_state == 'false' }}
6270 uses : actions/checkout@v5
6371
6472 - name : Check VS components
You can’t perform that action at this time.
0 commit comments