From b3aa4388be6b32f2d9fb879aa4decd9d697cbc70 Mon Sep 17 00:00:00 2001 From: Jared Hendrickson Date: Sat, 31 May 2025 00:25:35 -0600 Subject: [PATCH 1/9] feat: fully implement WireGuardTunnel 'descr' field #705 --- .../files/usr/local/pkg/RESTAPI/Models/WireGuardTunnel.inc | 5 +++++ .../pkg/RESTAPI/Tests/APIModelsWireGuardTunnelTestCase.inc | 2 ++ 2 files changed, 7 insertions(+) diff --git a/pfSense-pkg-RESTAPI/files/usr/local/pkg/RESTAPI/Models/WireGuardTunnel.inc b/pfSense-pkg-RESTAPI/files/usr/local/pkg/RESTAPI/Models/WireGuardTunnel.inc index 721d6c95e..26535d1b7 100644 --- a/pfSense-pkg-RESTAPI/files/usr/local/pkg/RESTAPI/Models/WireGuardTunnel.inc +++ b/pfSense-pkg-RESTAPI/files/usr/local/pkg/RESTAPI/Models/WireGuardTunnel.inc @@ -51,6 +51,11 @@ class WireGuardTunnel extends Model { indicates_false: 'no', help_text: 'Enables or disables this tunnels and any associated peers.', ); + $this->descr = new StringField( + required: false, + default: '', + help_text: 'A description for this WireGuard tunnel.', + ); $this->listenport = new PortField( unique: true, default: '51820', diff --git a/pfSense-pkg-RESTAPI/files/usr/local/pkg/RESTAPI/Tests/APIModelsWireGuardTunnelTestCase.inc b/pfSense-pkg-RESTAPI/files/usr/local/pkg/RESTAPI/Tests/APIModelsWireGuardTunnelTestCase.inc index c7a391852..3a2f5cb4d 100644 --- a/pfSense-pkg-RESTAPI/files/usr/local/pkg/RESTAPI/Tests/APIModelsWireGuardTunnelTestCase.inc +++ b/pfSense-pkg-RESTAPI/files/usr/local/pkg/RESTAPI/Tests/APIModelsWireGuardTunnelTestCase.inc @@ -124,6 +124,7 @@ class APIModelsWireGuardTunnelTestCase extends TestCase { $tunnel = new WireGuardTunnel( privatekey: 'KG0BA4UyPilHH5qnXCfr6Lw8ynecOPor88tljLy3AHk=', listenport: '55000', + descr: 'test', async: false, ); $tunnel->create(apply: true); @@ -134,6 +135,7 @@ class APIModelsWireGuardTunnelTestCase extends TestCase { $this->assert_str_contains($wg_showconf->output, 'ListenPort = ' . $tunnel->listenport->value); $this->assert_str_contains($wg_showconf->output, 'PrivateKey = ' . $tunnel->privatekey->value); $this->assert_str_contains($wg_show->output, 'public key: ' . $tunnel->publickey->value); + $this->assert_equals($tunnel->descr->value, 'test'); # Update the tunnel with new values $tunnel->from_representation(privatekey: 'GNdQw+ujEIVgys4B2dDCXcBpiiQsNd2bAq5hnTp+smg=', listenport: '51820'); From 301b3e84b41b7dafb36a22ef2bbc3a494d7c552c Mon Sep 17 00:00:00 2001 From: Jared Hendrickson Date: Sat, 31 May 2025 09:37:37 -0600 Subject: [PATCH 2/9] fix: allow WireGuardTunnel 'descr' to be empty --- .../files/usr/local/pkg/RESTAPI/Models/WireGuardTunnel.inc | 1 + 1 file changed, 1 insertion(+) diff --git a/pfSense-pkg-RESTAPI/files/usr/local/pkg/RESTAPI/Models/WireGuardTunnel.inc b/pfSense-pkg-RESTAPI/files/usr/local/pkg/RESTAPI/Models/WireGuardTunnel.inc index 26535d1b7..11a213ae0 100644 --- a/pfSense-pkg-RESTAPI/files/usr/local/pkg/RESTAPI/Models/WireGuardTunnel.inc +++ b/pfSense-pkg-RESTAPI/files/usr/local/pkg/RESTAPI/Models/WireGuardTunnel.inc @@ -54,6 +54,7 @@ class WireGuardTunnel extends Model { $this->descr = new StringField( required: false, default: '', + allow_empty: true, help_text: 'A description for this WireGuard tunnel.', ); $this->listenport = new PortField( From 3f408d801a6204f053d99759ef8a6c1def97ff51 Mon Sep 17 00:00:00 2001 From: Jared Hendrickson Date: Wed, 28 May 2025 23:32:51 -0600 Subject: [PATCH 3/9] feat: add 'advanced' field to HAProxyBackendServer #682 --- .../usr/local/pkg/RESTAPI/Models/HAProxyBackendServer.inc | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/pfSense-pkg-RESTAPI/files/usr/local/pkg/RESTAPI/Models/HAProxyBackendServer.inc b/pfSense-pkg-RESTAPI/files/usr/local/pkg/RESTAPI/Models/HAProxyBackendServer.inc index 52d616e40..3e70884a0 100644 --- a/pfSense-pkg-RESTAPI/files/usr/local/pkg/RESTAPI/Models/HAProxyBackendServer.inc +++ b/pfSense-pkg-RESTAPI/files/usr/local/pkg/RESTAPI/Models/HAProxyBackendServer.inc @@ -23,6 +23,7 @@ class HAProxyBackendServer extends Model { public BooleanField $ssl; public BooleanField $sslserververify; public IntegerField $serverid; + public StringField $advanced; public function __construct(mixed $id = null, mixed $parent_id = null, mixed $data = [], ...$options) { # Set model attributes @@ -80,6 +81,12 @@ class HAProxyBackendServer extends Model { help_text: 'The unique ID for this backend server. This value is set by the system for internal use and ' . 'cannot be changed.', ); + $this->advanced = new StringField( + default: '', + allow_empty: true, + help_text: 'Allows adding custom HAProxy server settings to the server.', + ); + parent::__construct($id, $parent_id, $data, ...$options); } From d922d1105cd86b3bf4d5ddf5cc0ac4570a142983 Mon Sep 17 00:00:00 2001 From: Jared Hendrickson Date: Sat, 31 May 2025 00:10:56 -0600 Subject: [PATCH 4/9] feat: use standard cron expressions for dispatcher schedules --- .../Caches/RESTAPIVersionReleasesCache.inc | 2 +- .../usr/local/pkg/RESTAPI/Core/Dispatcher.inc | 41 ++++++++++++------- .../Tests/APICoreDispatcherTestCase.inc | 2 +- 3 files changed, 28 insertions(+), 17 deletions(-) diff --git a/pfSense-pkg-RESTAPI/files/usr/local/pkg/RESTAPI/Caches/RESTAPIVersionReleasesCache.inc b/pfSense-pkg-RESTAPI/files/usr/local/pkg/RESTAPI/Caches/RESTAPIVersionReleasesCache.inc index 6db84fb2e..74f00be6b 100644 --- a/pfSense-pkg-RESTAPI/files/usr/local/pkg/RESTAPI/Caches/RESTAPIVersionReleasesCache.inc +++ b/pfSense-pkg-RESTAPI/files/usr/local/pkg/RESTAPI/Caches/RESTAPIVersionReleasesCache.inc @@ -15,7 +15,7 @@ class RESTAPIVersionReleasesCache extends Cache { const RELEASES_URL = 'https://api.github.com/repos/jaredhendrickson13/pfsense-api/releases'; public int $timeout = 30; - public string $schedule = 'hourly'; + public string $schedule = '0 * * * *'; /** * Retrieves available release information from external repos and updates the releases cache files. diff --git a/pfSense-pkg-RESTAPI/files/usr/local/pkg/RESTAPI/Core/Dispatcher.inc b/pfSense-pkg-RESTAPI/files/usr/local/pkg/RESTAPI/Core/Dispatcher.inc index 78e708d24..e3afd0730 100644 --- a/pfSense-pkg-RESTAPI/files/usr/local/pkg/RESTAPI/Core/Dispatcher.inc +++ b/pfSense-pkg-RESTAPI/files/usr/local/pkg/RESTAPI/Core/Dispatcher.inc @@ -19,10 +19,6 @@ class Dispatcher { * @const DISPATCH_SCRIPT The absolute file path to the dispatch.sh helper script. */ const DISPATCH_SCRIPT = '/usr/local/pkg/RESTAPI/.resources/scripts/dispatch.sh'; - /** - * @const SCHEDULE_OPTIONS The cron event schedules supported by Dispatchers. - */ - const SCHEDULE_OPTIONS = ['hourly', 'daily', 'weekly']; /** * @var string $full_name @@ -297,27 +293,27 @@ class Dispatcher { # Only proceed if a schedule was requested if ($this->schedule) { # Ensure the requested schedule is supported - if (!in_array($this->schedule, self::SCHEDULE_OPTIONS)) { + if (count(explode(' ', $this->schedule)) !== 5) { throw new ServerError( message: "Dispatcher schedule `$this->schedule` is not a supported schedule frequency.", response_id: 'DISPATCHER_SCHEDULE_UNSUPPORTED', ); } - # Check if a cron job already exists for this dispatcher - $dispatcher_cron_job_q = CronJob::query(command: $this->schedule_command); - - # Delete the cron job for this dispatcher if it exists, so we can recreate it with current values - if ($dispatcher_cron_job_q->exists()) { - $existing_cron_job = $dispatcher_cron_job_q->first(); - $existing_cron_job->packages = []; // Don't require the pfSense-pkg-Cron package to delete - $existing_cron_job->delete(); - } + # Remove any existing scheduled CronJob for this Dispatcher + $this->remove_schedule(); # Create the cron job for this dispatcher + $cron_expr = explode(' ', $this->schedule); $cron_job = new CronJob( - data: ['minute' => "@$this->schedule", 'who' => 'root', 'command' => $this->schedule_command], require_pkg: false, + minute: $cron_expr[0], + hour: $cron_expr[1], + mday: $cron_expr[2], + month: $cron_expr[3], + wday: $cron_expr[4], + who: 'root', + command: $this->schedule_command, ); $cron_job->create(); @@ -330,4 +326,19 @@ class Dispatcher { return null; } + + /** + * Removes the scheduled CronJob for this Dispatcher if it exists. + */ + public function remove_schedule(): void { + # Check if a cron job already exists for this dispatcher + $dispatcher_cron_job_q = CronJob::query(command: $this->schedule_command); + + # Delete the cron job for this dispatcher if it exists, so we can recreate it with current values + if ($dispatcher_cron_job_q->exists()) { + $existing_cron_job = $dispatcher_cron_job_q->first(); + $existing_cron_job->packages = []; // Don't require the pfSense-pkg-Cron package to delete + $existing_cron_job->delete(); + } + } } diff --git a/pfSense-pkg-RESTAPI/files/usr/local/pkg/RESTAPI/Tests/APICoreDispatcherTestCase.inc b/pfSense-pkg-RESTAPI/files/usr/local/pkg/RESTAPI/Tests/APICoreDispatcherTestCase.inc index 148067f58..663b5a0c3 100644 --- a/pfSense-pkg-RESTAPI/files/usr/local/pkg/RESTAPI/Tests/APICoreDispatcherTestCase.inc +++ b/pfSense-pkg-RESTAPI/files/usr/local/pkg/RESTAPI/Tests/APICoreDispatcherTestCase.inc @@ -134,7 +134,7 @@ class APICoreDispatcherTestCase extends TestCase { $this->assert_equals($dispatcher->setup_schedule(), null); # Assign the dispatcher a schedule and ensure setup_schedule() returns a CronJob object with the correct schedule - $dispatcher->schedule = 'daily'; + $dispatcher->schedule = '* 12 * * *'; $dispatcher_cron_job = $dispatcher->setup_schedule(); $cron_job_cmd = '/usr/local/pkg/RESTAPI/.resources/scripts/manage.php notifydispatcher Dispatcher'; $this->assert_equals($dispatcher_cron_job->minute->value, "@$dispatcher->schedule"); From 50c8b4ced2529c07403d2ad539fa09838b21f2d5 Mon Sep 17 00:00:00 2001 From: Jared Hendrickson Date: Sat, 31 May 2025 00:16:33 -0600 Subject: [PATCH 5/9] fix: run AvailablePackageCache at irregular interval #700 This should help prevent a potential conflicts with other repo related tasks on the system. --- .../usr/local/pkg/RESTAPI/Caches/AvailablePackageCache.inc | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/pfSense-pkg-RESTAPI/files/usr/local/pkg/RESTAPI/Caches/AvailablePackageCache.inc b/pfSense-pkg-RESTAPI/files/usr/local/pkg/RESTAPI/Caches/AvailablePackageCache.inc index 37e2bc0eb..eb9a78013 100644 --- a/pfSense-pkg-RESTAPI/files/usr/local/pkg/RESTAPI/Caches/AvailablePackageCache.inc +++ b/pfSense-pkg-RESTAPI/files/usr/local/pkg/RESTAPI/Caches/AvailablePackageCache.inc @@ -12,8 +12,7 @@ use function RESTAPI\Dispatchers\get_pkg_info; */ class AvailablePackageCache extends Cache { public int $timeout = 120; - public string $schedule = 'hourly'; - + public string $schedule = '12 * * * *'; # Run at irregular interval to avoid conflicts with repo jobs /** * Retrieves the available package information to cache from external repos */ From 5b10fd47dfe8c713e713ad1c64f79232ac812f13 Mon Sep 17 00:00:00 2001 From: Jared Hendrickson Date: Sat, 31 May 2025 15:39:41 -0600 Subject: [PATCH 6/9] tests: corrected expected schedule string in Dispatcher test --- .../usr/local/pkg/RESTAPI/Tests/APICoreDispatcherTestCase.inc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pfSense-pkg-RESTAPI/files/usr/local/pkg/RESTAPI/Tests/APICoreDispatcherTestCase.inc b/pfSense-pkg-RESTAPI/files/usr/local/pkg/RESTAPI/Tests/APICoreDispatcherTestCase.inc index 663b5a0c3..82d492ea3 100644 --- a/pfSense-pkg-RESTAPI/files/usr/local/pkg/RESTAPI/Tests/APICoreDispatcherTestCase.inc +++ b/pfSense-pkg-RESTAPI/files/usr/local/pkg/RESTAPI/Tests/APICoreDispatcherTestCase.inc @@ -137,7 +137,7 @@ class APICoreDispatcherTestCase extends TestCase { $dispatcher->schedule = '* 12 * * *'; $dispatcher_cron_job = $dispatcher->setup_schedule(); $cron_job_cmd = '/usr/local/pkg/RESTAPI/.resources/scripts/manage.php notifydispatcher Dispatcher'; - $this->assert_equals($dispatcher_cron_job->minute->value, "@$dispatcher->schedule"); + $this->assert_equals($dispatcher_cron_job->minute->value, $dispatcher->schedule); $this->assert_equals($dispatcher_cron_job->command->value, $cron_job_cmd); # Delete the CronJob From fc189fc9d133791bd2e90661f8836b84a2f12ac3 Mon Sep 17 00:00:00 2001 From: Jared Hendrickson Date: Sat, 31 May 2025 16:36:13 -0600 Subject: [PATCH 7/9] tests: check correct cron syntax in Dispatcher --- .../local/pkg/RESTAPI/Tests/APICoreDispatcherTestCase.inc | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/pfSense-pkg-RESTAPI/files/usr/local/pkg/RESTAPI/Tests/APICoreDispatcherTestCase.inc b/pfSense-pkg-RESTAPI/files/usr/local/pkg/RESTAPI/Tests/APICoreDispatcherTestCase.inc index 82d492ea3..1ac45c976 100644 --- a/pfSense-pkg-RESTAPI/files/usr/local/pkg/RESTAPI/Tests/APICoreDispatcherTestCase.inc +++ b/pfSense-pkg-RESTAPI/files/usr/local/pkg/RESTAPI/Tests/APICoreDispatcherTestCase.inc @@ -134,10 +134,14 @@ class APICoreDispatcherTestCase extends TestCase { $this->assert_equals($dispatcher->setup_schedule(), null); # Assign the dispatcher a schedule and ensure setup_schedule() returns a CronJob object with the correct schedule - $dispatcher->schedule = '* 12 * * *'; + $dispatcher->schedule = '1 2 3 4 5'; $dispatcher_cron_job = $dispatcher->setup_schedule(); $cron_job_cmd = '/usr/local/pkg/RESTAPI/.resources/scripts/manage.php notifydispatcher Dispatcher'; - $this->assert_equals($dispatcher_cron_job->minute->value, $dispatcher->schedule); + $this->assert_equals($dispatcher_cron_job->minute->value, "1"); + $this->assert_equals($dispatcher_cron_job->hour->value, "2"); + $this->assert_equals($dispatcher_cron_job->mday->value, "3"); + $this->assert_equals($dispatcher_cron_job->month->value, "4"); + $this->assert_equals($dispatcher_cron_job->wday->value, "5"); $this->assert_equals($dispatcher_cron_job->command->value, $cron_job_cmd); # Delete the CronJob From 202747995e2ff0fd452dce0ac39002d74e52990e Mon Sep 17 00:00:00 2001 From: Jared Hendrickson Date: Sat, 31 May 2025 22:53:05 -0600 Subject: [PATCH 8/9] style: run prettier on changed files --- .../pkg/RESTAPI/Tests/APICoreDispatcherTestCase.inc | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/pfSense-pkg-RESTAPI/files/usr/local/pkg/RESTAPI/Tests/APICoreDispatcherTestCase.inc b/pfSense-pkg-RESTAPI/files/usr/local/pkg/RESTAPI/Tests/APICoreDispatcherTestCase.inc index 1ac45c976..ceddaf442 100644 --- a/pfSense-pkg-RESTAPI/files/usr/local/pkg/RESTAPI/Tests/APICoreDispatcherTestCase.inc +++ b/pfSense-pkg-RESTAPI/files/usr/local/pkg/RESTAPI/Tests/APICoreDispatcherTestCase.inc @@ -137,11 +137,11 @@ class APICoreDispatcherTestCase extends TestCase { $dispatcher->schedule = '1 2 3 4 5'; $dispatcher_cron_job = $dispatcher->setup_schedule(); $cron_job_cmd = '/usr/local/pkg/RESTAPI/.resources/scripts/manage.php notifydispatcher Dispatcher'; - $this->assert_equals($dispatcher_cron_job->minute->value, "1"); - $this->assert_equals($dispatcher_cron_job->hour->value, "2"); - $this->assert_equals($dispatcher_cron_job->mday->value, "3"); - $this->assert_equals($dispatcher_cron_job->month->value, "4"); - $this->assert_equals($dispatcher_cron_job->wday->value, "5"); + $this->assert_equals($dispatcher_cron_job->minute->value, '1'); + $this->assert_equals($dispatcher_cron_job->hour->value, '2'); + $this->assert_equals($dispatcher_cron_job->mday->value, '3'); + $this->assert_equals($dispatcher_cron_job->month->value, '4'); + $this->assert_equals($dispatcher_cron_job->wday->value, '5'); $this->assert_equals($dispatcher_cron_job->command->value, $cron_job_cmd); # Delete the CronJob From 5b82c9f35afb97eb1556788d117a6fd94e018782 Mon Sep 17 00:00:00 2001 From: Jared Hendrickson Date: Sun, 1 Jun 2025 11:18:50 -0600 Subject: [PATCH 9/9] ci: do not build and deploy documentation for this backport --- .github/workflows/release.yml | 141 ---------------------------------- 1 file changed, 141 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index ea95f957f..5b92a3d7a 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -63,144 +63,3 @@ jobs: uses: softprops/action-gh-release@v2 with: files: pfSense-${{ matrix.PFSENSE_VERSION }}-pkg-RESTAPI.pkg - - build_schemas: - runs-on: self-hosted - needs: [release_pkg] - steps: - - uses: actions/checkout@v4 - - - uses: actions/download-artifact@v4 - with: - name: pfSense-${{ env.DEFAULT_PFSENSE_VERSION }}-pkg-RESTAPI.pkg - path: pfSense-${{ env.DEFAULT_PFSENSE_VERSION }}-pkg-RESTAPI.pkg - - - name: Setup pfSense VM - run: | - /usr/local/bin/VBoxManage controlvm pfSense-${{ env.DEFAULT_PFSENSE_VERSION }}-RELEASE poweroff || true - /usr/local/bin/VBoxManage snapshot pfSense-${{ env.DEFAULT_PFSENSE_VERSION }}-RELEASE restore initial - /usr/local/bin/VBoxManage startvm pfSense-${{ env.DEFAULT_PFSENSE_VERSION }}-RELEASE --type headless - sleep 5 - - # This is only necessary until GitHub Actions allows an easier way to get a URL to download the artifact within pfSense - - name: Copy pfSense-pkg-RESTAPI build to pfSense - run: | - pfsense-vshell --host pfSense-${{ env.DEFAULT_PFSENSE_VERSION }}-RELEASE.jaredhendrickson.com -u admin -p pfsense -c 'pfSsh.php playback enablesshd' -k - pfsense-vshell --host pfSense-${{ env.DEFAULT_PFSENSE_VERSION }}-RELEASE.jaredhendrickson.com -u admin -p pfsense -c "mkdir /root/.ssh/ && echo $(cat ~/.ssh/id_rsa.pub) > /root/.ssh/authorized_keys" -k - scp -o StrictHostKeyChecking=no pfSense-${{ env.DEFAULT_PFSENSE_VERSION }}-pkg-RESTAPI.pkg/pfSense-${{ env.DEFAULT_PFSENSE_VERSION }}-pkg-RESTAPI.pkg admin@pfSense-${{ env.DEFAULT_PFSENSE_VERSION }}-RELEASE.jaredhendrickson.com:/tmp/ - - - name: Install pfSense-pkg-RESTAPI on pfSense - run: | - ssh -o StrictHostKeyChecking=no -o LogLevel=quiet admin@pfSense-${{ env.DEFAULT_PFSENSE_VERSION }}-RELEASE.jaredhendrickson.com "pkg -C /dev/null add /tmp/pfSense-${{ env.DEFAULT_PFSENSE_VERSION }}-pkg-RESTAPI.pkg" - sleep 5 - - - name: Fetch schemas from pfSense - run: | - curl -s -k -u admin:pfsense -X GET https://pfSense-${{ env.DEFAULT_PFSENSE_VERSION }}-RELEASE.jaredhendrickson.com/api/v2/schema/openapi > openapi.json - curl -s -k -u admin:pfsense -X GET https://pfSense-${{ env.DEFAULT_PFSENSE_VERSION }}-RELEASE.jaredhendrickson.com/api/v2/schema/graphql > schema.graphql - - - name: Teardown pfSense VM - if: "${{ always() }}" - run: | - /usr/local/bin/VBoxManage controlvm pfSense-${{ env.DEFAULT_PFSENSE_VERSION }}-RELEASE poweroff || true - /usr/local/bin/VBoxManage snapshot pfSense-${{ env.DEFAULT_PFSENSE_VERSION }}-RELEASE restore initial - - - name: Upload OpenAPI schema - uses: actions/upload-artifact@v4 - with: - name: openapi.json - path: openapi.json - - - name: Upload GraphQL schema - uses: actions/upload-artifact@v4 - with: - name: schema.graphql - path: schema.graphql - - release_docs: - needs: [build_schemas] - runs-on: ubuntu-latest - if: ${{ !github.event.release.prerelease }} - environment: - name: github-pages - url: ${{ steps.deployment.outputs.page_url }} - steps: - - uses: actions/checkout@v4 - - - name: Setup Pages - uses: actions/configure-pages@v5.0.0 - - - name: Make website directory - run: mkdir ./www - - - name: Setup python - uses: actions/setup-python@v5 - with: - python-version: ${{ env.PYTHON_VERSION }} - - - name: Build mkdocs site - run: | - python3 -m pip install -r ./requirements.txt - python3 -m mkdocs build - mv ./site/* ./www/ - - - name: Download OpenAPI schema - uses: actions/download-artifact@v4 - with: - name: openapi.json - path: openapi.json - - - name: Download GraphQL schema - uses: actions/download-artifact@v4 - with: - name: schema.graphql - path: schema.graphql - - - name: Build Swagger UI - run: | - mkdir -p ./www/api-docs/ - wget -O /tmp/swagger.tar.gz https://github.com/swagger-api/swagger-ui/archive/refs/tags/v${{ env.SWAGGER_UI_VERSION }}.tar.gz - tar -xzf /tmp/swagger.tar.gz -C /tmp/ - cp -r /tmp/swagger-ui-${{ env.SWAGGER_UI_VERSION }}/dist/* ./www/api-docs/ - cp pfSense-pkg-RESTAPI/files/usr/local/www/api/swagger/index.css ./www/api-docs/index.css - cp openapi.json/openapi.json ./www/api-docs/openapi.json - echo 'window.onload = function() { - document.title = "pfSense REST API Documentation"; - window.ui = SwaggerUIBundle({ - url: "/api-docs/openapi.json", - dom_id: "#swagger-ui", - deepLinking: true, - presets: [ - SwaggerUIBundle.presets.apis, - SwaggerUIStandalonePreset - ], - plugins: [ - SwaggerUIBundle.plugins.DownloadUrl - ], - layout: "StandaloneLayout", - supportedSubmitMethods: [], - validatorUrl: null - }); - };' > ./www/api-docs/swagger-initializer.js - - - name: Write GraphQL schema - run: | - mkdir -p ./www/graphql-docs/ - cp schema.graphql/schema.graphql ./www/graphql-docs/schema.graphql - - - name: Build PHP reference documentation - run: | - mkdir ./www/php-docs - wget https://phpdoc.org/phpDocumentor.phar - chmod +x phpDocumentor.phar - ./phpDocumentor.phar - mv ./.phpdoc/build/* ./www/php-docs/ - - - name: Upload artifact - uses: actions/upload-pages-artifact@v3.0.1 - with: - path: "./www" - - - name: Deploy to GitHub Pages - id: deployment - uses: actions/deploy-pages@v4.0.5