Skip to content

Commit 5f8f3c2

Browse files
committed
Add OIDC GitHub Actions suport
1 parent 33216d5 commit 5f8f3c2

16 files changed

+5353
-0
lines changed

.gitattributes

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
.gitattributes export-ignore
2+
/.github/ export-ignore
3+
.gitignore export-ignore
4+
/phpunit.xml.dist export-ignore
5+
/phpstan.dist.neon export-ignore
6+
/bin/ export-ignore
7+
/tests/ export-ignore
Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
name: CI
2+
on:
3+
pull_request:
4+
push:
5+
branches:
6+
- "main"
7+
8+
jobs:
9+
build:
10+
runs-on: ubuntu-latest
11+
12+
strategy:
13+
matrix:
14+
php-version:
15+
- "7.2"
16+
- "7.3"
17+
- "7.4"
18+
- "8.0"
19+
- "8.1"
20+
- "8.2"
21+
- "8.3"
22+
- "8.4"
23+
24+
steps:
25+
- uses: actions/checkout@v4
26+
27+
- name: "Install PHP"
28+
uses: "shivammathur/setup-php@v2"
29+
with:
30+
coverage: "none"
31+
ini-values: "memory_limit=-1, phar.readonly=0"
32+
php-version: "${{ matrix.php-version }}"
33+
34+
- name: Validate composer.json
35+
run: composer validate
36+
37+
- name: Install dependencies
38+
run: composer install --prefer-dist --no-progress
39+
40+
- name: PHPUnit
41+
run: ./vendor/bin/phpunit tests
42+
43+
- name: PHP-CS-Fixer
44+
run: ./vendor/bin/php-cs-fixer fix --dry-run --diff
45+
env:
46+
PHP_CS_FIXER_IGNORE_ENV: 1
47+
48+
- name: PHPStan
49+
run: ./vendor/bin/phpstan analyze --no-progress

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
.php-cs-fixer.cache
2+
vendor

.php-cs-fixer.php

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
<?php
2+
3+
$header = <<<HEADER
4+
(c) Packagist Conductors GmbH <[email protected]>
5+
6+
For the full copyright and license information, please view the LICENSE
7+
file that was distributed with this source code.
8+
HEADER;
9+
10+
$finder = PhpCsFixer\Finder::create()
11+
->files()
12+
->in(__DIR__.'/src')
13+
->in(__DIR__.'/tests')
14+
->name('*.php')
15+
;
16+
17+
return (new PhpCsFixer\Config())
18+
->setUsingCache(true)
19+
->setRiskyAllowed(true)
20+
->setRules(array(
21+
'@PSR2' => true,
22+
'no_unused_imports' => true,
23+
'header_comment' => [
24+
'comment_type' => 'PHPDoc',
25+
'header' => $header,
26+
'location' => 'after_declare_strict',
27+
'separate' => 'both',
28+
]
29+
))
30+
->setFinder($finder)
31+
;

README.md

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
# packagist/publish-artifact-github-action
2+
3+
GitHub Action to publish artifacts as package versions to Private Packagist.
4+
5+
## Requirements
6+
7+
PHP >= 7.2
8+
9+
## Install
10+
11+
Via Composer:
12+
```bash
13+
$ composer require private-packagist/oidc-identities
14+
```
15+
16+
## Usage
17+
18+
Initiate a `TokenGenerator` instance and call the `generate` method with `$audience`.
19+
The `TokenGenerator` will automatically try all supported platforms.
20+
21+
```php
22+
// Configure a HttpMethodsClient instance
23+
$oidcHttpClient = new HttpMethodsClient(
24+
Psr18ClientDiscovery::find(),
25+
Psr17FactoryDiscovery::findRequestFactory(),
26+
Psr17FactoryDiscovery::findStreamFactory(),
27+
);
28+
29+
$tokenGenerator = new TokenGenerator(new NullLogger(), $oidcHttpClient);
30+
$token = $tokenGenerator->generate($audience);
31+
```
32+
33+
## Copyright and License
34+
35+
The GitHub Action is licensed under the MIT License.

composer.json

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
{
2+
"name": "private-packagist/oidc-identities",
3+
"description": "Create OIDC tokens on different platforms",
4+
"license": "MIT",
5+
"keywords": ["openid connect", "oidc", "identities"],
6+
"autoload": {
7+
"psr-4": {
8+
"PrivatePackagist\\OIDC\\Identities\\": "src/"
9+
}
10+
},
11+
"autoload-dev": {
12+
"psr-4": {
13+
"PrivatePackagist\\OIDC\\Identities\\": "tests/"
14+
}
15+
},
16+
"require": {
17+
"php": "^7.2.5 || ^8.0",
18+
"psr/log": "^1.0 || ^2.0 || ^3.0",
19+
"php-http/client-common": "^1.9 || ^2.7"
20+
},
21+
"require-dev": {
22+
"phpstan/phpstan": "^1.11.8",
23+
"phpstan/phpstan-phpunit": "^1.4.0",
24+
"phpstan/phpstan-deprecation-rules": "^1.2.0",
25+
"phpstan/phpstan-strict-rules": "^1.6.0",
26+
"phpunit/phpunit": "^8.5",
27+
"php-http/mock-client": "^1.6",
28+
"nyholm/psr7": "^1.8",
29+
"symfony/http-client": "^5.4",
30+
"monolog/monolog": "^2",
31+
"friendsofphp/php-cs-fixer": "^3.4",
32+
"phpstan/extension-installer": "^1.4"
33+
},
34+
"config": {
35+
"allow-plugins": {
36+
"php-http/discovery": true,
37+
"phpstan/extension-installer": true
38+
},
39+
"platform": {
40+
"php": "7.2.5"
41+
}
42+
}
43+
}

0 commit comments

Comments
 (0)