diff --git a/.github/workflows/refresh-sqlite-integration.yml b/.github/workflows/refresh-sqlite-integration.yml new file mode 100644 index 0000000000..ecc14a00ae --- /dev/null +++ b/.github/workflows/refresh-sqlite-integration.yml @@ -0,0 +1,46 @@ +name: 'Refresh WordPress Nightly' + +on: + workflow_dispatch: + # Deploy the nightly version of WordPress every day at 8am UTC + schedule: + - cron: '0 8 * * *' + +jobs: + build_and_deploy: + # Only run this workflow from the trunk branch and when it's triggered by dmsnell OR adamziel + if: > + github.ref == 'refs/heads/trunk' && ( + github.actor == 'adamziel' || + github.actor == 'dmsnell' || + github.actor == 'bgrgicak' || + github.actor == 'brandonpayton' + ) + + runs-on: ubuntu-latest + environment: + name: wordpress-assets + steps: + - uses: actions/checkout@v3 + with: + ref: ${{ github.event.pull_request.head.ref }} + clean: true + persist-credentials: false + - uses: ./.github/actions/prepare-playground + - name: 'Get the latest SQLite database integration plugin' + shell: bash + run: | + wget https://github.com/WordPress/sqlite-database-integration/archive/refs/heads/main.zip \ + -o packages/playground/wordpress-builds + - name: Config git user + run: | + git config --global user.name "deployment_bot" + git config --global user.email "deployment_bot@users.noreply.github.com" + git remote set-url origin https://${{ secrets.GH_ACTOR }}:${{ secrets.GH_TOKEN }}@github.com/${{ github.repository }} + git add -A + git commit -a -m "Refresh WordPress Nightly" + git pull --rebase + # Push if the pull did not result in a conflict + if [ $? -eq 0 ]; then + git push origin HEAD:trunk + fi; diff --git a/packages/playground/wordpress-builds/build/refresh-sqlite-integration-plugin.js b/packages/playground/wordpress-builds/build/refresh-sqlite-integration-plugin.js new file mode 100644 index 0000000000..6a42e4d6d3 --- /dev/null +++ b/packages/playground/wordpress-builds/build/refresh-sqlite-integration-plugin.js @@ -0,0 +1,42 @@ +import yargs from 'yargs'; +import { promises as fs } from 'fs'; +const parser = yargs(process.argv.slice(2)) + .usage('Usage: $0 [options]') + .options({ + ['output-dir']: { + type: 'string', + description: 'output directory', + required: true, + }, + }); + +const args = parser.argv; + +const outputZipPath = `${args.outputDir}/sqlite-database-integration.zip`; +const sqliteResponse = await fetch( + 'https://github.com/WordPress/sqlite-database-integration/archive/refs/heads/main.zip' +); +const sqliteZip = Buffer.from(await sqliteResponse.arrayBuffer()); +await fs.writeFile(outputZipPath, sqliteZip); + +// Refresh get-sqlite-module.ts +const getWordPressModulePath = `${args.outputDir}/get-sqlite-database-plugin-details.ts`; +const getWordPressModuleContent = ` +// @ts-ignore +import url from './sqlite-database-integration.zip?url'; + +/** + * This file was auto generated by packages/playground/wordpress-builds/build/refresh-sqlite-integration-plugin.js + * DO NOT CHANGE MANUALLY! + * This file must statically exists in the project because of the way + * vite resolves imports. + */ +export function getSqliteDatabaseIntegrationDetails(): { size: number, url: string } { + /** @ts-ignore */ + return { + size: ${JSON.stringify((await fs.stat(outputZipPath)).size)}, + url: url, + }; +} +`; +await fs.writeFile(getWordPressModulePath, getWordPressModuleContent); \ No newline at end of file diff --git a/packages/playground/wordpress-builds/src/index.ts b/packages/playground/wordpress-builds/src/index.ts index de91d79a88..13b7739f51 100644 --- a/packages/playground/wordpress-builds/src/index.ts +++ b/packages/playground/wordpress-builds/src/index.ts @@ -1,5 +1,6 @@ export { getWordPressModuleDetails } from './wordpress/get-wordpress-module-details'; export { getWordPressModule } from './wordpress/get-wordpress-module'; +export { getSqliteDatabaseIntegrationDetails } from './sqlite-database-integration/get-sqlite-database-plugin-details'; import SupportedWordPressVersions from './wordpress/wp-versions.json'; export { SupportedWordPressVersions }; @@ -8,4 +9,3 @@ export const SupportedWordPressVersionsList = Object.keys( ) as any as string[]; export const LatestSupportedWordPressVersion = SupportedWordPressVersionsList.filter((v) => v.match(/^\d/))[0] as string; - diff --git a/packages/playground/wordpress-builds/src/sqlite-database-integration/get-sqlite-database-plugin-details.ts b/packages/playground/wordpress-builds/src/sqlite-database-integration/get-sqlite-database-plugin-details.ts new file mode 100644 index 0000000000..aacd22dc4e --- /dev/null +++ b/packages/playground/wordpress-builds/src/sqlite-database-integration/get-sqlite-database-plugin-details.ts @@ -0,0 +1,19 @@ +// @ts-ignore +import url from './sqlite-database-integration.zip?url'; + +/** + * This file was auto generated by packages/playground/wordpress-builds/build/refresh-sqlite-integration-plugin.js + * DO NOT CHANGE MANUALLY! + * This file must statically exists in the project because of the way + * vite resolves imports. + */ +export function getSqliteDatabaseIntegrationDetails(): { + size: number; + url: string; +} { + /** @ts-ignore */ + return { + size: 83948, + url: url, + }; +} diff --git a/packages/playground/wordpress-builds/src/sqlite-database-integration/sqlite-database-integration.zip b/packages/playground/wordpress-builds/src/sqlite-database-integration/sqlite-database-integration.zip new file mode 100644 index 0000000000..ce60c10eec Binary files /dev/null and b/packages/playground/wordpress-builds/src/sqlite-database-integration/sqlite-database-integration.zip differ