Skip to content

Commit 56fc657

Browse files
Replace GitHub PAT authentication with GitHub App
Personal Access Tokens are bound to a GitHub user, which doesn't work for teams. And when the workflow fails, that GitHub user gets notified. Using a GitHub App to authenticate makes it easier for teams to manage access. The unit test has been upgraded to a full integration test, that uses a GitHub App to test. Faking the new authentication process makes the unit test useless. Having a full integration tests hopefully helps, and won't have to much false positives.
1 parent 525c28c commit 56fc657

File tree

18 files changed

+413
-140
lines changed

18 files changed

+413
-140
lines changed

.github/workflows/run-tests.yaml

Lines changed: 5 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -10,33 +10,16 @@ jobs:
1010
fail-fast: true
1111
matrix:
1212
os: [ubuntu-latest]
13-
laravel: [8.*, 9.*, 10.*, 11.*]
14-
php: [8.0, 8.1, 8.2, 8.3]
13+
laravel: [10.*, 11.*]
14+
php: [8.2, 8.3, 8.4]
1515
dependency-version: [prefer-stable]
1616
include:
17-
- laravel: 8.*
18-
testbench: 6.*
19-
phpunit: 9.*
20-
- laravel: 9.*
21-
testbench: 7.*
22-
phpunit: 9.*
2317
- laravel: 10.*
2418
testbench: 8.*
2519
phpunit: 9.*
2620
- laravel: 11.*
2721
testbench: 9.*
2822
phpunit: 10.*
29-
exclude:
30-
- laravel: 8.*
31-
php: 8.2
32-
- laravel: 8.*
33-
php: 8.3
34-
- laravel: 10.*
35-
php: 8.0
36-
- laravel: 11.*
37-
php: 8.0
38-
- laravel: 11.*
39-
php: 8.1
4023
name: PHP ${{ matrix.php }} - Laravel ${{ matrix.laravel }}
4124

4225
steps:
@@ -45,6 +28,7 @@ jobs:
4528
- uses: shivammathur/setup-php@v2
4629
with:
4730
php-version: ${{ matrix.php }}
31+
coverage: none
4832

4933
- name: Get Composer Cache Directory
5034
id: composer-cache
@@ -69,3 +53,5 @@ jobs:
6953
7054
- name: Run PHP tests
7155
run: vendor/bin/phpunit
56+
env:
57+
NOVA_PUBLISH_PRIVATE_KEY: ${{ secrets.NOVA_PUBLISH_PRIVATE_KEY }}

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
/.env
12
/.idea
23
/vendor
34
/node_modules

CHANGELOG.md

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,28 @@
11
# CHANGELOG
22

3-
## V2.0.2
3+
## 3.0.0
4+
5+
- Add support for GitHub Apps
6+
- Drop support for PHP 8.0 and 8.1
7+
- Drop support for Laravel 8 and 9
8+
- Drop support for GitHub Personal Access Tokens
9+
10+
Run `php artisan vendor:publish --tag=publish-config` to publish the new configuration file.
11+
12+
See "GitHub credentials" in README.md for information about creating a GitHub Apps.
13+
14+
## 2.0.2
415

516
- Fix cms navigation bug
617

7-
## V2.0.1
18+
## 2.0.1
819

920
- Add event for when publication was started
1021

11-
## V2.0.0
22+
## 2.0.0
1223

1324
- Nova 4 added as dependency. The tool is now compatible with Nova 4.
1425

15-
## V1.0.0
26+
## 1.0.0
1627

1728
- Initial version for Nova 3.

README.md

Lines changed: 24 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,8 @@
2424

2525
[Return To Top](#nova-publish)
2626

27-
- PHP 8.0, 8.1, 8.2
28-
- Laravel 8, 9, 10
27+
- PHP 8.2, 8.3, 8.4
28+
- Laravel 9, 10
2929
- Nova 4
3030

3131
## Installation
@@ -66,34 +66,44 @@ Publish configuration
6666
php artisan vendor:publish --provider="Publish\ToolServiceProvider"
6767
```
6868

69-
Configure GitHub credentials, set the path to the workflow file and configure an application version.
69+
Configure [GitHub credentials](#github-credentials), set the name of workflow file and configure an application version.
7070

7171
=======
7272

7373
## Local development
7474

75-
Run `npm run dev` to watch for changes in the `resources/js` directory.
75+
Run `yarn run dev` to watch for changes in the `resources/js` directory.
7676

7777
Use the local checkout in a project that uses this plugin. [The Composer documentation explains how to do this.](https://getcomposer.org/doc/05-repositories.md#path)
7878

79-
## i18n
79+
To run the tests you need a Nova License and a GitHub App with access to your repository. It will use the workflow `test-workflow.yml` to do integration tests.
8080

81-
To add a language or change an existing translation, please read the [Laravel documentation about overriding package language files](https://laravel.com/docs/10.x/localization#overriding-package-language-files).
81+
Create `/.env` file with the following content:
82+
83+
```dotenv
84+
NOVA_PUBLISH_PRIVATE_KEY="your GitHub App private key"
85+
NOVA_PUBLISH_APPLICATION_ID="your GitHub App ID"
86+
NOVA_PUBLISH_OWNER="your GitHub owner"
87+
NOVA_PUBLISH_REPOSITORY="your GitHub repository"
88+
```
8289

83-
## GitHub API credentials
90+
## i18n
8491

85-
Personal Access Tokens (PATs) are currently the only way to access the GitHub API. The token is created by a GitHub user. So when this user is removed from the GitHub organization the token must be recreated by another user. Not ideal, so there is room for improvement.
92+
To add a language or change an existing translation, please read the [Laravel documentation about overriding package language files](https://laravel.com/docs/10.x/localization#overriding-package-language-files).
8693

87-
Create a Personal Access Token: https://github.com/settings/tokens
94+
## GitHub credentials
8895

89-
- Note: the name of the project
90-
- Expiration: No expiration (or you have to replace the token every time it expires)
91-
- Scopes: "repo" and "workflow"
96+
You need a GitHub Apps to use this tool. The application must have access to the repository where the workflow is located.
9297

93-
Add the created token as environment variable `PUBLISH_GITHUB_PERSONAL_ACCESS_TOKEN`.
98+
[About creating GitHub Apps](https://docs.github.com/en/apps/creating-github-apps/about-creating-github-apps/about-creating-github-apps).
9499

95-
You GitHub username must be stored in `PUBLISH_GITHUB_USERNAME`.
100+
Use the application ID and private key in `config/publish.php`.
96101

97102
## Contribute
98103

99104
You need a Nova license to run the tests.
105+
106+
## Release new version
107+
108+
- Run `yarn run prod` to build the assets, and commit the changes
109+
- Add the new version to `CHANGELOG.md`

composer.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,8 @@
1313
],
1414
"license": "MIT",
1515
"require": {
16-
"php": "^8.0|^8.1|^8.2|^8.3",
16+
"php": "^8.2|^8.3|^8.4",
17+
"ext-openssl": "*",
1718
"guzzlehttp/guzzle": "^7.3",
1819
"laravel/nova": "^4.0"
1920
},

config/publish.php

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,18 +3,26 @@
33
return [
44
/*
55
|--------------------------------------------------------------------------
6-
| GitHub credentials
6+
| GitHub App credentials
77
|--------------------------------------------------------------------------
88
|
99
| Publish uses these credentials to connect to the GitHub API. The token
1010
| needs the "repo" and "workflow" scope.
1111
|
1212
*/
1313

14-
"github_username" => env("PUBLISH_GITHUB_USERNAME"),
15-
"github_personal_access_token" => env(
16-
"PUBLISH_GITHUB_PERSONAL_ACCESS_TOKEN"
17-
),
14+
"application_id" => env("NOVA_PUBLISH_APPLICATION_ID"),
15+
"private_key" => env("NOVA_PUBLISH_PRIVATE_KEY"),
16+
17+
/*
18+
|--------------------------------------------------------------------------
19+
| GitHub repository information
20+
|--------------------------------------------------------------------------
21+
|
22+
*/
23+
24+
"owner" => env("NOVA_PUBLISH_OWNER", "norday-agency"),
25+
"repository" => env("NOVA_PUBLISH_REPOSITORY"),
1826

1927
/*
2028
|--------------------------------------------------------------------------
@@ -28,7 +36,7 @@
2836
| https://api.github.com/repos/grrr-amsterdam/nova-publish/actions/workflows/my-workflow_dispatch-workflow.yml
2937
|
3038
*/
31-
"workflow_path" => "https://api.github.com/path/to/workflow.yml",
39+
"workflow" => env("NOVA_PUBLISH_WORKFLOW"),
3240

3341
/*
3442
|--------------------------------------------------------------------------

dist/js/tool.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)