Skip to content

Commit 7baaff9

Browse files
committed
Fix logs in extension module
Run import at the top in action.yml
1 parent d1456c3 commit 7baaff9

2 files changed

Lines changed: 17 additions & 13 deletions

File tree

extension/BuildPhpExtension/private/Get-CheckoutState.ps1

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -16,20 +16,24 @@ Function Get-CheckoutState {
1616
if([string]::IsNullOrWhiteSpace($Repository)) {
1717
$Repository = $env:GITHUB_REPOSITORY
1818
}
19-
19+
$checkout_state = $true;
2020
if([string]::IsNullOrWhiteSpace($Repository) -or -not(Test-Path .git)) {
21-
return $false.ToString().ToLowerInvariant()
21+
$checkout_state = $false
2222
}
23-
2423
try {
2524
$originUrl = git remote get-url origin 2>$null
2625
if($LASTEXITCODE -ne 0 -or [string]::IsNullOrWhiteSpace($originUrl)) {
27-
return $false.ToString().ToLowerInvariant()
26+
$checkout_state = $false
2827
}
29-
30-
return ($originUrl -match "(^|[:/])$([regex]::Escape($Repository))(\.git)?$").ToString().ToLowerInvariant()
28+
$checkout_state = ($originUrl -match "(^|[:/])$([regex]::Escape($Repository))(\.git)?$")
3129
} catch {
32-
return $false.ToString().ToLowerInvariant()
30+
$checkout_state = $false
31+
}
32+
$checkout_state = $checkout_state.ToString().ToLowerInvariant()
33+
if($null -ne $env:GITHUB_OUTPUT) {
34+
Add-Content -Path $env:GITHUB_OUTPUT -Value "checkout_state=$checkout_state" -Encoding utf8
35+
} else {
36+
return $checkout_state
3337
}
3438
}
3539
end {

extension/action.yml

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -58,12 +58,16 @@ inputs:
5858
runs:
5959
using: composite
6060
steps:
61+
- name: Import module
62+
shell: pwsh
63+
run: |
64+
Add-Content -Path $env:GITHUB_ENV -Value "PSModulePath=${{ github.action_path }};$env:PSModulePath" -Encoding utf8
65+
6166
- name: Check checkout state
6267
id: checkout-state
6368
shell: pwsh
6469
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
70+
Get-CheckoutState -Repository $env:GITHUB_REPOSITORY
6771
6872
- name: Checkout
6973
if: ${{ steps.checkout-state.outputs.checkout_state == 'false' }}
@@ -73,7 +77,6 @@ runs:
7377
id: vs-check
7478
shell: pwsh
7579
run: |
76-
Import-Module ${{ github.action_path }}\BuildPhpExtension -Force
7780
Get-VsCacheInfo -PhpVersion ${{ inputs.php-version }}
7881
7982
- name: Restore VS components cache
@@ -88,7 +91,6 @@ runs:
8891
if: steps.vs-cache.outputs.cache-hit == 'true'
8992
shell: pwsh
9093
run: |
91-
Import-Module ${{ github.action_path }}\BuildPhpExtension -Force
9294
Invoke-RestoreVsToolsetCache -CachePath "${{ steps.vs-check.outputs.vs-cache-path }}" -VsInstallPath "${{ steps.vs-check.outputs.vs-install-path }}"
9395
9496
- name: Build PHP Extension
@@ -108,7 +110,6 @@ runs:
108110
AUTO_DETECT_ARGS: ${{env.auto-detect-args}}
109111
AUTO_DETECT_LIBS: ${{env.auto-detect-libs}}
110112
run: |
111-
Import-Module ${{ github.action_path }}\BuildPhpExtension -Force
112113
Invoke-PhpBuildExtension -ExtensionUrl "${{inputs.extension-url}}" `
113114
-ExtensionRef "${{inputs.extension-ref}}" `
114115
-PhpVersion ${{inputs.php-version}} `
@@ -119,7 +120,6 @@ runs:
119120
if: steps.vs-check.outputs.needs-vs-install == 'true' && steps.vs-cache.outputs.cache-hit != 'true'
120121
shell: pwsh
121122
run: |
122-
Import-Module ${{ github.action_path }}\BuildPhpExtension -Force
123123
Invoke-SaveVsToolsetCache -PhpVersion ${{ inputs.php-version }} -CachePath "${{ steps.vs-check.outputs.vs-cache-path }}"
124124
125125
- name: Save VS components cache

0 commit comments

Comments
 (0)