Skip to content
Open
Show file tree
Hide file tree
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
14 changes: 14 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,14 @@ Create a database
database: testdb
```

Set MySQL's `root` user password:

```yml
- uses: ankane/setup-mariadb@v1
with:
root-user-password: SuperSecretPassword
```

## Extra Steps

Run queries
Expand All @@ -86,3 +94,9 @@ Everyone is encouraged to help improve this project. Here are a few ways you can
- Fix bugs and [submit pull requests](https://github.com/ankane/setup-mariadb/pulls)
- Write, clarify, or fix documentation
- Suggest or add new features


## Notes

- A database user named `runneradmin` is created, with no password, who has all privleges.
- MySQL's `root` user has no password by default. A password can be added by using the action input `root-user-password`.
2 changes: 2 additions & 0 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ inputs:
description: The MariaDB version to download (if necessary) and use
database:
description: Database to create
root-user-password:
description: Password to set for the MySQL root user. Do not use a production password
runs:
using: node16
main: index.js
8 changes: 8 additions & 0 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ if (!['10.10', '10.9', '10.8', '10.7', '10.6', '10.5', '10.4', '10.3'].includes(
}

const database = process.env['INPUT_DATABASE'];
const rootPassword = process.env['INPUT_ROOT-USER-PASSWORD'] || '';

let bin;

Expand All @@ -71,6 +72,7 @@ if (isMac()) {
run(`${bin}/mysql -u root -e "GRANT ALL PRIVILEGES ON *.* TO ''@'localhost'"`);
run(`${bin}/mysql -u root -e "FLUSH PRIVILEGES"`);
}

} else if (isWindows()) {
// install
const tmpDir = fs.mkdtempSync(path.join(os.tmpdir(), 'mariadb-'));
Expand All @@ -96,6 +98,7 @@ if (isMac()) {
run(`"${bin}\\mysql" -u root -e "CREATE USER 'runneradmin'@'localhost' IDENTIFIED BY ''"`);
run(`"${bin}\\mysql" -u root -e "GRANT ALL PRIVILEGES ON *.* TO 'runneradmin'@'localhost'"`);
run(`"${bin}\\mysql" -u root -e "FLUSH PRIVILEGES"`);

} else {
const image = process.env['ImageOS'];
if (image == 'ubuntu20' || image == 'ubuntu22') {
Expand Down Expand Up @@ -128,3 +131,8 @@ if (isMac()) {
if (database) {
runSafe(path.join(bin, 'mysqladmin'), 'create', database);
}

// set root password if specified
if (rootPassword) {
runSafe(path.join(bin, 'mysqladmin'), '-uroot', 'password', rootPassword);
}