Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Dynamically build the my.cnf #11

Merged
merged 1 commit into from
Nov 11, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
47 changes: 34 additions & 13 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand All @@ -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 }}
Expand Down Expand Up @@ -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
Expand Down
Loading