diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 0000000..e7b1697 --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,14 @@ +on: + push: + branches: + - main + +jobs: + release-on-merge: + runs-on: ubuntu-latest + permissions: + contents: write + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + steps: + - uses: dexwritescode/release-on-merge-action@v1 diff --git a/src/Console/Export.php b/src/Console/Export.php index 64298d4..17a14be 100644 --- a/src/Console/Export.php +++ b/src/Console/Export.php @@ -24,11 +24,44 @@ public function handle() $this->exportFieldSets(); + $this->exportCollections(); + $this->newLine(); $this->info('All done!'); } + private function exportCollections() + { + $namespaces = collect(config('statamic.builder.collections', [])); + + $namespaces->each(function ($collections): void { + $collections = collect($collections); + + $collections->each(function ($collection): void { + $this->exportCollection($collection); + }); + }); + } + + private function exportCollection($collection) + { + $filesystem = Storage::build([ + 'driver' => 'local', + 'root' => base_path('resources/collections'), + ]); + + $data = (new $collection)->register(); + + $path = base_path("resources/collections/{$data->handle()}.yaml"); + + $yaml = YAML::dump($data->toArray()); + + $this->line("Exporting collection [{$data->handle()}] to [{$path}]"); + + $filesystem->put("{$data->handle()}.yaml", $yaml); + } + private function exportBlueprints() { $namespaces = collect(config('statamic.builder.blueprints', []));