Skip to content

Commit 2a82938

Browse files
committed
Add support for auth token to fetch extensions
1 parent fab8797 commit 2a82938

File tree

5 files changed

+14
-0
lines changed

5 files changed

+14
-0
lines changed

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,7 @@ Build a PHP extension for a specific version.
7878
- `build-directory` (optional) - The directory to build the extension in, defaults to the user's temporary directory.
7979
- `run-tests` (optional) - Run the extension tests. Defaults to `true`.
8080
- `test-runner` (optional) - The test runner to use. Defaults to `run-tests.php`.
81+
- `auth-token` (optional) - Authentication token to use in case the extension is hosted on a private repository.
8182

8283
Instead of having to configure all the inputs for the extension action, you can use the `extension-matrix` action to get the matrix of jobs with different input configurations.
8384

@@ -109,6 +110,7 @@ jobs:
109110
- `arch-list` (optional) - The architectures to build the extension for. Defaults to `x64, x86`.
110111
- `ts-list` (optional) - The thread safety to build the extension for. Defaults to `nts, ts`.
111112
- `allow-old-php-versions` (optional) - Allow building the extension for older PHP versions. Defaults to `false`.
113+
- `auth-token` (optional) - Authentication token to use in case the extension is hosted on a private repository.
112114

113115
### Outputs
114116

extension-matrix/action.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,9 @@ inputs:
1313
extension-ref:
1414
description: Git reference in the extension repo
1515
required: false
16+
auth-token:
17+
description: Auth token
18+
required: false
1619
php-version-list:
1720
description: PHP versions to build
1821
required: false
@@ -55,3 +58,4 @@ runs:
5558
ARCH_LIST: ${{inputs.arch-list}}
5659
TS_LIST: ${{inputs.ts-list}}
5760
ALLOW_OLD_PHP_VERSIONS: ${{inputs.allow-old-php-versions}}
61+
AUTH_TOKEN: ${{inputs.auth-token}}

extension-matrix/src/php-versions.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ function get_extension() {
4444
tar -xzf "$directory/$extension-$EXTENSION_REF.tgz" -C "$directory"
4545
cp -a "$directory/$extension-$EXTENSION_REF"/* "$directory"
4646
else
47+
[ -n "$AUTH_TOKEN" ] && EXTENSION_URL="https://${AUTH_TOKEN}@${EXTENSION_URL/https:\/\/}"
4748
git -C "$directory" init
4849
git -C "$directory" remote add origin "$EXTENSION_URL"
4950
git -C "$directory" fetch --depth=1 origin "$EXTENSION_REF"

extension/BuildPhpExtension/private/Get-Extension.ps1

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,9 @@ function Get-Extension {
3232
Copy-Item -Path "$extension-$ExtensionRef\*" -Destination $currentDirectory -Recurse -Force
3333
Remove-Item -Path "$extension-$ExtensionRef" -Recurse -Force
3434
} else {
35+
if($null -ne $env:AUTH_TOKEN) {
36+
$ExtensionUrl = $ExtensionUrl -replace '^https://', "https://${Env:AUTH_TOKEN}@"
37+
}
3538
git init > $null 2>&1
3639
git remote add origin $ExtensionUrl > $null 2>&1
3740
git fetch --depth=1 origin $ExtensionRef > $null 2>&1

extension/action.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,9 @@ inputs:
1313
extension-ref:
1414
description: Git reference in the extension repo
1515
required: false
16+
auth-token:
17+
description: Auth token to fetch the extension source code
18+
required: false
1619
php-version:
1720
description: PHP version to build
1821
required: true
@@ -61,6 +64,7 @@ runs:
6164
RUN_TESTS: ${{inputs.run-tests}}
6265
TEST_RUNNER: ${{inputs.test-runner}}
6366
BUILD_DIRECTORY: ${{inputs.build-directory}}
67+
AUTH_TOKEN: ${{inputs.auth-token}}
6468
run: |
6569
Import-Module ${{ github.action_path }}\BuildPhpExtension -Force
6670
Invoke-PhpBuildExtension -ExtensionUrl "${{inputs.extension-url}}" `

0 commit comments

Comments
 (0)