generated from GoLinks/mysql-schema-diff-action
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
efdc888
commit fa32b77
Showing
3 changed files
with
136 additions
and
21 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 |
---|---|---|
|
@@ -28,11 +28,23 @@ jobs: | |
- name: Install MySQL 5.7 | ||
shell: bash | ||
run: | | ||
<<<<<<< Updated upstream | ||
brew install mysql | ||
brew install [email protected] | ||
brew unlink mysql && brew link [email protected] | ||
echo 'export PATH="/usr/local/opt/[email protected]/bin:$PATH"' >> /Users/runner/.bash_profile | ||
bash | ||
======= | ||
while ! mysqladmin ping -h"127.0.0.1" --silent; do | ||
sleep 1 | ||
done | ||
|
||
# Step to install MySQL client on the GitHub Actions runner | ||
- name: Install the Latest MySQL Client | ||
run: | | ||
sudo apt-get update | ||
sudo apt-get install mysql-client -y | ||
>>>>>>> Stashed changes | ||
mysql --version | ||
mysqldump --version | ||
# Runs a single command using the runners shell | ||
|
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,76 @@ | ||
# This is a basic workflow to help you get started with Actions | ||
name: Check MySQL 8.0 | ||
|
||
# Controls when the workflow will run | ||
on: | ||
# Triggers the workflow on push or pull request events but only for the main branch | ||
push: | ||
branches: [ main ] | ||
pull_request: | ||
branches: [ main ] | ||
|
||
# Allows you to run this workflow manually from the Actions tab | ||
workflow_dispatch: | ||
|
||
# A workflow run is made up of one or more jobs that can run sequentially or in parallel | ||
jobs: | ||
# This workflow contains a single job called "build" | ||
build: | ||
# The type of runner that the job will run on | ||
runs-on: ubuntu-latest | ||
|
||
# Define services required by the job, in this case, MySQL 8.0 | ||
services: | ||
mysql: | ||
image: mysql:8.0 # Use MySQL version 8.0 Docker image | ||
env: | ||
MYSQL_ROOT_PASSWORD: root # Environment variable for MySQL root password | ||
MYSQL_DATABASE: testdb # Environment variable to create a default database | ||
ports: | ||
- 3306:3306 # Map port 3306 inside the container to port 3306 on the host | ||
options: --health-cmd="mysqladmin ping" --health-interval=10s --health-timeout=5s --health-retries=5 # Docker options to ensure MySQL is healthy before proceeding | ||
|
||
# Steps represent a sequence of tasks that will be executed as part of the job | ||
steps: | ||
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it | ||
- uses: actions/checkout@v4 | ||
|
||
# Step to wait for MySQL 8.0 to fully start before proceeding with subsequent steps | ||
- name: Wait for MySQL 8.0 | ||
run: | | ||
while ! mysqladmin ping -h"127.0.0.1" --silent; do | ||
sleep 1 | ||
done | ||
# Step to install MySQL client on the GitHub Actions runner | ||
- name: Install the Latest MySQL Client | ||
run: | | ||
sudo apt-get update | ||
sudo apt-get install mysql-client -y | ||
mysql --version | ||
mysqldump --version | ||
# Add a users table to provide some table structure | ||
- name: Create table | ||
run: | | ||
mysql -h 127.0.0.1 -u root --password=root testdb -e "CREATE TABLE IF NOT EXISTS users (id INT AUTO_INCREMENT PRIMARY KEY, name VARCHAR(255), email VARCHAR(255));" | ||
env: | ||
MYSQL_HOST: 127.0.0.1 | ||
MYSQL_PORT: 3306 | ||
MYSQL_ROOT_PASSWORD: root | ||
|
||
# Runs a single command using the runners shell | ||
- name: Check MySQL 8.0 schemas | ||
uses: ./ | ||
with: | ||
file: db.sql | ||
hostname: '127.0.0.1' | ||
username: 'root' | ||
password: 'root' | ||
database: testdb | ||
|
||
# Uploads db.sql as an artifact of the workflow run | ||
- uses: actions/upload-artifact@v4 | ||
with: | ||
name: db.sql | ||
path: ./db.sql |
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 |
---|---|---|
@@ -1,7 +1,7 @@ | ||
# MySQL Schema Artifact Action | ||
|
||
This action is used to create a SQL Dump file with no exteraneous data except the raw table structures | ||
This can be used to check if a stage and production database have the same schemas before merging code. | ||
This action is used to create a SQL Dump file with no extraneous data except the raw table structures | ||
This can be used to check if a stage and production database have the same schema before merging code. | ||
|
||
``` | ||
inputs: | ||
|
@@ -16,8 +16,7 @@ inputs: | |
|
||
```yaml | ||
# This is a basic workflow to help you get started with Actions | ||
|
||
name: Check Databases | ||
name: Check MySQL 8.0 | ||
|
||
# Controls when the workflow will run | ||
on: | ||
|
@@ -35,34 +34,62 @@ jobs: | |
# This workflow contains a single job called "build" | ||
build: | ||
# The type of runner that the job will run on | ||
runs-on: macos-latest | ||
runs-on: ubuntu-latest | ||
|
||
# Define services required by the job, in this case, MySQL 8.0 | ||
services: | ||
mysql: | ||
image: mysql:8.0 # Use MySQL version 8.0 Docker image | ||
env: | ||
MYSQL_ROOT_PASSWORD: root # Environment variable for MySQL root password | ||
MYSQL_DATABASE: testdb # Environment variable to create a default database | ||
ports: | ||
- 3306:3306 # Map port 3306 inside the container to port 3306 on the host | ||
options: --health-cmd="mysqladmin ping" --health-interval=10s --health-timeout=5s --health-retries=5 # Docker options to ensure MySQL is healthy before proceeding | ||
|
||
# Steps represent a sequence of tasks that will be executed as part of the job | ||
steps: | ||
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it | ||
- uses: actions/checkout@v2 | ||
- name: Install MySQL 5.7 | ||
shell: bash | ||
- uses: actions/checkout@v4 | ||
|
||
# Step to wait for MySQL 8.0 to fully start before proceeding with subsequent steps | ||
- name: Wait for MySQL 8.0 | ||
run: | | ||
brew install mysql | ||
brew install [email protected] | ||
brew unlink mysql && brew link [email protected] | ||
echo 'export PATH="/usr/local/opt/[email protected]/bin:$PATH"' >> /Users/runner/.bash_profile | ||
bash | ||
while ! mysqladmin ping -h"127.0.0.1" --silent; do | ||
sleep 1 | ||
done | ||
# Step to install MySQL client on the GitHub Actions runner | ||
- name: Install the Latest MySQL Client | ||
run: | | ||
sudo apt-get update | ||
sudo apt-get install mysql-client -y | ||
mysql --version | ||
mysqldump --version | ||
# Add a users table to provide some table structure | ||
- name: Create table | ||
run: | | ||
mysql -h 127.0.0.1 -u root --password=root testdb -e "CREATE TABLE IF NOT EXISTS users (id INT AUTO_INCREMENT PRIMARY KEY, name VARCHAR(255), email VARCHAR(255));" | ||
env: | ||
MYSQL_HOST: 127.0.0.1 | ||
MYSQL_PORT: 3306 | ||
MYSQL_ROOT_PASSWORD: root | ||
|
||
# Runs a single command using the runners shell | ||
- name: Check MySQL schemas | ||
- name: Check MySQL 8.0 schemas | ||
uses: ./ | ||
with: | ||
with: | ||
file: db.sql | ||
hostname: ${{ secrets.HOSTNAME }} | ||
username: ${{ secrets.USERNAME }} | ||
password: ${{ secrets.PASSWORD }} | ||
database: ${{ secrets.DATABASE }} | ||
- uses: actions/upload-artifact@v2 | ||
hostname: '127.0.0.1' | ||
username: 'root' | ||
password: 'root' | ||
database: testdb | ||
|
||
# Uploads db.sql as an artifact of the workflow run | ||
- uses: actions/upload-artifact@v4 | ||
with: | ||
name: db.sql | ||
path: ./db.sql | ||
|
||
``` |