Update db.sql #52
Workflow file for this run
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
name: SQL Syntax Check | |
on: | |
pull_request: | |
paths: | |
- 'db.sql' | |
jobs: | |
generate_init_sql: | |
name: Generate init.sql | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout Repository | |
uses: actions/checkout@v2 | |
- name: Generate init.sql | |
run: | | |
mkdir -p ${{ github.workspace }}/init | |
echo "DELETE FROM mysql.proxies_priv WHERE Host != 'localhost';" > ${{ github.workspace }}/init/init.sql | |
echo "Generated init.sql at: ${{ github.workspace }}/init/init.sql" # Output file path | |
- name: Upload init.sql artifact | |
uses: actions/upload-artifact@v2 | |
with: | |
name: init-sql | |
path: ${{ github.workspace }}/init | |
syntax_check: | |
name: Check SQL Syntax | |
runs-on: ubuntu-latest | |
needs: generate_init_sql | |
services: | |
mariadb: | |
image: mariadb:latest | |
env: | |
MYSQL_RANDOM_ROOT_PASSWORD: "yes" # Generate a random root password | |
MYSQL_DATABASE: test # optional, create a test database if needed | |
options: >- | |
--health-cmd="mysqladmin ping" | |
--health-interval=10s | |
--health-timeout=5s | |
--health-retries=3 | |
ports: | |
- 3306:3306 | |
volumes: | |
- ${{ github.workspace }}/init:/docker-entrypoint-initdb.d | |
steps: | |
- name: Checkout Repository | |
uses: actions/checkout@v2 | |
- name: Wait for MariaDB to Start | |
run: dockerize -wait tcp://127.0.0.1:3306 -timeout 1m | |
- name: Run SQL Linting | |
run: | | |
password="${{ secrets.MYSQL_ROOT_PASSWORD }}" | |
docker exec -i ${{ job.services.mariadb.name }} mysql -h localhost -u root -p"$password" < db.sql |