-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #11 from shopware/feat/dynamically-build-my-cnf
feat: Dynamically build the my.cnf
- Loading branch information
Showing
1 changed file
with
34 additions
and
13 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 |
---|---|---|
|
@@ -178,13 +178,41 @@ runs: | |
composer run framework:schema:dump | ||
composer run npm:admin run convert-entity-schema | ||
- name: Configure MySQL Client | ||
if: inputs.mysql-version != 'builtin' | ||
- name: Setup Shopware Database URL | ||
shell: bash | ||
working-directory: ${{ inputs.path }} | ||
run: | | ||
echo "[client]" > $HOME/.my.cnf | ||
echo "host=127.0.0.1" > $HOME/.my.cnf | ||
echo "user=root" > $HOME/.my.cnf | ||
echo "DATABASE_URL=mysql://[email protected]/shopware" >> "$GITHUB_ENV" | ||
if: ${{ env.DATABASE_URL == '' }} # Don't override if already set | ||
|
||
- name: Configure MySQL Client | ||
if: inputs.mysql-version != 'builtin' | ||
uses: actions/github-script@v7 | ||
with: | ||
script: | | ||
const fs = require('fs'); | ||
const os = require('os'); | ||
const uri = process.env.DATABASE_URL; | ||
const regex = /^mysql:\/\/(?<user>[^:]+)(:(?<password>[^@]+))?@(?<host>[^:\/]+)(:(?<port>\d+))?(\/(?<database>[^\?]+))?/; | ||
const match = uri.match(regex); | ||
if (!match || !match.groups) { | ||
console.error("DATABASE_URL is invalid!"); | ||
process.exit(1); | ||
} | ||
const { user, password, host, port, database } = match.groups; | ||
const myFileContent = [ | ||
"[client]", | ||
`host=${host}`, | ||
`user=${user}`, | ||
password ? `password=${password}` : null, | ||
port ? `port=${port}` : null, | ||
database ? `database=${database}` : null, | ||
].filter(Boolean).join("\n"); | ||
fs.writeFileSync(`${os.homedir()}/.my.cnf`, myFileContent); | ||
- name: Wait for MySQL | ||
if: inputs.mysql-version != 'builtin' && inputs.mysql-version != 'skip' | ||
|
@@ -208,13 +236,6 @@ runs: | |
echo "APP_SECRET=def00000bb5acb32b54ff8ee130270586eec0e878f7337dc7a837acc31d3ff00f93a56b595448b4b29664847dd51991b3314ff65aeeeb761a133b0ec0e070433bff08e48" >> "$GITHUB_ENV" | ||
echo "APP_URL=http://localhost:8000" >> "$GITHUB_ENV" | ||
- name: Setup Shopware Database URL | ||
shell: bash | ||
working-directory: ${{ inputs.path }} | ||
run: | | ||
echo "DATABASE_URL=mysql://[email protected]/shopware" >> "$GITHUB_ENV" | ||
if: ${{ env.DATABASE_URL == '' }} # Don't override if already set | ||
|
||
- name: Configure HMAC JWT | ||
shell: bash | ||
working-directory: ${{ inputs.path }} | ||
|
@@ -248,7 +269,7 @@ runs: | |
if: inputs.install-storefront == 'true' | ||
shell: bash | ||
working-directory: ${{ inputs.path }} | ||
run: | | ||
run: | | ||
if bin/console theme:change --help | grep -q '--sync'; then | ||
bin/console theme:change --sync --all Storefront | ||
else | ||
|