Skip to content

Export JSON/XML/YAML/CSV/MYSQL/PSQL/SQLITE #177

Export JSON/XML/YAML/CSV/MYSQL/PSQL/SQLITE

Export JSON/XML/YAML/CSV/MYSQL/PSQL/SQLITE #177

Workflow file for this run

name: Export JSON/XML/YAML/CSV
on:
push:
branches:
- master
paths-ignore:
- '**'
- '!scripts/export**'
workflow_dispatch:
inputs:
pass:
description: 'Passcode'
required: true
jobs:
export_json_xml:
name: JSON/XML/YAML/CSV
runs-on: ubuntu-latest
strategy:
fail-fast: false
steps:
- name: Checkout
uses: actions/checkout@v2
with:
ref: ${{ github.head_ref }}
- name: Install PHP
uses: shivammathur/setup-php@v2
with:
php-version: '8.0'
extensions: intl #optional
ini-values: "post_max_size=256M" #optional
- name: Cleanup world.sql
run: |
grep -v "DROP TABLE" sql/world.sql > tmpfile && mv tmpfile sql/world.sql
echo -e "DROP TABLE IF EXISTS \`regions\`;\n\n$(cat sql/world.sql)" > sql/world.sql
echo -e "DROP TABLE IF EXISTS \`subregions\`;\n$(cat sql/world.sql)" > sql/world.sql
echo -e "DROP TABLE IF EXISTS \`countries\`;\n$(cat sql/world.sql)" > sql/world.sql
echo -e "DROP TABLE IF EXISTS \`states\`;\n$(cat sql/world.sql)" > sql/world.sql
echo -e "DROP TABLE IF EXISTS \`cities\`;\n$(cat sql/world.sql)" > sql/world.sql
- name: Create & Import DB
run: |
ls -R
sudo systemctl start mysql.service
mysql -V
mysql -uroot -proot -e "CREATE DATABASE world;"
mysql -uroot -proot -e "SHOW DATABASES;"
mysql -uroot -proot --default-character-set=utf8mb4 world < sql/world.sql
- name: Composer Dependencies
run: cd scripts/vendor && composer install
- name: Run Export Scripts
run: |
php scripts/export.php
php scripts/export_xml.php
php scripts/export_yaml.php
php scripts/export_csv.php
mysqldump -uroot -proot --add-drop-table --disable-keys --set-charset --skip-add-locks world regions > sql/regions.sql
mysqldump -uroot -proot --add-drop-table --disable-keys --set-charset --skip-add-locks world subregions > sql/subregions.sql
mysqldump -uroot -proot --add-drop-table --disable-keys --set-charset --skip-add-locks world countries > sql/countries.sql
mysqldump -uroot -proot --add-drop-table --disable-keys --set-charset --skip-add-locks world states > sql/states.sql
mysqldump -uroot -proot --add-drop-table --disable-keys --set-charset --skip-add-locks world cities > sql/cities.sql
- name: Create Pull Request
uses: peter-evans/create-pull-request@v3
with:
commit-message: Add exported JSON, CSV, XML & YAML files
committer: Darshan Gada <[email protected]>
author: ${{ github.actor }} <${{ github.actor }}@users.noreply.github.com>
signoff: true
branch: export/Files
delete-branch: true
title: '(chore): Export JSON, CSV, XML & YAML files'
labels: |
exports
automated
reviewers: dr5hn, valerianpereira