-
Notifications
You must be signed in to change notification settings - Fork 274
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Website: Ship the SQLite database integration plugin (#1418)
Related to Boot protocol #1398 Ships the SQLite database integration in WordPress builds to make it accessible in remote.html and enable installing it separately in WordPress builds that don't ship it by default. To test, run `rm packages/playground/wordpress-builds/src/sqlite-database-integration/sqlite-database-integration.zip` and then confirm this command refreshes the local SQLite database zip: ``` nx bundle-sqlite-database playground-wordpress-builds ```
- Loading branch information
Showing
6 changed files
with
122 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
name: 'Refresh WordPress Major&Beta' | ||
|
||
on: | ||
workflow_dispatch: | ||
inputs: | ||
force_rebuild: | ||
description: 'Force rebuild of WordPress (true/false)' | ||
required: false | ||
default: 'false' | ||
# Every 20 minutes | ||
schedule: | ||
- cron: '*/20 * * * *' | ||
|
||
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 | ||
concurrency: | ||
group: check-version-and-run-build | ||
steps: | ||
- uses: actions/checkout@v3 | ||
with: | ||
ref: ${{ github.event.pull_request.head.ref }} | ||
clean: true | ||
persist-credentials: false | ||
- uses: ./.github/actions/prepare-playground | ||
- name: 'Recompile WordPress' | ||
shell: bash | ||
env: | ||
FORCE_REBUILD: ${{ github.event.inputs.force_rebuild }} | ||
run: npx nx bundle-sqlite-database playground-wordpress-builds | ||
- name: Check for uncommitted changes | ||
id: changes | ||
run: | | ||
if [ -z "$(git status --porcelain)" ]; then | ||
echo "No changes" | ||
echo 'CHANGES=0' >> $GITHUB_OUTPUT | ||
else | ||
echo "Changes detected" | ||
echo 'CHANGES=1' >> $GITHUB_OUTPUT | ||
fi | ||
- name: Push rebuilt WordPress to GitHub | ||
if: steps.changes.outputs.CHANGES == '1' | ||
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 "Recompile WordPress major and beta versions" | ||
git pull --rebase | ||
# Push if the pull did not result in a conflict | ||
if [ $? -eq 0 ]; then | ||
git push origin HEAD:trunk | ||
fi; | ||
- name: Deploy website | ||
if: steps.changes.outputs.CHANGES == '1' | ||
uses: benc-uk/workflow-dispatch@v1 | ||
with: | ||
workflow: build-website.yml | ||
token: ${{ secrets.GITHUB_TOKEN }} |
38 changes: 38 additions & 0 deletions
38
packages/playground/wordpress-builds/build/refresh-sqlite-integration-plugin.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
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 const size = ${JSON.stringify((await fs.stat(outputZipPath)).size)}; | ||
export { url }; | ||
`; | ||
await fs.writeFile(getWordPressModulePath, getWordPressModuleContent); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
11 changes: 11 additions & 0 deletions
11
...nd/wordpress-builds/src/sqlite-database-integration/get-sqlite-database-plugin-details.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
// @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 const size = 83948; | ||
export { url }; |
Binary file added
BIN
+82 KB
...ayground/wordpress-builds/src/sqlite-database-integration/sqlite-database-integration.zip
Binary file not shown.